/* PremiumZone VM Monitor — dark glass dashboard.
   Shell-agnostic: same CSS for browser, Tauri webview, and WebView reference. */

:root {
  --bg-0: #070a14;
  --bg-1: #0a0e1a;
  --glass: rgba(20, 27, 45, 0.55);
  --glass-brd: rgba(255, 255, 255, 0.08);
  --glass-hi: rgba(255, 255, 255, 0.04);
  --ink: #e8edf7;
  --ink-dim: #8a93a9;
  --accent: #38e1c4;   /* teal */
  --accent-2: #5b8cff; /* blue */
  --good: #38e1c4;
  --warn: #ffc017;
  --crit: #ff5d6c;
  --radius: 18px;
  --shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.7);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
}

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

/* The HTML `hidden` attribute must win over class display rules (.login-wrap / .sheet-backdrop
   set display:grid, which would otherwise keep hidden elements visible). */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background: radial-gradient(1200px 800px at 15% -10%, #122042 0%, transparent 55%),
              radial-gradient(1000px 700px at 110% 10%, #1a1340 0%, transparent 50%),
              var(--bg-0);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* drifting aurora behind everything */
.aurora {
  position: fixed; inset: -30vh -10vw auto -10vw; height: 80vh; z-index: -1;
  background:
    radial-gradient(40vw 40vw at 20% 30%, rgba(56,225,196,0.16), transparent 60%),
    radial-gradient(36vw 36vw at 80% 20%, rgba(91,140,255,0.18), transparent 60%);
  filter: blur(40px);
  animation: drift 18s ease-in-out infinite alternate;
}
@keyframes drift { from { transform: translate3d(-3%, -2%, 0) scale(1); } to { transform: translate3d(4%, 3%, 0) scale(1.1); } }

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--shadow);
}

.muted { color: var(--ink-dim); }
.tiny { font-size: 12px; }

/* ── LOGIN ─────────────────────────────────────────────────────────────── */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px; border-radius: var(--radius);
  padding: 28px; display: flex; flex-direction: column; gap: 14px;
  animation: rise .5s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.98); } }
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center;
  font-weight: 800; font-size: 18px; letter-spacing: .5px; color: #04211c;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 24px -8px var(--accent);
}
.brand h1 { font-size: 19px; font-weight: 700; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-dim); }
.field.check { flex-direction: row; align-items: flex-start; gap: 10px; color: var(--ink-dim); }
.field input[type=text], .field input[type=url], .field input[type=password], .field input[type=number] {
  width: 100%; padding: 12px 14px; border-radius: 12px; color: var(--ink);
  background: rgba(0,0,0,0.25); border: 1px solid var(--glass-brd);
  font-size: 15px; font-family: var(--sans); transition: border-color .15s, box-shadow .15s;
}
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56,225,196,0.18); }

.btn {
  appearance: none; border: 1px solid var(--glass-brd); cursor: pointer;
  background: rgba(255,255,255,0.06); color: var(--ink);
  padding: 12px 16px; border-radius: 12px; font-size: 15px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform .08s, background .15s, box-shadow .15s;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #042019;
  border: none; box-shadow: 0 10px 26px -10px var(--accent);
}
.btn.primary:hover { box-shadow: 0 12px 30px -10px var(--accent); }
.error { color: var(--crit); font-size: 13px; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.25); border-top-color: #042019; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── DASHBOARD ─────────────────────────────────────────────────────────── */
.dash { max-width: 1100px; margin: 0 auto; padding: 16px; }
.topbar {
  border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  position: sticky; top: 8px; z-index: 5;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.host-meta { display: flex; flex-direction: column; line-height: 1.25; }
.host-meta strong { font-size: 15px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink-dim); box-shadow: 0 0 0 0 transparent; transition: background .3s; }
.status-dot.ok { background: var(--good); box-shadow: 0 0 12px 1px var(--good); animation: pulse 2s ease-in-out infinite; }
.status-dot.bad { background: var(--crit); box-shadow: 0 0 12px 1px var(--crit); }
@keyframes pulse { 50% { box-shadow: 0 0 4px 0 var(--good); } }
.icon-btn {
  width: 38px; height: 38px; border-radius: 11px; cursor: pointer; font-size: 17px;
  background: rgba(255,255,255,0.05); border: 1px solid var(--glass-brd); color: var(--ink);
  display: grid; place-items: center; transition: background .15s, transform .08s;
}
.icon-btn:hover { background: rgba(255,255,255,0.1); }
.icon-btn:active { transform: scale(.94); }

.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.card { border-radius: var(--radius); padding: 18px; min-height: 120px; }
.card h2 { font-size: 13px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; color: var(--ink-dim); margin-bottom: 12px; }
.gauge-card { display: flex; flex-direction: column; align-items: center; }
.gauge { width: 168px; height: 168px; position: relative; }
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge .gauge-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; transform: none; }
.gauge .g-pct { font-size: 34px; font-weight: 700; font-family: var(--mono); line-height: 1; }
.gauge .g-cap { font-size: 11px; color: var(--ink-dim); margin-top: 4px; letter-spacing: .5px; }
.sub { margin-top: 10px; text-align: center; min-height: 16px; }

.spark { width: 100%; display: block; margin-top: 8px; height: 40px; max-height: 48px; }
.spark.wide { height: 48px; }
canvas.linechart { max-height: 240px; }

.load-row { display: flex; gap: 10px; margin-bottom: 14px; }
.load-pill { flex: 1; background: rgba(0,0,0,0.22); border: 1px solid var(--glass-brd); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.lp-val { font-family: var(--mono); font-size: 20px; font-weight: 700; }
.bar-track { height: 8px; border-radius: 6px; background: rgba(0,0,0,0.3); overflow: hidden; }
.bar-fill { height: 100%; width: 0%; border-radius: 6px; background: linear-gradient(90deg, var(--good), var(--accent-2)); transition: width .5s ease, background .3s; }

.net-row { display: flex; gap: 14px; margin-bottom: 10px; }
.net-stat { flex: 1; display: flex; align-items: center; gap: 10px; }
.net-stat strong { font-family: var(--mono); font-size: 18px; display: block; }
.net-arrow { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; }
.net-arrow.down { color: var(--accent); background: rgba(56,225,196,0.12); }
.net-arrow.up { color: var(--accent-2); background: rgba(91,140,255,0.12); }

.svc-list { display: flex; flex-direction: column; gap: 12px; }
.svc { display: flex; flex-direction: column; gap: 5px; }
.svc-head { display: flex; justify-content: space-between; font-size: 13px; }
.svc-head .svc-name { font-weight: 600; text-transform: capitalize; }
.svc-head .svc-val { font-family: var(--mono); color: var(--ink-dim); }
.svc .bar-track { height: 6px; }
.svc .bar-fill { background: linear-gradient(90deg, var(--accent-2), var(--accent)); }

/* section headers between card groups */
.section-head { display: flex; align-items: baseline; gap: 10px; margin: 22px 4px 2px; }
.section-head h3 { font-size: 15px; font-weight: 700; letter-spacing: .3px; }

/* full-width chart cards */
.grid .wide { grid-column: 1 / -1; }
.dash > .card.glass { margin-top: 16px; }
.linechart { width: 100%; display: block; }

/* chart legends */
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
.lg-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-dim); }
.lg-item i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }

/* cloudflare worker cards */
.cf-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.cf-card { background: rgba(0,0,0,0.22); border: 1px solid var(--glass-brd); border-radius: 14px; padding: 14px; }
.cf-card .cf-name { font-weight: 700; font-size: 14px; margin-bottom: 8px; word-break: break-all; }
.cf-row { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }
.cf-row .k { color: var(--ink-dim); }
.cf-row .v { font-family: var(--mono); }
.cf-row .v.bad { color: var(--crit); }
.cf-note { color: var(--ink-dim); font-size: 12px; }

/* services now show CPU% + RAM */
.svc .svc-sub { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-dim); margin-top: 2px; }

.dash-error, .error { margin-top: 8px; }
.dash-error { color: var(--warn); text-align: center; font-size: 13px; margin-top: 16px; }

/* ── SETTINGS SHEET ────────────────────────────────────────────────────── */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(4,6,12,0.6); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 20; padding: 20px; }
.sheet { width: 100%; max-width: 420px; border-radius: var(--radius); padding: 24px; display: flex; flex-direction: column; gap: 16px; animation: rise .3s ease both; }
.sheet h2 { font-size: 18px; }
.sheet-actions { display: flex; justify-content: flex-end; }

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  .aurora, .status-dot.ok { animation: none; }
  * { transition: none !important; }
}
