/**
 * themes.css - Light/Dark Theme Variables
 * Codex Platform - CSS Module 2/4
 */

/* =============================================
   LIGHT THEME OVERRIDES
   ============================================= */

[data-theme="light"] {
  /* Warm brand palette (SSOT: tokens.config.json --dcx-*). Same var()
     references as the dark :root — the token itself is theme-aware, so one
     change updates both themes. --bg-primary is the page canvas (body +
     MAIN.chat-container); it maps to the warm GROUND (--dcx-surface-sunken,
     light #f8f5ef = measured mock page bg rgb(248,245,239)). --text-primary
     stays PINNED (approved landing ink). */
  --bg-primary: var(--dcx-surface-sunken); /* page canvas = warm ground (mock --ground) */
  --bg-secondary: var(--dcx-surface-raised);
  --bg-tertiary: var(--dcx-border);
  --bg-hover: var(--dcx-border-strong);
  /* --bg-elevated: warm insurance, mirrors base.css (was only declared in the
     always-dark drawer, fell back cool #252540 elsewhere). */
  --bg-elevated: var(--dcx-surface-raised);
  
  /* Colors - Text (warm ink from SSOT --dcx-ink; see base.css for rationale) */
  --text-primary: var(--dcx-ink);
  --text-secondary: var(--dcx-ink-2);
  --text-muted: var(--dcx-ink-3);
  
  /* Colors - Accent (the one saturated brand colour — warm green) */
  --accent-primary: var(--dcx-accent);
  /* --accent-color: warm brand green; mirrors base.css. Fixes the globally-unset
     token whose var(--accent-color, #3b82f6/#7c3aed) fallbacks painted cool
     focus rings / buttons. Drawer's scoped value still wins inside the drawer. */
  --accent-color: var(--dcx-accent);
  --accent-hover: var(--dcx-accent-hover);
  --accent-success: var(--dcx-success);
  --accent-warning: var(--dcx-warning);
  --accent-error: var(--dcx-danger);
  
  /* Colors - Borders & Shadows */
  --border-color: var(--dcx-border);
  --shadow-color: var(--dcx-card-shadow);
  
  /* Colors - Messages */
  --user-message-bg: color-mix(in srgb, var(--dcx-accent) 9%, var(--dcx-surface));
  --user-message-fg: var(--dcx-ink);
  --user-message-fg-muted: var(--dcx-ink-2);
  --user-message-border: color-mix(in srgb, var(--dcx-accent) 22%, var(--dcx-border));
  --assistant-message-bg: var(--dcx-surface-raised);
  
  /* Colors - Code */
  --code-bg: var(--dcx-surface-sunken);

  /* Global --dc-* aliases (light) - mirrors base.css :root; see the block
     comment there. Publishes the general warm roles app-wide so off-landing
     surfaces (Insights #debugPanel, account dropdown, wells) resolve var(--dc-*)
     to warm cream in light theme. Landing scoped blocks below still win on
     landing elements with identical values. */
  --dc-paper: var(--dcx-surface);
  --dc-band: var(--dcx-surface-raised);
  --dc-ground: var(--dcx-surface-sunken);
  --dc-sunk: var(--dcx-surface-recessed);
  --dc-line: var(--dcx-border);
  --dc-line-hover: var(--dcx-border-strong);
  --dc-ink: var(--dcx-ink);
  --dc-ink-2: var(--dcx-ink-2);
  --dc-ink-3: var(--dcx-ink-3);
  --dc-accent: var(--dcx-accent);
  --dc-card-shadow: var(--dcx-card-shadow);
  --dc-hue-u: var(--dcx-success);
  --dc-hue-s: var(--dcx-warning);
  /* --accent (bare): mirrors base.css — was never declared, so every
     var(--accent, #0078d4/#4db2ff) fallback painted cool blue (datafix chips,
     datafix/roles active-tab, codex-select focus ring). */
  --accent: var(--dcx-accent);
  
  /* Colors - Scrollbar */
  --scrollbar-thumb: var(--dcx-border-strong);
  --scrollbar-track: var(--dcx-surface-raised);
  
  /* Native form-control theming: mirrors base.css — pins
     accent-color warm in light theme so native checkboxes/radios/progress
     and the <select> option-list highlight stop rendering Windows blue. */
  accent-color: var(--dcx-accent);
}

/* =============================================
   LANDING / COMPOSER WARM PALETTE (LIGHT)
   Locked palette, including its known AA failures (ink-3 on paper/ground,
   hue-s on paper) - those are reported, not silently corrected here; see
   the port report for the exact failing pairs and where they are used.
   Scoped ONLY to the welcome/composer, title bar, and compact navigation
   rail (see base.css for the dark default and its matching comment). To
   widen this app-wide, a future owner changes exactly two selector lists:
     base.css: the four-selector landing list -> ":root"
     themes.css (below): the four-selector light list -> "[data-theme="light"]"
   Nothing else needs to change - every consumer already reads var(--dc-*).
   ============================================= */

[data-theme="light"] #welcomeMessage,
[data-theme="light"] .input-container,
[data-theme="light"] .app-header,
[data-theme="light"] .left-nav-rail {
  /* SSOT wiring (light). Each var() resolves to the SAME locked-mock value
     this block held before — landing stays byte-identical. */
  --dc-ground: var(--dcx-surface-sunken);
  --dc-paper: var(--dcx-surface);
  --dc-band: var(--dcx-surface-raised);
  --dc-line: var(--dcx-border);
  --dc-line-hover: var(--dcx-border-strong);
  --dc-ink: var(--dcx-ink);
  --dc-ink-2: var(--dcx-ink-2);
  --dc-ink-3: var(--dcx-ink-3);
  --dc-accent: var(--dcx-accent);
  --dc-card-shadow: rgba(23, 21, 15, 0.09); /* landing-scoped literal locked by p2-home test — value == --dcx-card-shadow (light) */
  --dc-hue-u: var(--dcx-success);
  --dc-hue-t: #3a6ea5;
  --dc-hue-e: #6b5ba8;
  --dc-hue-s: var(--dcx-warning);
  --dc-hue-p: #5c6b78;
}

/* =============================================
   LIGHT THEME SPECIFIC OVERRIDES
   ============================================= */

/* Tool Progress */
[data-theme="light"] .tool-progress-container {
  background: var(--dc-ground); /* was #f8f8f8 cool-grey; warm recessed tray */
  border-left-color: var(--accent-primary);
}

[data-theme="light"] .tool-progress-item {
  background: var(--dc-paper); /* was #ffffff; warm raised chip on the tray */
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .tool-spinner {
  border-color: #ddd;
  border-top-color: var(--accent-primary);
}

/* Reasoning Section */
[data-theme="light"] .reasoning-container {
  background: linear-gradient(135deg, rgba(156, 39, 176, 0.08) 0%, rgba(103, 58, 183, 0.08) 100%);
}

[data-theme="light"] .reasoning-label {
  color: #7b1fa2;
}

[data-theme="light"] .reasoning-content {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-secondary);
}

/* Session Restored Banner */
[data-theme="light"] .session-restored-banner {
  color: #2e7d32;
}

/* Markdown Tables */
[data-theme="light"] .markdown-table tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.02);
}

/* Tool Calls Preview */
[data-theme="light"] .tool-calls-preview details {
  background-color: #e8f5e9;
  border-color: #81c784;
}

[data-theme="light"] .tool-calls-preview summary {
  background-color: #c8e6c9;
  color: #2e7d32;
}

[data-theme="light"] .tool-calls-preview summary:hover {
  background-color: #a5d6a7;
  color: #1b5e20;
}

[data-theme="light"] .tool-calls-content {
  background-color: #f1f8f1;
  color: #2e7d32;
}

/* User Identity Dropdown */
[data-theme="light"] .user-auth-row {
  background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
}

[data-theme="light"] .user-status-badge.authenticated {
  background: #2e7d32;
}

/* =============================================
   ACTIVITY DRAWER — ALWAYS DARK
   Re-declares dark CSS vars scoped to the drawer
   so light theme cannot bleed into it
   ============================================= */

/* The activity drawer is owner-approved always-dark and keeps its purple accent
   identity in BOTH themes. The dark-forcing block below is light-only; but the
   drawer's --accent-color must stay #7c3aed even under the dark theme, where the
   app accent is warm green. Without this, globalizing --accent-color (A1) would
   drop the dark fallback and shift this owner-locked drawer purple->green. */
.activity-drawer {
  --accent-color: #7c3aed;
}

[data-theme="light"] .activity-drawer {
  --bg-primary:    #0f0f1a;
  --bg-secondary:  #141428;
  --bg-tertiary:   #141428;
  --bg-elevated:   #252540;
  --text-primary:  #e2e2e8;
  --text-secondary:#a0a0b8;
  --text-tertiary: #666680;
  --border-color:  #2a2a45;
  --hover-color:   rgba(255,255,255,0.07);
  --accent-color:  #7c3aed;
  color-scheme: dark;
}
