/* =============================================================================
   FBDock — "Apple-clean" design tokens  (light + dark)
   Grounded in: Apple HIG system colors, Apple.com UI, Tailwind neutral scale,
   Radix Colors (semantic), Inter variable font (SIL OFL).
   Base unit: 4px. Type base: 14px (0.875rem) — dashboard density.

   Theme switch: <html data-theme="dark">  (set pre-paint by the inline script in
   App.razor, then kept in sync by wwwroot/js/theme.js). MudBlazor's own palette is
   driven separately from Theme/FBDockTheme.cs and toggled by the same control, so
   the two layers stay in lock-step.
   ============================================================================= */

:root {
  /* ---- Typography ------------------------------------------------------- */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text",
               system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", ui-monospace, "Cascadia Code",
               "Roboto Mono", Menlo, Consolas, monospace;
  /* Inter tuned to read closer to SF (open shapes, simpler 1/4/l) */
  --font-features: "cv02", "cv03", "cv04", "cv11", "ss01";

  /* Type scale (size / line-height) */
  --text-xs:   0.75rem;    --lh-xs:   1rem;      /* 12 / 16  — captions, legends */
  --text-sm:   0.8125rem;  --lh-sm:   1.25rem;   /* 13 / 20  — secondary labels   */
  --text-base: 0.875rem;   --lh-base: 1.375rem;  /* 14 / 22  — body/default       */
  --text-md:   0.9375rem;  --lh-md:   1.5rem;    /* 15 / 24                        */
  --text-lg:   1.0625rem;  --lh-lg:   1.5rem;    /* 17 / 24  — iOS body / card hd  */
  --text-xl:   1.25rem;    --lh-xl:   1.75rem;   /* 20 / 28                        */
  --text-2xl:  1.5rem;     --lh-2xl:  1.875rem;  /* 24 / 30  — section titles      */
  --text-3xl:  1.9375rem;  --lh-3xl:  2.25rem;   /* 31 / 36  — page title          */
  --text-4xl:  2.5rem;     --lh-4xl:  2.75rem;   /* 40 / 44  — hero / big metric    */

  --fw-regular: 400;
  --fw-medium:  500;
  --fw-semibold:600;
  --fw-bold:    700;

  --tracking-tighter: -0.022em;  /* display / 40px+        */
  --tracking-tight:   -0.014em;  /* headings 20–31px       */
  --tracking-snug:    -0.006em;  /* 15–17px                */
  --tracking-normal:   0;        /* body 13–14px           */
  --tracking-wide:     0.02em;   /* UPPERCASE eyebrow labels */

  /* ---- Spacing (4px grid) ---------------------------------------------- */
  --space-0:  0;
  --space-1:  0.25rem;   /* 4  */
  --space-2:  0.5rem;    /* 8  */
  --space-3:  0.75rem;   /* 12 */
  --space-4:  1rem;      /* 16 */
  --space-5:  1.25rem;   /* 20 */
  --space-6:  1.5rem;    /* 24 */
  --space-8:  2rem;      /* 32 */
  --space-10: 2.5rem;    /* 40 */
  --space-12: 3rem;      /* 48 */
  --space-16: 4rem;      /* 64 */
  --space-20: 5rem;      /* 80 */

  /* ---- Radius (generous, Apple-squircle feel) -------------------------- */
  --radius-xs:   6px;    /* chips, tags            */
  --radius-sm:   8px;    /* inputs, small controls */
  --radius-md:  10px;    /* buttons                */
  --radius-lg:  14px;    /* cards (inner)          */
  --radius-xl:  18px;    /* cards / panels         */
  --radius-2xl: 24px;    /* modals, hero surfaces  */
  --radius-full: 9999px;

  /* ---- Motion ----------------------------------------------------------- */
  --ease-out:    cubic-bezier(0.25, 0.1, 0.25, 1);   /* Apple standard */
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);  /* gentle overshoot */
  --dur-fast:   120ms;
  --dur-base:   200ms;
  --dur-slow:   320ms;

  /* =======================================================================
     LIGHT THEME (default)
     ======================================================================= */

  /* Background layers: base(page) < sunken < elevated/card */
  --bg-base:      #F5F5F7;   /* page — Apple light gray      */
  --bg-sunken:    #ECECEF;   /* wells, track backgrounds     */
  --bg-elevated:  #FFFFFF;   /* cards, panels                */
  --bg-card:      #FFFFFF;   /* card surface                 */
  --bg-hover:     #F0F0F3;   /* row/control hover            */
  --bg-active:    #E8E8EC;   /* pressed                      */

  /* Text */
  --text-primary:    #1D1D1F;  /* near-black                 */
  --text-secondary:  #6E6E73;  /* muted body                 */
  --text-tertiary:   #8E8E93;  /* captions / systemGray      */
  --text-quaternary: #AEAEB2;  /* disabled / placeholder     */
  --text-on-accent:  #FFFFFF;

  /* Borders / separators (hairlines) */
  --border-subtle:  #E8E8ED;
  --border-default: #D2D2D7;   /* Apple hairline             */
  --border-strong:  #C6C6CB;

  /* Accent — Apple blue (user choice) */
  --accent:         #0071E3;
  --accent-hover:   #0077ED;
  --accent-active:  #006EDB;
  --accent-subtle:  #E8F1FD;   /* tint fill / selected bg    */
  --accent-contrast:#FFFFFF;
  --accent-ring:    rgba(0, 113, 227, 0.35);  /* focus ring */

  /* Semantic (Apple system colors, light) */
  --success:        #34C759;  --success-bg: #E7F8EC;
  --warning:        #FF9500;  --warning-bg: #FFF4E5;
  --error:          #FF3B30;  --error-bg:   #FDECEA;
  --info:           #007AFF;  --info-bg:    #E8F1FD;

  /* Elevation — soft, low-opacity, multi-layer */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 2px 4px rgba(0,0,0,0.04), 0 4px 10px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 8px rgba(0,0,0,0.04), 0 10px 28px rgba(0,0,0,0.08);
  --shadow-xl: 0 8px 16px rgba(0,0,0,0.06), 0 18px 50px rgba(0,0,0,0.12);

  /* Frosted glass (Apple "materials") — for sidebars, top bars, popovers */
  --glass-bg:     rgba(255,255,255,0.72);
  --glass-border: rgba(255,255,255,0.5);
  --glass-blur:   saturate(180%) blur(20px);

  /* ---- Chart palette (one system; distinct hues; light-tuned) ---------- */
  --chart-cpu:    #0071E3;   /* blue   — compute load   */
  --chart-ram:    #AF52DE;   /* purple — memory         */
  --chart-disk:   #FF9500;   /* orange — storage        */
  --chart-net-rx: #34C759;   /* green  — network in     */
  --chart-net-tx: #FF2D55;   /* pink   — network out    */
  --chart-grid:   #E8E8ED;   /* gridlines               */
  --chart-axis:   #8E8E93;   /* axis labels             */
  --chart-fill-alpha: 0.16;  /* area gradient top alpha */
}

/* =========================================================================
   DARK THEME  — set <html data-theme="dark">
   ========================================================================= */
:root[data-theme="dark"] {
  --bg-base:      #0B0B0D;   /* near-black page              */
  --bg-sunken:    #060607;
  --bg-elevated:  #161618;   /* raised panel                 */
  --bg-card:      #1C1C1E;   /* iOS systemGray6 dark         */
  --bg-hover:     #26262A;
  --bg-active:    #2C2C2E;   /* systemGray5 dark             */

  --text-primary:    #F5F5F7;
  --text-secondary:  #A1A1A6;
  --text-tertiary:   #8E8E93;
  --text-quaternary: #636366;
  --text-on-accent:  #FFFFFF;

  --border-subtle:  #2C2C2E;
  --border-default: #38383A;
  --border-strong:  #48484A;

  --accent:         #0A84FF;  /* systemBlue dark             */
  --accent-hover:   #3395FF;
  --accent-active:  #0A84FF;
  --accent-subtle:  rgba(10,132,255,0.16);
  --accent-contrast:#FFFFFF;
  --accent-ring:    rgba(10,132,255,0.45);

  --success:        #30D158;  --success-bg: rgba(48,209,88,0.14);
  --warning:        #FF9F0A;  --warning-bg: rgba(255,159,10,0.14);
  --error:          #FF453A;  --error-bg:   rgba(255,69,58,0.14);
  --info:           #0A84FF;  --info-bg:    rgba(10,132,255,0.14);

  /* Dark elevation: shadows read weakly on black — pair with a top hairline.
     Keep shadows for depth under modals/popovers only. */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.45);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.55);
  --shadow-xl: 0 18px 50px rgba(0,0,0,0.65);

  --glass-bg:     rgba(22,22,24,0.72);
  --glass-border: rgba(255,255,255,0.08);
  --glass-blur:   saturate(180%) blur(20px);

  --chart-cpu:    #0A84FF;
  --chart-ram:    #BF5AF2;
  --chart-disk:   #FF9F0A;
  --chart-net-rx: #30D158;
  --chart-net-tx: #FF375F;
  --chart-grid:   #2C2C2E;
  --chart-axis:   #8E8E93;
  --chart-fill-alpha: 0.22;
}

/* =========================================================================
   BASE APPLICATION OF TOKENS
   ========================================================================= */
html { color-scheme: light dark; }
:root[data-theme="dark"] { color-scheme: dark; }

body {
  font-family: var(--font-sans);
  font-feature-settings: var(--font-features);
  font-size: var(--text-base);
  line-height: var(--lh-base);
  letter-spacing: var(--tracking-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Numeric metrics (CPU %, MB, rates) — align digits */
.metric, .tabular, .mud-table-cell.fb-num, .fb-tabular {
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tracking-normal);
}

/* Thin custom scrollbars (WebKit) — unobtrusive, Apple-like */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}
