/* ============================================================
   BASTION — Hosting Control Panel  ·  Design tokens & base
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=IBM+Plex+Sans:wght@400;450;500;600;700&family=JetBrains+Mono:wght@400;500;600&family=Sora:wght@400;500;600;700&family=Outfit:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  /* type */
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  /* accent — overridden live by tweaks */
  --accent: #6C5CE7;
  --accent-fg: #ffffff;

  /* density — overridden live by tweaks */
  --d: 1;                 /* density multiplier */
  --row-h: calc(46px * var(--d));
  --space: calc(20px * var(--d));
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;

  /* semantic status (theme-agnostic-ish, tuned per theme below) */
  --ok: #15a34a;
  --warn: #d97706;
  --err: #dc2626;
  --info: #2563eb;
  --ok-soft: color-mix(in oklab, var(--ok) 14%, transparent);
  --warn-soft: color-mix(in oklab, var(--warn) 16%, transparent);
  --err-soft: color-mix(in oklab, var(--err) 14%, transparent);
  --info-soft: color-mix(in oklab, var(--info) 14%, transparent);

  --accent-soft: color-mix(in oklab, var(--accent) 12%, transparent);
  --accent-line: color-mix(in oklab, var(--accent) 30%, transparent);
}

/* ---------- LIGHT (default) ---------- */
:root, :root[data-theme="light"] {
  --canvas: #eef0f6;
  --canvas-2: #e7e9f2;
  --surface: #ffffff;
  --surface-2: #fbfbfe;
  --elevated: #ffffff;
  --line: #e4e6ef;
  --line-strong: #d4d7e4;
  --text: #16181f;
  --text-muted: #5a5e6e;
  --text-faint: #8a8e9e;
  --sidebar: #14141b;
  --sidebar-text: #c7c9d6;
  --sidebar-muted: #80828f;
  --sidebar-line: #25262f;
  --sidebar-active: #ffffff;
  --shadow-sm: 0 1px 2px rgba(20,22,35,.06), 0 1px 1px rgba(20,22,35,.04);
  --shadow-md: 0 4px 14px rgba(20,22,35,.07), 0 2px 4px rgba(20,22,35,.05);
  --shadow-lg: 0 18px 50px rgba(20,22,35,.13), 0 6px 16px rgba(20,22,35,.07);
  --grid-dot: rgba(20,22,40,.05);
}

/* ---------- DARK ---------- */
:root[data-theme="dark"] {
  --canvas: #08090d;
  --canvas-2: #0c0d12;
  --surface: #121319;
  --surface-2: #15161d;
  --elevated: #191b22;
  --line: #24262f;
  --line-strong: #2f323d;
  --text: #f3f4f8;
  --text-muted: #a2a5b3;
  --text-faint: #6b6e7c;
  --sidebar: #0c0d12;
  --sidebar-text: #b9bcca;
  --sidebar-muted: #6e707e;
  --sidebar-line: #1d1f27;
  --sidebar-active: #ffffff;
  --ok: #34d27e;
  --warn: #f5a623;
  --err: #f25555;
  --info: #4d8df6;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 6px 20px rgba(0,0,0,.45);
  --shadow-lg: 0 24px 60px rgba(0,0,0,.6), 0 8px 20px rgba(0,0,0,.4);
  --grid-dot: rgba(255,255,255,.045);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--canvas);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}
#root { height: 100vh; }

::selection { background: color-mix(in oklab, var(--accent) 30%, transparent); }

/* scrollbars */
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-thumb {
  background: color-mix(in oklab, var(--text-faint) 45%, transparent);
  border-radius: 20px; border: 3px solid transparent; background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: color-mix(in oklab, var(--text-faint) 70%, transparent); background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

h1,h2,h3,h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.02em; margin: 0; }
.mono { font-family: var(--font-mono); font-feature-settings: 'zero' 1; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* utility */
.tnum { font-variant-numeric: tabular-nums; }

/* focus ring */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* entrance */
@keyframes riseIn { from { transform: translateY(9px); } to { transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: no-preference) {
  .rise { animation: riseIn .45s cubic-bezier(.2,.7,.2,1); }
}

/* ---------- interactions ---------- */
.bst-btn:hover { filter: brightness(1.04); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.bst-btn:active { transform: translateY(0); }
.bst-iconbtn:hover { background: color-mix(in oklab, var(--text-faint) 16%, transparent) !important; color: var(--text) !important; }
.bst-card-hover { transition: transform .18s cubic-bezier(.2,.7,.2,1), box-shadow .18s, border-color .18s; cursor: pointer; }
.bst-card-hover:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.bst-listrow { transition: background .13s; }
.bst-listrow:hover { background: color-mix(in oklab, var(--accent) 6%, transparent) !important; }
.bst-nav:hover { background: color-mix(in oklab, #fff 7%, transparent) !important; }
.bst-tree:hover { background: var(--accent-soft); }
.bst-pulse { animation: pulse 1.8s cubic-bezier(.4,0,.6,1) infinite; }
@keyframes pulse { 0% { transform: scale(1); opacity: .55; } 70%,100% { transform: scale(2.6); opacity: 0; } }
.bst-pop { animation: popIn .15s ease; transform-origin: top left; }
@keyframes popIn { from { transform: scale(.97) translateY(-4px); } to { transform: none; } }
.bst-drawer { animation: drawerIn .22s cubic-bezier(.2,.7,.2,1); }
@keyframes drawerIn { from { transform: translateX(28px); } to { transform: none; } }
table { font-variant-numeric: tabular-nums; }

/* form controls */
.bst-select {
  height: 38px; padding: 0 32px 0 12px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%238a8e9e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M3 5l4 4 4-4'/></svg>") no-repeat right 11px center;
  color: var(--text); font-size: 13.5px; font-family: var(--font-body); -webkit-appearance: none; appearance: none; cursor: pointer;
}
.bst-check { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.bst-input {
  height: 38px; width: 100%; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); font-size: 13.5px; outline: none;
}
.bst-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- tabs (PHP port; switched by app.js) ---------- */
/* segmented pill tab bar */
.bst-segbar { display: inline-flex; background: var(--canvas-2); border-radius: 10px; padding: 3px; gap: 2px; border: 1px solid var(--line); flex-wrap: wrap; }
.bst-segbtn { border: none; background: transparent; color: var(--text-muted); font-weight: 550; font-size: 12.5px; padding: 6px 13px; border-radius: 7px; transition: all .15s; display: inline-flex; align-items: center; gap: 7px; }
.bst-segbtn[data-on="1"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.bst-segbtn.sm { font-size: 12px; padding: 5px 10px; }
/* underline tab bar */
.bst-tabbar { display: flex; gap: 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.bst-tab { border: none; background: transparent; color: var(--text-muted); font-weight: 550; font-size: 13px; padding: 10px 13px; position: relative; transition: color .15s; display: inline-flex; align-items: center; gap: 7px; }
.bst-tab:hover { color: var(--text); }
.bst-tab[data-on="1"] { color: var(--text); }
.bst-tab[data-on="1"]::after { content: ''; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.bst-tab .tab-badge { font-size: 10.5px; font-weight: 600; color: var(--text-faint); background: var(--canvas-2); border-radius: 6px; padding: 1px 7px; }

/* vertical nav-tab (settings/profile category lists) */
.bst-navtab { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 11px; border: none; background: transparent; color: var(--text-muted); font-size: 13px; font-weight: 500; border-radius: 9px; text-align: left; position: relative; transition: all .15s; }
.bst-navtab:hover { background: color-mix(in oklab, var(--accent) 6%, transparent); color: var(--text); }
.bst-navtab[data-on="1"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ---------- sidebar collapse (PHP port; toggled by app.js) ---------- */
.bst-sidebar { width: 252px; }
.bst-sidebar-nav { padding: 4px 14px; }
body.sb-collapsed .bst-sidebar { width: 74px; }
body.sb-collapsed .bst-sidebar-nav { padding: 6px 12px; }
body.sb-collapsed .sb-label,
body.sb-collapsed .sb-group-title,
body.sb-collapsed .sb-badge,
body.sb-collapsed .sb-footer,
body.sb-collapsed .sb-active-bar { display: none; }
body.sb-collapsed .sb-brand { justify-content: center; padding: 20px 0; }
body.sb-collapsed .bst-nav { justify-content: center; padding: 10px; }

/* chart horizontal scroll */
.chart-x::-webkit-scrollbar { height: 8px; }
.chart-x::-webkit-scrollbar-thumb { background: color-mix(in oklab, var(--text-faint) 40%, transparent); border-radius: 20px; border: 2px solid transparent; background-clip: padding-box; }
.chart-x::-webkit-scrollbar-thumb:hover { background: color-mix(in oklab, var(--text-faint) 65%, transparent); background-clip: padding-box; }
.chart-x { scrollbar-width: thin; }

/* ============================================================
   Component styles moved out of PHP <style> blocks (2026-06-25)
   for maintainability. Source files noted per section.
   ============================================================ */

/* Theme tweaks panel — from layout/tweaks.php */
.twk-fab { position: fixed; right: 18px; bottom: 18px; z-index: 2147483645; width: 44px; height: 44px; border-radius: 13px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text-muted); box-shadow: var(--shadow-md);
  display: grid; place-items: center; transition: all .15s; }
.twk-fab:hover { color: var(--accent); transform: translateY(-2px); }
.twk-panel { position: fixed; right: 18px; bottom: 74px; z-index: 2147483646; width: 268px; display: none; flex-direction: column;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg);
  font: 12px/1.4 var(--font-body); overflow: hidden; }
.twk-panel.open { display: flex; }
.twk-hd { display: flex; align-items: center; justify-content: space-between; padding: 13px 14px; border-bottom: 1px solid var(--line); }
.twk-hd b { font-size: 13px; font-weight: 600; font-family: var(--font-display); }
.twk-x { border: 0; background: transparent; color: var(--text-faint); width: 24px; height: 24px; border-radius: 7px; font-size: 14px; }
.twk-x:hover { background: var(--canvas-2); color: var(--text); }
.twk-body { padding: 6px 14px 16px; display: flex; flex-direction: column; gap: 11px; }
.twk-sect { font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-faint); padding: 9px 0 0; }
.twk-row { display: flex; flex-direction: column; gap: 6px; }
.twk-lbl { font-weight: 500; color: var(--text-muted); font-size: 12px; }
.twk-seg { display: flex; padding: 3px; gap: 2px; border-radius: 9px; background: var(--canvas-2); border: 1px solid var(--line); }
.twk-seg button { flex: 1; border: 0; background: transparent; color: var(--text-muted); font: inherit; font-weight: 550;
  min-height: 24px; border-radius: 6px; padding: 4px 6px; text-transform: capitalize; }
.twk-seg button[data-on="1"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.twk-chips { display: flex; gap: 7px; }
.twk-chip { flex: 1; height: 30px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; position: relative; box-shadow: 0 0 0 1px var(--line); }
.twk-chip[data-on="1"] { border-color: var(--surface); box-shadow: 0 0 0 2px var(--accent); }
.twk-field { height: 32px; width: 100%; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); font: inherit; outline: none; cursor: pointer; }

/* Toggle switch — from screens/data.php */
.aswitch { position: relative; display: inline-flex; width: 38px; height: 22px; flex-shrink: 0; cursor: pointer; }
.aswitch input { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; }
.aswitch .track { width: 100%; height: 100%; border-radius: 999px; background: var(--line-strong); transition: background .15s; }
.aswitch .knob { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s; }
.aswitch input:checked + .track { background: var(--accent); }
.aswitch input:checked ~ .knob { transform: translateX(16px); }

/* Modal field labels — .dbml from screens/data.php, .wml from screens/sites.php */
.dbml, .wml { display: block; font-size: 11px; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; margin: 16px 0 7px; }
.dbml:first-child, .wml:first-child { margin-top: 0; }
