/* ============================================================
   ServerPulse v2 — base.css  (reset + design tokens + brand themes)
   Apple-inspired macOS System Settings aesthetic
   ============================================================ */

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

html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  hanging-punctuation: first last;
}

html, body { height: 100%; overflow: hidden; margin: 0; }

body {
  line-height: 1.5;
  font-family: var(--font-body, -apple-system, sans-serif);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
}

img, picture, video, canvas, svg { display: block; max-width: 100%; height: auto; }
ul[role="list"], ol[role="list"] { list-style: none; }
input, button, textarea, select { font: inherit; color: inherit; }

h1, h2, h3, h4, h5, h6 { text-wrap: balance; line-height: 1.2; }
p, li, figcaption { text-wrap: pretty; max-width: 72ch; }

::selection {
  background: oklch(from var(--color-primary) l c h / 0.25);
  color: var(--color-text);
}

:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

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

button { cursor: pointer; background: none; border: none; }
table { border-collapse: collapse; width: 100%; }

a, button, [role="button"], [role="link"], input, textarea, select {
  transition: color var(--transition-fast),
              background var(--transition-fast),
              border-color var(--transition-fast),
              box-shadow var(--transition-fast),
              opacity var(--transition-fast);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0;
}

/* ---- Type scale (Apple SF Pro inspired) ---- */
:root {
  --text-2xs:  0.6875rem;
  --text-xs:   0.75rem;
  --text-sm:   0.8125rem;
  --text-base: 0.875rem;
  --text-lg:   1.0625rem;
  --text-xl:   1.375rem;
  --text-2xl:  1.75rem;

  /* Spacing (tighter, Apple-like) */
  --space-0:  0;
  --space-px: 1px;
  --space-0-5: 0.125rem;
  --space-1:  0.25rem;
  --space-1-5: 0.375rem;
  --space-2:  0.5rem;
  --space-2-5: 0.625rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* Radius (macOS-inspired, 12px for cards) */
  --radius-xs:   4px;
  --radius-sm:   6px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-2xl:  20px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.25, 0.1, 0.25, 1);
  --transition-interactive: 200ms cubic-bezier(0.25, 0.1, 0.25, 1);
  --transition-spring: 350ms cubic-bezier(0.175, 0.885, 0.32, 1.275);

  /* Sidebar / Header sizing */
  --sidebar-width: 240px;
  --sidebar-collapsed: 56px;
  --header-height: 56px;

  /* Fonts (Apple SF Pro stack) */
  --font-body: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Inter', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'JetBrains Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;
}

/* ============================================================
   BRAND THEMES — Applied via data-brand attribute on <html>
   ============================================================ */

/* ---- UNIFIED HOSTING (default / super admin) ---- */
:root, [data-brand="unified"] {
  --brand-primary: #22d3ee;
  --brand-primary-hover: #06b6d4;
  --brand-primary-active: #0891b2;
  --brand-sidebar-bg: #1c1c1e;
  --brand-sidebar-text: #f5f5f7;
  --brand-sidebar-muted: #86868b;
  --brand-sidebar-border: rgba(255, 255, 255, 0.08);
  --brand-sidebar-active-bg: rgba(34, 211, 238, 0.12);
  --brand-header-bg: #1c1c1e;
  --brand-accent: #22d3ee;
}

/* ---- URG HOSTING ---- */
[data-brand="urg"] {
  --brand-primary: #2dd4bf;
  --brand-primary-hover: #14b8a6;
  --brand-primary-active: #0d9488;
  --brand-sidebar-bg: #1a3a3a;
  --brand-sidebar-text: #e0f2f1;
  --brand-sidebar-muted: #80cbc4;
  --brand-sidebar-border: rgba(255, 255, 255, 0.08);
  --brand-sidebar-active-bg: rgba(45, 212, 191, 0.15);
  --brand-header-bg: #1a3a3a;
  --brand-accent: #2dd4bf;
}

/* ---- SW HOSTING ---- */
[data-brand="sw"] {
  --brand-primary: #38bdf8;
  --brand-primary-hover: #0ea5e9;
  --brand-primary-active: #0284c7;
  --brand-sidebar-bg: #1c2333;
  --brand-sidebar-text: #e2e8f0;
  --brand-sidebar-muted: #94a3b8;
  --brand-sidebar-border: rgba(255, 255, 255, 0.08);
  --brand-sidebar-active-bg: rgba(56, 189, 248, 0.12);
  --brand-header-bg: #1c2333;
  --brand-accent: #0072B8;
}

/* ---- Dark Theme (default) — Apple-inspired dark mode ---- */
:root, [data-theme="dark"] {
  --color-bg:               #000000;
  --color-surface:          #1c1c1e;
  --color-surface-2:        #2c2c2e;
  --color-surface-offset:   #232326;
  --color-surface-offset-2: #2c2c2e;
  --color-surface-dynamic:  #38383a;
  --color-divider:          rgba(255, 255, 255, 0.08);
  --color-border:           rgba(255, 255, 255, 0.12);

  --color-text:             #f5f5f7;
  --color-text-muted:       #86868b;
  --color-text-faint:       #48484a;
  --color-text-inverse:     #000000;

  --color-primary:          var(--brand-primary, #22d3ee);
  --color-primary-hover:    var(--brand-primary-hover, #06b6d4);
  --color-primary-active:   var(--brand-primary-active, #0891b2);
  --color-primary-highlight: rgba(34, 211, 238, 0.10);
  --color-primary-muted:    rgba(34, 211, 238, 0.6);

  --color-success:          #30d158;
  --color-success-bg:       rgba(48, 209, 88, 0.12);
  --color-warning:          #ffd60a;
  --color-warning-bg:       rgba(255, 214, 10, 0.12);
  --color-error:            #ff453a;
  --color-error-bg:         rgba(255, 69, 58, 0.12);
  --color-info:             #64d2ff;
  --color-info-bg:          rgba(100, 210, 255, 0.12);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4), 0 0 0 0.5px rgba(255,255,255,0.05);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5), 0 0 0 0.5px rgba(255,255,255,0.05);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.6), 0 0 0 0.5px rgba(255,255,255,0.05);
  --shadow-inset: inset 0 0.5px 0 rgba(255,255,255,0.06);

  /* macOS vibrancy / blur effect */
  --blur-bg: rgba(28, 28, 30, 0.72);
  --blur-amount: 20px;
}

/* ---- Light Theme — Apple-inspired light mode ---- */
[data-theme="light"] {
  --color-bg:               #f2f2f7;
  --color-surface:          #ffffff;
  --color-surface-2:        #f9f9fb;
  --color-surface-offset:   #f2f2f7;
  --color-surface-offset-2: #e5e5ea;
  --color-surface-dynamic:  #d1d1d6;
  --color-divider:          rgba(0, 0, 0, 0.08);
  --color-border:           rgba(0, 0, 0, 0.12);

  --color-text:             #1d1d1f;
  --color-text-muted:       #86868b;
  --color-text-faint:       #aeaeb2;
  --color-text-inverse:     #ffffff;

  --color-primary:          var(--brand-primary-active, #0891b2);
  --color-primary-hover:    var(--brand-primary-hover, #0e7490);
  --color-primary-active:   var(--brand-primary, #155e75);
  --color-primary-highlight: rgba(8, 145, 178, 0.08);
  --color-primary-muted:    rgba(8, 145, 178, 0.6);

  --color-success:          #34c759;
  --color-success-bg:       rgba(52, 199, 89, 0.10);
  --color-warning:          #ff9f0a;
  --color-warning-bg:       rgba(255, 159, 10, 0.10);
  --color-error:            #ff3b30;
  --color-error-bg:         rgba(255, 59, 48, 0.10);
  --color-info:             #007aff;
  --color-info-bg:          rgba(0, 122, 255, 0.10);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 0 0 0.5px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10), 0 0 0 0.5px rgba(0,0,0,0.04);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.14), 0 0 0 0.5px rgba(0,0,0,0.04);
  --shadow-inset: inset 0 0.5px 0 rgba(255,255,255,0.8);

  --blur-bg: rgba(255, 255, 255, 0.72);
  --blur-amount: 20px;
}
