﻿/* =============================================================================
   Callbook — main.css
   CSS custom properties, base reset, layout
   ============================================================================= */

/* --- Custom Properties --- */
:root {
  /* Backgrounds */
  --bg-base:        #0d0f14;
  --bg-surface:     #161a23;
  --bg-elevated:    #1e2430;
  --bg-interactive: #252d3d;
  --bg-hover:       #2e3a50;

  /* Borders */
  --border-subtle:  #1e2838;
  --border-default: #2a3a52;
  --border-focus:   #4a6fa5;

  /* Text */
  --text-primary:   #e8edf5;
  --text-secondary: #8a9ab5;
  --text-muted:     #4a5a72;
  --text-inverse:   #0d0f14;

  /* Accent — amber spotlight */
  --accent:         #e8a820;
  --accent-hover:   #d4961a;
  --accent-muted:   rgba(232, 168, 32, 0.15);
  --accent-text:    #0d0f14;

  /* System colors */
  --eos-color:      #3b82f6;
  --eos-muted:      rgba(59, 130, 246, 0.15);
  --dm7-color:      #10b981;
  --dm7-muted:      rgba(16, 185, 129, 0.15);

  /* Tier colors */
  --tier-observer:  #6b7280;
  --tier-operator:  #3b82f6;
  --tier-lead:      #8b5cf6;
  --tier-td:        #f59e0b;

  /* Status */
  --success:        #22c55e;
  --success-muted:  rgba(34, 197, 94, 0.15);
  --warning:        #f59e0b;
  --warning-muted:  rgba(245, 158, 11, 0.15);
  --error:          #ef4444;
  --error-muted:    rgba(239, 68, 68, 0.15);
  --info:           #38bdf8;
  --info-muted:     rgba(56, 189, 248, 0.15);

  /* Show readiness */
  --readiness-not-cleared:  #6b7280;
  --readiness-assisted:     #f59e0b;
  --readiness-solo:         #22c55e;

  /* Typography */
  --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Consolas', 'Courier New', monospace;

  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  1.875rem;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --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;

  /* Radii */
  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
  --shadow:     0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg:  0 8px 24px rgba(0,0,0,0.6);

  /* Layout */
  --sidebar-width:      240px;
  --sidebar-width-collapsed: 60px;
  --topbar-height:      56px;
  --content-max-width:  1100px;

  /* Transitions */
  --transition: 150ms ease;
  --transition-slow: 250ms ease;
}

/* ── Light theme (system preference) ───────────────────────────────────────── */
@media (prefers-color-scheme: light) {
  :root {
    --bg-base:        #f8f9fb;
    --bg-surface:     #ffffff;
    --bg-elevated:    #f1f4f8;
    --bg-interactive: #e8edf5;
    --bg-hover:       #dde3ed;
    --border-subtle:  #e2e8f0;
    --border-default: #cbd5e1;
    --border-focus:   #4a6fa5;
    --text-primary:   #0d1117;
    --text-secondary: #4a5568;
    --text-muted:     #94a3b8;
    --text-inverse:   #ffffff;
    --shadow-sm:      0 1px 3px rgba(0,0,0,.08);
    --shadow:         0 4px 12px rgba(0,0,0,.12);
    --shadow-lg:      0 8px 24px rgba(0,0,0,.18);
    --accent-text:    #ffffff;
  }
}

/* ── Manual override — JS sets data-theme to lock choice in localStorage ────── */
html[data-theme="light"] {
  --bg-base:        #f8f9fb;
  --bg-surface:     #ffffff;
  --bg-elevated:    #f1f4f8;
  --bg-interactive: #e8edf5;
  --bg-hover:       #dde3ed;
  --border-subtle:  #e2e8f0;
  --border-default: #cbd5e1;
  --border-focus:   #4a6fa5;
  --text-primary:   #0d1117;
  --text-secondary: #4a5568;
  --text-muted:     #94a3b8;
  --text-inverse:   #ffffff;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08);
  --shadow:         0 4px 12px rgba(0,0,0,.12);
  --shadow-lg:      0 8px 24px rgba(0,0,0,.18);
  --accent-text:    #ffffff;
}

html[data-theme="dark"] {
  --bg-base:        #0d0f14;
  --bg-surface:     #161a23;
  --bg-elevated:    #1e2430;
  --bg-interactive: #252d3d;
  --bg-hover:       #2e3a50;
  --border-subtle:  #1e2838;
  --border-default: #2a3a52;
  --border-focus:   #4a6fa5;
  --text-primary:   #e8edf5;
  --text-secondary: #8a9ab5;
  --text-muted:     #4a5a72;
  --text-inverse:   #0d0f14;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.4);
  --shadow:         0 4px 12px rgba(0,0,0,.5);
  --shadow-lg:      0 8px 24px rgba(0,0,0,.6);
  --accent-text:    #0d0f14;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-base);
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { color: var(--accent-hover); text-decoration: underline; }

img, svg { display: block; max-width: 100%; }

input, button, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

button { cursor: pointer; border: none; background: none; }
button:disabled { cursor: not-allowed; opacity: 0.5; }

ul, ol { list-style: none; }

/* --- App Shell Layout --- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition-slow);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  min-height: var(--topbar-height);
}

.sidebar-logo {
  color: var(--accent);
  flex-shrink: 0;
}

.sidebar-theater-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.sidebar-close-btn {
  display: none;
  color: var(--text-secondary);
  padding: var(--space-1);
  border-radius: var(--radius-sm);
}
.sidebar-close-btn:hover { background: var(--bg-interactive); }

.sidebar-nav {
  flex: 1;
  padding: var(--space-4) 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

/* Nav items */
.nav-group {
  padding: var(--space-3) var(--space-4) var(--space-1);
}
.nav-group-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: 0;
  transition: color var(--transition), background var(--transition);
  text-decoration: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.nav-item:hover {
  background: var(--bg-interactive);
  color: var(--text-primary);
  text-decoration: none;
}
.nav-item.active {
  background: var(--accent-muted);
  color: var(--accent);
  border-right: 3px solid var(--accent);
}
.nav-item svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.nav-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-2) var(--space-4);
}

.nav-item--locked {
  opacity: .55;
}
.nav-item--locked:hover {
  opacity: .75;
}

.nav-trial-badge {
  display: inline-flex;
  align-items: center;
  background: var(--accent-muted);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .03em;
  padding: 1px 6px;
  border-radius: 99px;
  margin-left: var(--space-2);
  vertical-align: middle;
}

.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--accent-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}

.sidebar-user-details {
  flex: 1;
  min-width: 0;
}
.sidebar-user-name {
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

/* --- Topbar (mobile) --- */
.topbar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-4);
  z-index: 99;
}

.topbar-menu-btn {
  color: var(--text-secondary);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
}
.topbar-menu-btn:hover { background: var(--bg-interactive); color: var(--text-primary); }

.topbar-title {
  flex: 1;
  font-weight: 600;
  font-size: var(--text-base);
}

/* --- Main Content --- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  padding: var(--space-8);
}

/* View root */
#view-root {
  max-width: var(--content-max-width);
  margin: 0 auto;
}

/* Page header */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
  flex-wrap: wrap;
}

.page-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

.page-actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* --- Loading State --- */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-12);
  color: var(--text-secondary);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-default);
  border-top-color: var(--accent);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-12) var(--space-8);
  text-align: center;
  color: var(--text-secondary);
}
.empty-state svg {
  opacity: 0.3;
  margin: 0 auto;
}
.empty-state h3 {
  color: var(--text-primary);
  font-size: var(--text-lg);
}
.empty-state p {
  font-size: var(--text-sm);
  max-width: 360px;
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .sidebar-close-btn { display: flex; }

  .topbar { display: flex; }

  .main-content {
    margin-left: 0;
    padding-top: calc(var(--topbar-height) + var(--space-6));
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }
}

@media (max-width: 640px) {
  .main-content {
    padding-left: var(--space-3);
    padding-right: var(--space-3);
  }
  .page-header {
    flex-direction: column;
  }
  .page-title {
    font-size: var(--text-xl);
  }
}

/* Sidebar overlay on mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
}
.sidebar-overlay.visible { display: block; }
