/* ==========================================================================
   ShiftRelay Design Tokens & Symmetrical Theme System
   WCAG AAA High-Contrast Light and OLED Dark Themes
   ========================================================================== */

:root,
html[data-theme="light"],
body[data-theme="light"] {
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, Monaco, monospace;

  /* Surfaces & Canvas (Light Theme - Linear/Stripe Inspired) */
  --bg-canvas: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-subtle: #f1f5f9;
  --bg-surface-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-glass: rgba(255, 255, 255, 0.92);

  /* Typography Colors */
  --text-main: #0f172a;       /* Slate 900 - High Contrast */
  --text-secondary: #334155;  /* Slate 700 */
  --text-muted: #64748b;      /* Slate 500 */
  --text-subtle: #94a3b8;     /* Slate 400 */
  --text-inverse: #ffffff;

  /* Borders & Dividers */
  --border-subtle: #e2e8f0;   /* Slate 200 */
  --border-medium: #cbd5e1;   /* Slate 300 */
  --border-focus: #008751;    /* Brand Teal */

  /* Brand Accents (Surgical Emerald & Deep Teal) */
  --brand-primary: #008751;
  --brand-primary-hover: #00663D;
  --brand-primary-active: #004D2E;
  --brand-accent: #00A862;
  --brand-accent-subtle: #EAF5EF;

  /* Status Colors */
  --status-green-bg: #EAF5EF;
  --status-green-text: #005A35;
  --status-green-border: #a7f3d0;

  --status-yellow-bg: #fffbeb;
  --status-yellow-text: #92400e;
  --status-yellow-border: #fde68a;

  --status-red-bg: #fef2f2;
  --status-red-text: #991b1b;
  --status-red-border: #fecaca;

  --status-blue-bg: #eff6ff;
  --status-blue-text: #1d4ed8;
  --status-blue-border: #bfdbfe;

  /* Navigation Dock */
  --dock-bg: rgba(255, 255, 255, 0.96);
  --dock-border: rgba(226, 232, 240, 0.9);
  --dock-active: #008751;
  --dock-inactive: #94a3b8;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 12px 28px rgba(15, 23, 42, 0.1);
  --shadow-dock: 0 -4px 20px rgba(15, 23, 42, 0.06);
}

/* ==========================================================================
   Dark Theme (OLED Charcoal & Emerald Accent)
   Strictly High Contrast, Zero Invisible Elements
   ========================================================================== */
:root[data-theme="dark"],
html[data-theme="dark"],
body[data-theme="dark"] {
  /* Surfaces & Canvas (Dark Theme — Deep Blue / Navy, Soft & High Contrast) */
  --bg-canvas: #0f172a;        /* Deep Navy Slate (not pitch black) */
  --bg-surface: #1e293b;       /* Crisp Surface Slate */
  --bg-surface-subtle: #24344d;/* Elevated / Subtle Layer */
  --bg-surface-elevated: #283955;
  --bg-card: #1e293b;
  --bg-card-hover: #273752;
  --bg-glass: rgba(30, 41, 59, 0.94);

  /* Typography Colors */
  --text-main: #f8fafc;       /* Slate 50 - Brilliant white */
  --text-secondary: #cbd5e1;  /* Slate 300 - Clear readable */
  --text-muted: #94a3b8;      /* Slate 400 */
  --text-subtle: #64748b;     /* Slate 500 */
  --text-inverse: #090d16;

  /* Borders & Dividers */
  --border-subtle: #1e293b;   /* Slate 800 */
  --border-medium: #334155;   /* Slate 700 */
  --border-focus: #34d399;    /* Bright Emerald */

  /* Brand Accents */
  --brand-primary: #00A862;
  --brand-primary-hover: #34d399;
  --brand-primary-active: #008751;
  --brand-accent: #34d399;
  --brand-accent-subtle: #004D2E;

  /* Status Colors (Dark Backgrounds) */
  --status-green-bg: #004D2E;
  --status-green-text: #6ee7b7;
  --status-green-border: #005A35;

  --status-yellow-bg: #281e05;
  --status-yellow-text: #fde68a;
  --status-yellow-border: #78350f;

  --status-red-bg: #2d0d12;
  --status-red-text: #fca5a5;
  --status-red-border: #991b1b;

  --status-blue-bg: #0b2247;
  --status-blue-text: #93c5fd;
  --status-blue-border: #1e3a8a;

  /* Navigation Dock */
  --dock-bg: rgba(30, 41, 59, 0.96);
  --dock-border: #334155;
  --dock-active: #34d399;
  --dock-inactive: #94a3b8;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.6);
  --shadow-dock: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   Base Elements & Layout
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background-color: var(--bg-canvas);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  min-height: 100vh;
}

/* Input & Select Defaults mapped to tokens */
input:not([type="checkbox"]):not([type="radio"]),
textarea,
select {
  font-family: inherit;
  font-size: 14px;
  background-color: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(0, 168, 98, 0.15);
}

/* Common Buttons */
button {
  font-family: inherit;
  border: none;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button.primary {
  background: var(--brand-primary);
  color: #ffffff;
  font-weight: 700;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s ease, transform 0.12s ease;
}

button.primary:hover {
  background: var(--brand-primary-hover);
}

button.primary:active {
  transform: scale(0.97);
}

button.secondary {
  background: var(--bg-surface-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-medium);
  font-weight: 600;
  border-radius: var(--radius-md);
  padding: 10px 16px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
}

button.secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
}

/* Theme Toggle Button Component */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-toggle-btn:hover {
  border-color: var(--border-focus);
  transform: translateY(-1px);
}

.theme-toggle-btn:active {
  transform: scale(0.92);
}

.theme-toggle-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}

[data-theme="dark"] .theme-toggle-btn {
  background: var(--bg-surface-subtle);
  border-color: var(--border-medium);
  color: #fde047; /* Golden yellow sun in dark mode */
}

/* ─── Detailed Component Dark Mode Polish ────────────────────────────────── */
[data-theme="dark"] .access-panel,
[data-theme="dark"] .access-form {
  background: var(--bg-surface) !important;
  border-color: var(--border-subtle) !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] .login-intro h1 {
  color: #ffffff !important;
}

[data-theme="dark"] .login-intro p,
[data-theme="dark"] .muted,
[data-theme="dark"] .landing-subtitle {
  color: var(--text-muted) !important;
}

[data-theme="dark"] .eyebrow {
  color: var(--brand-accent) !important;
}

[data-theme="dark"] details.demo-access {
  background: var(--bg-surface-subtle) !important;
  border-color: var(--border-medium) !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] details.demo-access summary {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .role-card {
  background: var(--bg-surface) !important;
  border-color: var(--border-subtle) !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] .role-card strong {
  color: var(--text-main) !important;
}

[data-theme="dark"] .role-card small {
  color: var(--text-muted) !important;
}

[data-theme="dark"] .role-card:hover {
  background: var(--bg-surface-subtle) !important;
  border-color: var(--border-focus) !important;
}

[data-theme="dark"] .heritage-badge {
  background: rgba(0, 168, 98, 0.12) !important;
  border-color: rgba(0, 168, 98, 0.3) !important;
  color: #6ee7b7 !important;
}

[data-theme="dark"] .tour-landing-btn {
  border-color: #00A862 !important;
  color: #34d399 !important;
  background: transparent !important;
}

[data-theme="dark"] .tour-landing-btn:hover {
  background: rgba(0, 168, 98, 0.1) !important;
}

[data-theme="dark"] .feed-audio-card {
  background: var(--bg-surface) !important;
  border-color: var(--border-subtle) !important;
}

[data-theme="dark"] .audio-label {
  color: var(--text-main) !important;
}

[data-theme="dark"] .audio-timer {
  color: var(--text-muted) !important;
}

[data-theme="dark"] .pull-refresh-indicator {
  background: var(--bg-surface) !important;
  border-bottom-color: var(--border-subtle) !important;
  color: var(--text-muted) !important;
}

[data-theme="dark"] .modal-close,
[data-theme="dark"] .dialog-close,
[data-theme="dark"] .shield-dismiss-btn {
  color: var(--text-muted) !important;
}

[data-theme="dark"] .modal-close:hover,
[data-theme="dark"] .dialog-close:hover,
[data-theme="dark"] .shield-dismiss-btn:hover {
  background: var(--bg-surface-subtle) !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] .badge {
  background: var(--bg-surface-subtle) !important;
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .status-radio-option {
  background: var(--bg-surface) !important;
  border-color: var(--border-medium) !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] .status-radio-option:hover {
  border-color: var(--border-focus) !important;
}

[data-theme="dark"] .streak-pill {
  background-color: #2b1807 !important;
  border-color: #7c2d12 !important;
  color: #fed7aa !important;
}

[data-theme="dark"] .streak-pill.checked-in {
  background-color: #004D2E !important;
  border-color: #005A35 !important;
  color: #86efac !important;
}


/* ==========================================================================
   COMPREHENSIVE DARK THEME — App Dashboard & All Remaining Surfaces
   Added to ensure zero invisible text across the entire app in dark mode
   ========================================================================== */

/* --- App Header Bar --- */
[data-theme="dark"] .app-header,
[data-theme="dark"] #app-header {
  background: rgba(17, 24, 39, 0.96) !important;
  border-bottom-color: #1e293b !important;
}

[data-theme="dark"] .app-header-title,
[data-theme="dark"] .app-header h1 {
  color: #f8fafc !important;
}

/* --- Landing Page Hero --- */
[data-theme="dark"] .landing-experience {
  background: var(--bg-canvas) !important;
}

[data-theme="dark"] .landing-hero-visual {
  background: linear-gradient(135deg, #111827 0%, #0f172a 100%) !important;
}

[data-theme="dark"] .hero-content h1,
[data-theme="dark"] .hero-heading {
  color: #f8fafc !important;
}

[data-theme="dark"] .hero-content p,
[data-theme="dark"] .hero-subtext {
  color: #94a3b8 !important;
}

[data-theme="dark"] .landing-sticky-nav {
  background: rgba(9, 13, 22, 0.95) !important;
  border-bottom-color: #1e293b !important;
}

[data-theme="dark"] .brand-mark {
  color: #f8fafc !important;
}

/* --- Access Panel (Login/Register forms) --- */
[data-theme="dark"] .access-tab-strip {
  background: #1e293b !important;
  border-color: #334155 !important;
}

[data-theme="dark"] .access-tab-btn {
  color: #64748b !important;
}

[data-theme="dark"] .access-tab-btn.active {
  background: #111827 !important;
  color: #34d399 !important;
}

[data-theme="dark"] .form-label,
[data-theme="dark"] label {
  color: #94a3b8 !important;
}

[data-theme="dark"] .form-help,
[data-theme="dark"] .field-hint {
  color: #64748b !important;
}

[data-theme="dark"] .telemetry-chip {
  background: rgba(17, 24, 39, 0.9) !important;
  border-color: #334155 !important;
  color: #cbd5e1 !important;
}

/* --- Dashboard Today Tab --- */
[data-theme="dark"] #dashboard,
[data-theme="dark"] .dashboard-inner {
  background: var(--bg-canvas) !important;
}

[data-theme="dark"] .section-heading,
[data-theme="dark"] .tab-section-title {
  color: #f8fafc !important;
}

[data-theme="dark"] .section-label {
  color: #64748b !important;
}

/* --- Handover Tab (Relay) --- */
[data-theme="dark"] #relay-tab,
[data-theme="dark"] .relay-view {
  background: var(--bg-canvas) !important;
  color: #f8fafc !important;
}

[data-theme="dark"] .handover-form-card {
  background: #111827 !important;
  border-color: #1e293b !important;
}

[data-theme="dark"] .relay-header h2 {
  color: #f8fafc !important;
}

[data-theme="dark"] .relay-header p {
  color: #64748b !important;
}

/* --- Status Selector Pills --- */
[data-theme="dark"] .status-option-label {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #cbd5e1 !important;
}

[data-theme="dark"] .status-option-label:hover {
  border-color: #475569 !important;
}

/* --- Task Checklist Items --- */
[data-theme="dark"] .task-item,
[data-theme="dark"] .checklist-item {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}

[data-theme="dark"] .task-owner,
[data-theme="dark"] .task-due {
  color: #64748b !important;
}

/* --- Worker Profile (Me tab) --- */
[data-theme="dark"] .me-view,
[data-theme="dark"] #me-tab {
  background: var(--bg-canvas) !important;
}

[data-theme="dark"] .profile-bio {
  color: #94a3b8 !important;
}

[data-theme="dark"] .credential-badge {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #cbd5e1 !important;
}

[data-theme="dark"] .skill-tag {
  background: #004D2E !important;
  border-color: #005A35 !important;
  color: #6ee7b7 !important;
}

/* --- Modal & Dialog overlays --- */
[data-theme="dark"] .modal-card,
[data-theme="dark"] .dialog-card {
  background: #111827 !important;
  border-color: #1e293b !important;
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .dialog-header {
  border-bottom-color: #1e293b !important;
}

[data-theme="dark"] .modal-title,
[data-theme="dark"] .dialog-title {
  color: #f8fafc !important;
}

/* --- Notification / Alert Banners --- */
[data-theme="dark"] .alert-banner {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #cbd5e1 !important;
}

/* --- Tabs inside pages --- */
[data-theme="dark"] .tab-row,
[data-theme="dark"] .page-tab-strip {
  border-bottom-color: #1e293b !important;
}

[data-theme="dark"] .page-tab-btn {
  color: #64748b !important;
}

[data-theme="dark"] .page-tab-btn.active {
  color: #34d399 !important;
  border-bottom-color: #34d399 !important;
}

/* --- Scroll areas & lists --- */
[data-theme="dark"] .scroll-list-item {
  border-bottom-color: #1e293b !important;
  color: #f8fafc !important;
}

[data-theme="dark"] .scroll-list-item:hover {
  background: #1e293b !important;
}

/* --- Empty / Placeholder states --- */
[data-theme="dark"] .empty-state {
  color: #64748b !important;
}

[data-theme="dark"] .empty-state h3 {
  color: #f8fafc !important;
}

/* --- Account Menu Dropdown --- */
[data-theme="dark"] .account-menu {
  background: #111827 !important;
  border-color: #1e293b !important;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6) !important;
}

[data-theme="dark"] .account-menu-item {
  color: #cbd5e1 !important;
}

[data-theme="dark"] .account-menu-item:hover {
  background: #1e293b !important;
  color: #f8fafc !important;
}

[data-theme="dark"] .account-menu-item svg {
  stroke: #64748b !important;
}

[data-theme="dark"] .account-menu-item:hover svg {
  stroke: #34d399 !important;
}


/* Role cards in demo drive */
.role-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.role-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1.5px solid var(--border-subtle);
  background: var(--bg-surface);
  cursor: pointer;
  text-align: left;
  transition: all 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.role-card:hover {
  border-color: var(--brand-primary);
  background: var(--bg-card-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.role-card:active {
  transform: scale(0.98);
}

.role-card strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.role-card small {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 1px;
  text-transform: capitalize;
}

[data-theme="dark"] .role-card {
  background: var(--bg-surface) !important;
  border-color: var(--border-subtle) !important;
}

[data-theme="dark"] .role-card:hover {
  background: var(--bg-card-hover) !important;
  border-color: var(--brand-primary) !important;
}
