/* ============================================================
   SmartOS Design System — theme.css
   Single source of truth for all tokens, fonts, shell layout,
   and shared component classes.

   Colour palette from Smart Outdoor Brand Guidelines 2025:
     Shadow   #1a083c  — darkest dark
     Fuschia  #7225b1  — primary brand accent
     Illicit  #c175f9  — accent bright / gradient end
     Pouty    #e6d5f1  — soft accent tint

   Typefaces:
     Display / UI headings : Space Grotesk (Google Fonts)
     Body / secondary      : Poppins (Google Fonts)
     System fallback       : Aptos, sans-serif
     Monospace             : system ui-monospace stack
   ============================================================ */

/* ── Google Fonts ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Poppins:wght@300;400;500;600&display=swap');

/* ── Tokens ───────────────────────────────────────────────── */
:root {
  /* Fonts */
  --font-display: 'Space Grotesk', Aptos, sans-serif;
  --font-body:    'Poppins', Aptos, sans-serif;
  --font-mono:    ui-monospace, 'Cascadia Code', 'Fira Mono', 'Courier New', monospace;

  /* Dark chrome — sidebar, topbar */
  --ink-900: #1a083c;   /* Shadow — primary dark bg */
  --ink-800: #25104f;   /* raised dark (inputs on dark bg) */
  --ink-700: #2e1460;   /* hover states on dark */
  --ink-600: #3d1d7a;
  --ink-400: #8a7aaa;   /* muted text on dark */
  --ink-300: #c4b8e0;   /* body text on dark */
  --ink-100: rgba(255,255,255,0.08); /* subtle divider on dark */

  /* Light canvas — main content area */
  --canvas:          #F6F5F0;   /* warm off-white page bg */
  --canvas-raised:   #FFFFFF;   /* cards, tables, modals */
  --canvas-sunken:   #EEEDE6;   /* table headers, hover rows, wells */
  --hairline:        #E4E2D8;   /* default borders */
  --hairline-strong: #D4D2C6;   /* button borders, emphasised dividers */

  /* Text on light canvas */
  --text-primary:   #18211D;
  --text-secondary: #5A645F;
  --text-tertiary:  #8A9089;
  --text-dim:       #8A9089;   /* alias for --text-tertiary (legacy template strings) */

  /* Brand accent — Smart Outdoor Fuschia */
  --accent:       #7225b1;   /* primary accent */
  --accent-hover: #5a1a90;   /* pressed / hover */
  --accent-ink:   #FFFFFF;   /* text on accent */
  --accent-soft:  #e6d5f1;   /* Pouty — tinted backgrounds */
  --accent-light: #c175f9;   /* Illicit — gradient end, highlights */

  /* Neo Purple Gradient (sidebar flourish, icon bg) */
  --gradient-brand: linear-gradient(160deg, #1a083c 0%, #7225b1 60%, #c175f9 100%);

  /* Status colours (WCAG AA on light canvas) */
  --status-live:        #2E8B5C;
  --status-booked:      #B8860B;
  --status-available:   #4A6FA5;
  --status-maintenance: #A04545;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  /* Layout */
  --sidebar-w: 240px;
  --topbar-h:  56px;
  --logo-h-sidebar: 20px;
  --logo-h-light:   26px;

  /* Breakpoints (reference only — CSS doesn't evaluate custom props in @media).
     Convention across the app:
       <  640px  → mobile: card-list transforms, bottom tab bar, bottom sheets.
       640–1024  → tablet: keep desktop density (sidebar + tables).
       ≥ 1024px  → desktop.
     Use these exact values in media queries so the breakpoints stay consistent. */
  --bp-mobile: 640px;
  --bp-tablet: 1024px;

  /* Mobile shell dimensions */
  --mobile-topbar-h: 50px;
  --mobile-tabbar-h: 56px;
}

/* ── Reset basics ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

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

/* ── Shell layout ─────────────────────────────────────────── */
.so-shell {
  display: flex;
  min-height: 100vh;
  font-family: var(--font-body);
  background: var(--canvas);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
}

/* Sidebar */
.so-sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--ink-900);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
}

.so-brand {
  padding: 18px 16px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--ink-100);
  flex-shrink: 0;
}
.so-brand-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: none; /* hidden on desktop; icon-only sidebar shows it on mobile */
}
.so-brand-logo {
  height: var(--logo-h-sidebar);
  width: auto;
  object-fit: contain;
  /* full logo (icon mark + wordmark) — visible on desktop */
}

.so-nav {
  list-style: none;
  margin: 12px 0 0;
  padding: 0 8px;
  flex: 1;
}
.so-nav li { margin: 2px 0; }
.so-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-300);
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}
.so-nav-item .nav-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.so-nav-item:hover {
  background: var(--ink-700);
  color: #fff;
}
.so-nav-item.active {
  background: var(--ink-700);
  color: #fff;
  box-shadow: inset 2px 0 0 var(--accent);
}

.so-nav-section {
  padding: 16px 20px 6px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-400);
}

.so-sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--ink-100);
  flex-shrink: 0;
}
.so-user-email {
  display: block;
  font-size: 11.5px;
  color: var(--ink-400);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.so-signout {
  font-size: 12px;
  color: var(--ink-400);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 500;
}
.so-signout:hover { color: var(--ink-300); }

/* Canvas — right of sidebar */
.so-canvas {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Top bar */
.so-topbar {
  height: var(--topbar-h);
  background: var(--ink-900);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
}
.so-breadcrumb {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}
.so-breadcrumb .bc-parent {
  color: var(--ink-400);
  font-weight: 400;
}
.so-breadcrumb .bc-sep {
  color: var(--ink-600);
  margin: 0 6px;
}
.so-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Main content */
.so-main {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* Light shell — client-facing pages (no sidebar) */
.so-light-shell {
  min-height: 100vh;
  background: var(--canvas);
  font-family: var(--font-body);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.so-light-header {
  height: 60px;
  background: var(--canvas-raised);
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  padding: 0 32px;
}
.so-light-header img { height: var(--logo-h-light); width: auto; }
.so-light-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

/* Responsive — slightly tighter sidebar on narrow laptops */
@media (max-width: 1280px) {
  :root { --sidebar-w: 200px; }
  .so-main { padding: 20px; }
  .so-topbar { padding: 0 18px; }
}

/* Below 768px (tablets / phones) collapse sidebar to icon strip with
   the billboard mark only. Desktop & laptop always show full sidebar. */
@media (max-width: 767px) {
  .so-sidebar { width: 60px; }
  .so-brand-logo,
  .so-nav-item > span,
  .so-nav-item .nav-label,
  .so-nav-section,
  .so-user-email,
  .so-signout { display: none; }
  .so-brand-icon { display: block; } /* show icon mark when sidebar is collapsed */
  .so-brand { justify-content: center; padding: 14px 8px; }
  .so-nav-item { justify-content: center; padding: 10px; }
  .so-nav-item .nav-icon { width: auto; }
  .so-main { padding: 16px; }
}

/* ── Cards ────────────────────────────────────────────────── */
.so-card {
  background: var(--canvas-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 20px;
}
.so-card-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin: 0 0 6px;
}
.so-card-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}
.so-card-value.hero { color: var(--accent); }

/* ── Buttons ──────────────────────────────────────────────── */
.so-btn {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13.5px;
  padding: 7px 15px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1;
  text-decoration: none;
  transition: background 0.12s, opacity 0.12s;
  white-space: nowrap;
}
.so-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Primary — dark, not purple */
.so-btn-primary { background: var(--ink-900); color: #fff; }
.so-btn-primary:hover:not(:disabled) { background: var(--ink-700); }

/* Accent — use sparingly (brand moments only) */
.so-btn-accent  { background: var(--accent); color: var(--accent-ink); }
.so-btn-accent:hover:not(:disabled) { background: var(--accent-hover); }

/* Ghost */
.so-btn-ghost {
  background: transparent;
  border: 1px solid var(--hairline-strong);
  color: var(--text-primary);
}
.so-btn-ghost:hover:not(:disabled) { background: var(--canvas-sunken); }

/* Danger */
.so-btn-danger { background: #dc2626; color: #fff; }
.so-btn-danger:hover:not(:disabled) { background: #b91c1c; }

/* Size variants */
.so-btn-sm { font-size: 12px;   padding: 5px 11px; }
.so-btn-md { font-size: 13.5px; padding: 7px 15px; } /* default */
.so-btn-lg { font-size: 15px;   padding: 10px 20px; }

/* ── Tables ───────────────────────────────────────────────── */
.so-table-wrap {
  background: var(--canvas-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.so-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.so-table thead tr {
  background: var(--canvas-sunken);
  border-bottom: 1px solid var(--hairline);
}
.so-table th {
  padding: 9px 14px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-tertiary);
  text-align: left;
  white-space: nowrap;
}
.so-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline);
  color: var(--text-primary);
  vertical-align: middle;
}
.so-table tbody tr:last-child td { border-bottom: none; }
.so-table tbody tr:hover td { background: var(--canvas-sunken); }
.so-table .mono { font-family: var(--font-mono); font-size: 12.5px; }
.so-table .muted { color: var(--text-secondary); }

/* Row actions — hidden at rest, shown on row hover */
.so-table .row-actions { visibility: hidden; }
.so-table tbody tr:hover .row-actions { visibility: visible; }

/* ── Status tags ──────────────────────────────────────────── */
.so-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}
.so-tag::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.so-tag-live        { color: var(--status-live);         background: #E4F3EB; }
.so-tag-booked      { color: var(--status-booked);       background: #FDF3D8; }
.so-tag-available   { color: var(--status-available);    background: #E8EEF7; }
.so-tag-maintenance { color: var(--status-maintenance);  background: #F5E8E8; }
.so-tag-draft       { color: var(--text-tertiary);       background: var(--canvas-sunken); }

/* ── Forms / inputs ───────────────────────────────────────── */
.so-input,
.so-select,
.so-textarea {
  font-family: var(--font-body);
  font-size: 13.5px;
  background: var(--canvas-raised);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-primary);
  outline: none;
  width: 100%;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.so-input:focus,
.so-select:focus,
.so-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.so-input::placeholder,
.so-textarea::placeholder { color: var(--text-tertiary); }

.so-label {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ── Page section headers ─────────────────────────────────── */
.so-page-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 4px;
}
.so-page-sub {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin: 0 0 20px;
}

/* Toolbar row (search + filters + actions) */
.so-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.so-toolbar .so-input { max-width: 280px; }

/* Stat card grid */
.so-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

/* ── Divider ──────────────────────────────────────────────── */
.so-divider {
  border: none;
  border-top: 1px solid var(--hairline);
  margin: 20px 0;
}

/* ── Toast / notification strip ──────────────────────────── */
.so-toast-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

/* Individual toast (used by utils.js) */
.so-toast {
  font-family: var(--font-body);
  font-size: 13.5px;
  color: #fff;
  background: var(--ink-900);
  border: 1px solid var(--ink-700);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  box-shadow: 0 6px 24px rgba(26, 8, 60, 0.45);
  pointer-events: auto;
  max-width: 420px;
}
.so-toast-success { border-left: 3px solid var(--status-live); }
.so-toast-error   { border-left: 3px solid #dc2626; }
.so-toast-info    { border-left: 3px solid var(--accent-light); }

/* ── Empty states ─────────────────────────────────────────── */
.so-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
  background: var(--canvas-raised);
  border: 1px dashed var(--hairline-strong);
  border-radius: var(--radius-md);
}
.so-empty-icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.4;
}
.so-empty-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 4px;
}
.so-empty-sub {
  font-size: 13px;
  color: var(--text-tertiary);
  margin: 0 0 16px;
}

/* ── Stale data / info banner ─────────────────────────────── */
.so-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #FDF3D8;
  color: #6b4a00;
  font-size: 13px;
  border-bottom: 1px solid #F0D98A;
}
.so-banner .so-banner-close {
  margin-left: auto;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: inherit;
  opacity: 0.6;
}
.so-banner .so-banner-close:hover { opacity: 1; }
