/* ═══════════════════════════════════════════════════════════
   Nexus Panel – CSS
   Theme: Dark industrial / terminal-adjacent
   Fonts: Syne (display) + DM Sans (body) + JetBrains Mono (code)
═══════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0d0e12;
  --surface:     #141519;
  --surface2:    #1b1c23;
  --surface3:    #22232d;
  --border:      rgba(255,255,255,0.07);
  --border-hover:rgba(255,255,255,0.13);
  --text:        #dde0ec;
  --muted:       #6b6e82;
  --discord:     #5865f2;
  --discord-h:   #7289f5;
  --accent:      #00d4ff;
  --green:       #2ecc71;
  --red:         #e74c3c;
  --yellow:      #f39c12;
  --sidebar-w:   220px;
  --header-h:    54px;
  --radius:      10px;
  --radius-lg:   16px;
}

html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Views ─────────────────────────────────────────────── */
.view { display: none; min-height: 100vh; }
.view.active { display: flex; }

/* ═══════════════════════════════════════════════════════
   LANDING
═══════════════════════════════════════════════════════ */
#view-landing {
  position: relative;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.landing-bg {
  position: absolute; inset: 0;
  pointer-events: none; overflow: hidden;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: .18;
}
.blob-1 {
  width: 600px; height: 600px;
  background: #5865f2;
  top: -150px; left: -100px;
  animation: drift 12s ease-in-out infinite alternate;
}
.blob-2 {
  width: 500px; height: 500px;
  background: #00d4ff;
  bottom: -100px; right: -80px;
  animation: drift 16s ease-in-out infinite alternate-reverse;
}
@keyframes drift { 0%{transform:translate(0,0)} 100%{transform:translate(40px,30px)} }

/* Login card (corner widget) */
.login-card {
  position: fixed;
  top: 1.5rem; right: 1.5rem;
  background: rgba(20,21,25,0.95);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px);
  width: 300px;
  z-index: 200;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  overflow: hidden;
  transition: box-shadow .2s;
}
.login-card:hover { box-shadow: 0 24px 70px rgba(0,0,0,.65); }

.login-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1.2rem;
  border-bottom: 1px solid var(--border);
}
.logo-sm {
  font-family: 'Syne', sans-serif;
  font-weight: 800; font-size: 1.1rem;
  letter-spacing: -.03em;
}
.logo-sm em { font-style: normal; color: var(--accent); }

.login-toggle-btn {
  background: none; border: none; color: var(--muted);
  cursor: pointer; padding: .2rem;
  transition: color .15s;
  display: none; /* hidden on desktop */
}
.login-toggle-btn:hover { color: var(--text); }
.login-toggle-btn svg { width: 18px; height: 18px; display: block; }

.login-card-body { padding: 1.4rem 1.2rem; }
.login-card-body.collapsed { display: none; }

.login-welcome { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 1rem; margin-bottom: .3rem; }
.login-sub { color: var(--muted); font-size: .85rem; margin-bottom: 1.2rem; }
.login-privacy { color: var(--muted); font-size: .75rem; text-align: center; margin-top: .8rem; }

.btn-discord {
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  width: 100%;
  background: var(--discord); color: #fff;
  border: none; padding: .75rem; border-radius: 8px;
  font-family: 'DM Sans', sans-serif; font-size: .9rem; font-weight: 500;
  cursor: pointer;
  transition: background .2s, transform .15s, box-shadow .2s;
  box-shadow: 0 4px 20px rgba(88,101,242,.3);
}
.btn-discord:hover { background: var(--discord-h); transform: translateY(-1px); box-shadow: 0 6px 28px rgba(88,101,242,.45); }

/* Landing hero */
.landing-hero {
  text-align: center;
  padding: 2rem;
  max-width: 700px;
}
.hero-badge {
  display: inline-flex; align-items: center; gap: .5rem;
  background: rgba(88,101,242,.12);
  border: 1px solid rgba(88,101,242,.25);
  color: #a0aaff;
  padding: .3rem .9rem; border-radius: 999px;
  font-size: .8rem; margin-bottom: 1.5rem;
}
.pulse-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.2} }

.landing-hero h1 {
  font-family: 'Syne', sans-serif;
  font-size: clamp(2.4rem, 6vw, 5rem);
  font-weight: 800;
  letter-spacing: -.04em;
  line-height: 1.05;
}
.landing-hero h1 em { font-style: normal; color: var(--accent); }
.hero-sub { color: var(--muted); font-size: 1.05rem; margin-top: 1rem; }

/* Error toast on landing */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); padding: .75rem 1.4rem;
  border-radius: 999px; font-size: .875rem;
  z-index: 999; white-space: nowrap;
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
  transition: opacity .3s;
}
.toast.toast-error { border-color: rgba(231,76,60,.4); color: #ff7b72; }
.toast.hidden { display: none; }

/* ═══════════════════════════════════════════════════════
   DASHBOARD LAYOUT
═══════════════════════════════════════════════════════ */
#view-dashboard {
  flex-direction: row;
}

/* Mobile header (hidden on desktop) */
.mobile-header {
  display: none;
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center; justify-content: space-between;
  padding: 0 1.2rem;
  z-index: 150;
}
.sidebar-toggle {
  background: none; border: none; color: var(--muted);
  cursor: pointer; padding: .3rem;
  transition: color .15s;
}
.sidebar-toggle svg { width: 22px; height: 22px; display: block; }
.sidebar-toggle:hover { color: var(--text); }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  position: sticky; top: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 1.4rem 0;
  flex-shrink: 0;
  transition: transform .3s ease;
  z-index: 100;
}
.sidebar-logo {
  font-family: 'Syne', sans-serif;
  font-weight: 800; font-size: 1.25rem;
  letter-spacing: -.03em;
  padding: 0 1.2rem 1.4rem;
}
.sidebar-logo em { font-style: normal; color: var(--accent); }

.sidebar-nav {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column;
  gap: 2px; padding: 0 .6rem;
}
.nav-section {
  font-size: .68rem; text-transform: uppercase;
  letter-spacing: .1em; color: var(--muted);
  padding: .8rem .6rem .3rem;
  display: block;
}
.nav-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .55rem .7rem;
  border-radius: 8px;
  color: var(--muted); text-decoration: none;
  font-size: .875rem;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.05); color: var(--text); }
.nav-item.active { background: rgba(88,101,242,.15); color: #a0aaff; }

.sidebar-bottom { padding: .6rem; }
.user-chip {
  display: flex; align-items: center; gap: .7rem;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; padding: .7rem .8rem;
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
  background: var(--discord);
}
.user-info { flex: 1; min-width: 0; }
.user-name { display: block; font-size: .85rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-tag  { display: block; font-size: .72rem; color: var(--muted); }
.logout-btn {
  background: none; border: none; color: var(--muted);
  cursor: pointer; padding: .25rem; flex-shrink: 0;
  transition: color .15s;
}
.logout-btn:hover { color: var(--red); }
.logout-btn svg { width: 16px; height: 16px; display: block; }

/* Overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}

/* Main content */
.main-content {
  flex: 1; overflow-y: auto;
  padding: 2.2rem 2rem;
  min-width: 0;
}

/* ── Page sections ─────────────────────────────────────── */
.page-section { display: none; animation: fadeUp .35s ease; }
.page-section.active { display: block; }
@keyframes fadeUp { from{opacity:0;transform:translateY(12px)} to{opacity:1;transform:none} }

.page-header {
  display: flex; align-items: baseline; justify-content: space-between;
  flex-wrap: wrap; gap: .5rem;
  margin-bottom: 1.8rem;
}
.page-header h2 {
  font-family: 'Syne', sans-serif;
  font-size: 1.55rem; font-weight: 700;
}
.page-header p { color: var(--muted); font-size: .9rem; }

/* ── Stats row ─────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem; margin-bottom: 1.8rem;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.2rem;
}
.stat-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: .4rem; }
.stat-val { font-family: 'Syne', sans-serif; font-size: 1.6rem; font-weight: 700; }

/* ── Server detail card ────────────────────────────────── */
.server-detail-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.6rem;
}
.srv-title-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.4rem;
}
.srv-title-row h3 { font-family: 'Syne', sans-serif; font-size: 1.2rem; font-weight: 700; }
.srv-vmid { font-family: 'JetBrains Mono', monospace; font-size: .8rem; color: var(--muted); display: block; margin-top: .2rem; }

/* Status pill */
.status-pill {
  padding: .25rem .8rem; border-radius: 999px;
  font-size: .78rem; font-weight: 500; white-space: nowrap;
  flex-shrink: 0;
}
.status-running { background: rgba(46,204,113,.12); color: var(--green); border: 1px solid rgba(46,204,113,.25); }
.status-stopped { background: rgba(231,76,60,.1);   color: var(--red);   border: 1px solid rgba(231,76,60,.2); }
.status-unknown  { background: rgba(107,110,130,.1); color: var(--muted); border: 1px solid var(--border); }

/* Power controls */
.power-controls {
  display: flex; flex-wrap: wrap; gap: .6rem;
  margin-bottom: 1.6rem;
}
.btn-action {
  border: 1px solid var(--border);
  background: var(--surface2); color: var(--text);
  padding: .5rem 1rem; border-radius: 7px;
  font-family: 'DM Sans', sans-serif; font-size: .85rem;
  cursor: pointer; transition: background .15s, border-color .15s, transform .1s;
}
.btn-action:hover { border-color: var(--border-hover); background: var(--surface3); transform: translateY(-1px); }
.btn-action:active { transform: none; }
.btn-start:hover    { border-color: rgba(46,204,113,.4); color: var(--green); }
.btn-shutdown:hover { border-color: rgba(231,76,60,.4);  color: var(--red); }
.btn-reboot:hover   { border-color: rgba(0,212,255,.3);  color: var(--accent); }
.btn-stop:hover     { border-color: rgba(231,76,60,.4);  color: var(--red); }

/* Resource bars */
.resource-bars { display: flex; flex-direction: column; gap: .8rem; margin-bottom: 1.8rem; }
.res-row { display: flex; align-items: center; gap: .8rem; }
.res-label { font-size: .78rem; color: var(--muted); width: 36px; flex-shrink: 0; }
.res-bar { flex: 1; height: 7px; background: var(--surface3); border-radius: 999px; overflow: hidden; }
.res-fill { height: 100%; background: var(--discord); border-radius: 999px; transition: width .5s ease; width: 0; }
.res-pct { font-family: 'JetBrains Mono', monospace; font-size: .78rem; color: var(--muted); width: 42px; text-align: right; flex-shrink: 0; }

/* Section blocks (snapshots, reinstall) */
.section-block {
  border-top: 1px solid var(--border); padding-top: 1.4rem; margin-top: 1.4rem;
}
.section-block-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .9rem;
}
.section-block-header h4 { font-family: 'Syne', sans-serif; font-size: .95rem; font-weight: 600; }

/* Snapshot list */
.snapshot-list { list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.snapshot-list li { display: flex; align-items: center; gap: .75rem; padding: .55rem .75rem; background: var(--surface2); border-radius: 8px; border: 1px solid var(--border); font-size: .875rem; }
.snapshot-list .snap-name { flex: 1; font-family: 'JetBrains Mono', monospace; font-size: .82rem; }
.snap-actions { display: flex; gap: .4rem; }
.muted-item { color: var(--muted); font-size: .875rem; }

/* Reinstall */
.reinstall-area { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.hint-text { font-size: .78rem; color: var(--muted); margin-top: .6rem; }

/* ── Console ───────────────────────────────────────────── */
.console-wrapper { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; height: 580px; display: flex; align-items: center; justify-content: center; }
.console-placeholder { text-align: center; color: var(--muted); }
.console-icon { font-size: 2.5rem; margin-bottom: .8rem; }
.vnc-frame { width: 100%; height: 100%; border: none; }

/* ── Table ─────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th { text-align: left; padding: .8rem 1rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,.02); }
.loading-cell { text-align: center; color: var(--muted); padding: 2rem !important; }

/* User row */
.user-row-info { display: flex; align-items: center; gap: .7rem; }
.user-row-info img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.user-row-name { font-size: .875rem; font-weight: 500; }
.user-row-id   { font-family: 'JetBrains Mono', monospace; font-size: .72rem; color: var(--muted); }

/* Badge */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 500; }
.badge-active   { background: rgba(46,204,113,.12); color: var(--green); border: 1px solid rgba(46,204,113,.2); }
.badge-inactive { background: rgba(231,76,60,.1);   color: var(--red);   border: 1px solid rgba(231,76,60,.2); }
.badge-admin    { background: rgba(0,212,255,.1);   color: var(--accent);border: 1px solid rgba(0,212,255,.2); }

/* ── Assign card ───────────────────────────────────────── */
.assign-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.4rem;
}
.assign-card h4 { font-family: 'Syne', sans-serif; font-size: .95rem; margin-bottom: 1rem; }
.assign-form { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-start; }

/* ── Forms ─────────────────────────────────────────────── */
.form-select, .form-input {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: 7px; padding: .5rem .8rem;
  font-family: 'DM Sans', sans-serif; font-size: .875rem;
  min-width: 160px;
  transition: border-color .2s;
}
.form-select:focus, .form-input:focus { outline: none; border-color: rgba(88,101,242,.5); }

/* ── Buttons ───────────────────────────────────────────── */
.btn-sm {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: 7px; padding: .4rem .9rem;
  font-family: 'DM Sans', sans-serif; font-size: .82rem;
  cursor: pointer; transition: background .15s, border-color .15s;
}
.btn-sm:hover { background: var(--surface3); border-color: var(--border-hover); }

.btn-primary-sm {
  background: var(--discord); border: none; color: #fff;
  border-radius: 7px; padding: .5rem 1rem;
  font-family: 'DM Sans', sans-serif; font-size: .875rem;
  cursor: pointer; transition: background .2s;
}
.btn-primary-sm:hover { background: var(--discord-h); }

.btn-danger-sm {
  background: rgba(231,76,60,.1); border: 1px solid rgba(231,76,60,.2);
  color: var(--red); border-radius: 7px; padding: .5rem 1rem;
  font-family: 'DM Sans', sans-serif; font-size: .875rem;
  cursor: pointer; transition: background .2s;
}
.btn-danger-sm:hover { background: rgba(231,76,60,.2); }

.btn-icon {
  background: none; border: none; color: var(--muted);
  cursor: pointer; padding: .2rem .4rem; border-radius: 4px;
  font-size: .8rem; transition: color .15s, background .15s;
}
.btn-icon:hover { color: var(--text); background: rgba(255,255,255,.06); }
.btn-icon.danger:hover { color: var(--red); }

/* ── Modals ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; padding: 1rem;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 440px;
  box-shadow: 0 24px 60px rgba(0,0,0,.6);
  animation: fadeUp .2s ease;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.2rem 1.4rem; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-family: 'Syne', sans-serif; font-size: 1rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1rem; padding: .2rem .4rem; border-radius: 4px; transition: color .15s; }
.modal-close:hover { color: var(--text); }
.modal-body  { padding: 1.2rem 1.4rem; }
.modal-footer { padding: .8rem 1.4rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .6rem; }

/* Empty / no server */
.no-server-msg { text-align: center; padding: 3rem 2rem; color: var(--muted); }
.empty-icon { font-size: 2.5rem; margin-bottom: .8rem; }
.muted { color: var(--muted); }

/* ── Utility ───────────────────────────────────────────── */
.hidden { display: none !important; }
.mono { font-family: 'JetBrains Mono', monospace; }
hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
label { font-size: .85rem; color: var(--muted); display: block; margin-bottom: .3rem; margin-top: .8rem; }
label:first-child { margin-top: 0; }

/* ═══════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .mobile-header { display: flex; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    padding-top: calc(var(--header-h) + 1rem);
    z-index: 140;
  }
  .sidebar.open { transform: none; }
  .sidebar-overlay.active { display: block; }

  .main-content {
    padding: 1.4rem 1rem;
    padding-top: calc(var(--header-h) + 1.4rem);
  }

  /* Landing: login card becomes top-center */
  .login-card {
    top: 1rem; right: 1rem; left: 1rem;
    width: auto;
  }
  .login-toggle-btn { display: flex; }
}

@media (max-width: 600px) {
  .power-controls { gap: .4rem; }
  .btn-action { padding: .45rem .7rem; font-size: .8rem; }
  .assign-form { flex-direction: column; }
  .assign-form .form-select,
  .assign-form .form-input { min-width: 0; width: 100%; }

  .stats-row { grid-template-columns: 1fr 1fr; }

  .page-header { flex-direction: column; align-items: flex-start; }
}
