/* =========================================================================
   LEVA ANALYTICS — EXECUTIVE WORKSHOP DESIGN SYSTEM (Emerald & Champagne Gold)
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700;800;900&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@500;700&display=swap');

:root[data-theme="dark"], :root {
  color-scheme: dark;

  /* Core Luxury Emerald & Obsidian Palette */
  --bg: #05140C;
  --bg-canvas: #05140C;
  --surface: rgba(9, 28, 18, 0.88);
  --surface-solid: #0A2216;
  --surface-card: rgba(12, 38, 24, 0.8);
  --user-bg: rgba(212, 175, 55, 0.12);

  --brand-emerald: #007A53;
  --brand-emerald-light: #10B981;
  --brand-emerald-glow: rgba(16, 185, 129, 0.15);

  --gold-primary: #D4AF37;
  --gold-light: #FFF4D1;
  --gold-dark: #997A35;
  --gold-glow: rgba(212, 175, 55, 0.2);
  --gold-border: rgba(212, 175, 55, 0.22);

  --border: rgba(212, 175, 55, 0.18);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-focus: #D4AF37;

  --text: #E2ECE6;
  --text-title: #FFFFFF;
  --text-muted: #8EABA0;
  --text-subtle: #5C7A6E;

  --shell: #041009;
  --shell-text: #FFFFFF;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.65);
  --shadow-glow: 0 0 16px rgba(212, 175, 55, 0.12);

  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-brand: 'Cinzel', serif;
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg: #F5F8F6;
  --bg-canvas: #F5F8F6;
  --surface: rgba(255, 255, 255, 0.95);
  --surface-solid: #FFFFFF;
  --surface-card: #FFFFFF;
  --user-bg: #E2ECE6;

  --brand-emerald: #007A53;
  --brand-emerald-light: #065F46;
  --brand-emerald-glow: rgba(0, 122, 83, 0.08);

  --gold-primary: #B45309;
  --gold-light: #FEF3C7;
  --gold-dark: #78350F;
  --gold-glow: rgba(180, 83, 9, 0.08);
  --gold-border: #E2ECE6;

  --border: #E2ECE6;
  --border-subtle: #F1F5F9;
  --border-focus: #B45309;

  --text: #1E3A2B;
  --text-title: #0C2619;
  --text-muted: #647E72;
  --text-subtle: #92A79D;

  --shell: #0A2216;
  --shell-text: #FFFFFF;
  --shadow: 0 4px 14px rgba(7, 30, 20, 0.05);
  --shadow-lg: 0 8px 24px rgba(7, 30, 20, 0.08);
  --shadow-glow: 0 4px 14px rgba(0, 122, 83, 0.06);
}

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

body.workshop-chat {
  --chat-col-width: 820px;
  --chat-col-pad-x: 20px;
  --voice-rail-width: 360px;
  --composer-bg: var(--surface);
  --composer-border: var(--border);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

[data-theme="dark"] body.workshop-chat {
  background-image:
    radial-gradient(circle at 50% 0%, rgba(212, 175, 55, 0.06) 0%, transparent 55%),
    radial-gradient(circle at 85% 40%, rgba(16, 185, 129, 0.04) 0%, transparent 50%);
}

[data-theme="light"] body.workshop-chat {
  background-image:
    radial-gradient(circle at 50% 0%, rgba(0, 122, 83, 0.03) 0%, transparent 55%),
    radial-gradient(circle at 85% 40%, rgba(212, 175, 55, 0.02) 0%, transparent 50%);
}

/* =========================================================================
   1. EXECUTIVE LOGIN SCREEN (#login-screen)
   ========================================================================= */
#login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 19, 11, 0.88);
  backdrop-filter: blur(16px);
  z-index: 99999;
  padding: 20px;
}

#login-screen.hidden {
  display: none !important;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px 36px;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

#login-title {
  font-family: var(--font-brand);
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--text-title);
  text-align: center;
}

#login-tagline {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 4px;
  margin-bottom: 24px;
  font-weight: 600;
}

.login-card label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.login-card input[type="email"],
.login-card input[type="password"] {
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-canvas);
  color: var(--text-title);
  font-size: 0.92rem;
  margin-bottom: 16px;
  outline: none;
}

.login-card input:focus {
  border-color: var(--gold-primary);
  box-shadow: 0 0 10px var(--gold-glow);
}

.login-opts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.login-opts label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: none;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

#login-btn {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #FFF4D1 0%, #D4AF37 50%, #997A35 100%);
  color: #05140C;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 0 14px var(--gold-glow);
  transition: all 0.2s;
}

#login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 20px rgba(212, 175, 55, 0.5);
}

#login-error {
  margin-top: 14px;
  color: #EF4444;
  font-size: 0.82rem;
  text-align: center;
  font-weight: 600;
}

/* =========================================================================
   2. APP HEADER (LEVA BRANDING)
   ========================================================================= */
#app.with-sidebar {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 100vh;
}

#app.hidden {
  display: none !important;
}

header.ide-header {
  height: 64px;
  background: var(--surface);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

.brand {
  font-family: var(--font-brand);
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 2.5px;
  color: var(--text-title);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand span {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--gold-primary);
  border-left: 1px solid var(--border);
  padding-left: 8px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.text-btn, .theme-toggle-btn {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.text-btn:hover, .theme-toggle-btn:hover {
  border-color: var(--gold-primary);
  color: var(--gold-primary);
}

/* =========================================================================
   3. CHAT LAYOUT & SIDEBAR
   ========================================================================= */
#chat-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
}

#session-sidebar {
  width: 250px;
  background: var(--surface-solid);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
}

#session-sidebar-header {
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

#new-session-btn {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px dashed var(--border);
  background: rgba(212, 175, 55, 0.06);
  color: var(--text-title);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

#new-session-btn:hover {
  background: rgba(212, 175, 55, 0.15);
  border-color: var(--gold-primary);
}

#session-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.session-item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  margin-bottom: 4px;
  transition: all 0.15s ease;
}

.session-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.session-item.active {
  background: rgba(212, 175, 55, 0.12);
  border-color: var(--gold-primary);
}

.session-item-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-title);
}

.session-item-preview {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================================================================
   4. CHAT COLUMN & MINORITY REPORT EXECUTIVE CARDS
   ========================================================================= */
#chat-main {
  flex: 1;
  display: flex;
  flex-direction: row;
  min-width: 0;
  position: relative;
}

#chat-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
  min-width: 0;
}

#chat {
  flex: 1;
  width: 100%;
  overflow-y: auto;
  scroll-behavior: smooth;
}

#messages {
  max-width: var(--chat-col-width);
  width: 100%;
  margin: 0 auto;
  padding: 24px var(--chat-col-pad-x) 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.welcome {
  text-align: center;
  padding: 36px 20px;
  background: var(--surface-card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.welcome h2 {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 6px;
  color: var(--text-title);
}

.welcome p {
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.msg {
  width: 100%;
  display: flex;
  flex-direction: column;
}

.msg.user {
  align-items: flex-end;
}

.msg.user .bubble {
  background: var(--user-bg);
  border: 1px solid var(--border);
  color: var(--text-title);
  padding: 12px 18px;
  border-radius: 16px;
  border-bottom-right-radius: 4px;
  max-width: 80%;
  font-size: 0.92rem;
  font-weight: 600;
}

.msg.assistant {
  align-items: flex-start;
}

/* Executive Result / Chart Card */
.result-card, .chart-card, .plan-validation-card {
  width: 100%;
  background: var(--surface-card);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  transition: border-color 0.25s, box-shadow 0.25s;
}

.result-card:hover, .chart-card:hover {
  border-color: var(--gold-primary);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.result-head, .chart-card-head {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-title);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.04);
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 280px;
  padding: 6px;
}

.refine-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 18px 0;
}

.refine-chip {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}

.refine-chip:hover, .refine-chip.active {
  background: var(--gold-primary);
  color: #05140C;
  border-color: var(--gold-primary);
}

.insight-list {
  padding: 10px 18px 14px 34px;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--text-muted);
}

/* Multi-Block Grid (1 to 4 Tiles) */
.multi-grid {
  display: grid;
  gap: 16px;
  width: 100%;
  padding: 14px;
}

.multi-grid-1 { grid-template-columns: 1fr; }
.multi-grid-2 { grid-template-columns: 1fr; }
.multi-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (max-width: 768px) {
  .multi-grid-4 { grid-template-columns: 1fr; }
}

.analysis-block {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  overflow: hidden;
}

.analysis-block .block-head {
  font-size: 0.84rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--text-title);
}

.analysis-block .block-chart {
  height: 200px;
}

/* =========================================================================
   5. FLOATING MINIMALIST EXECUTIVE COMPOSER DOCK
   ========================================================================= */
#composer-wrap {
  position: sticky;
  bottom: 0;
  width: 100%;
  padding: 10px var(--chat-col-pad-x) 18px;
  background: linear-gradient(transparent, var(--bg) 40%);
  display: flex;
  justify-content: center;
  z-index: 50;
}

#composer-dock {
  max-width: var(--chat-col-width);
  width: 100%;
  background: var(--surface);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#composer-dock:focus-within {
  border-color: var(--gold-primary);
}

#composer-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px 0;
  overflow-x: auto;
}

.composer-chip {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--surface-solid);
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.composer-chip:hover, .composer-chip.active {
  background: rgba(212, 175, 55, 0.15);
  color: var(--text-title);
  border-color: var(--gold-primary);
}

#composer-filters {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.1);
}

#composer-filters.open {
  display: flex;
}

#composer-filters select,
#composer-filters input {
  flex: 1 1 120px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-solid);
  color: var(--text-title);
  font-size: 0.8rem;
  outline: none;
}

#composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--border-subtle);
}

#question {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-title);
  font-size: 0.92rem;
  font-family: inherit;
  resize: none;
  max-height: 140px;
  min-height: 24px;
  line-height: 1.45;
}

#send-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #FFF4D1 0%, #D4AF37 50%, #997A35 100%);
  color: #05140C;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 0 10px var(--gold-glow);
  transition: transform 0.15s;
}

#send-btn:hover:not(:disabled) {
  transform: scale(1.06);
}

/* =========================================================================
   6. PULSATING LEVA LOGO + STEREOSCOPIC WAVEFORM VOICE RAIL (#voice-rail)
   ========================================================================= */
#voice-rail {
  width: var(--voice-rail-width);
  min-width: var(--voice-rail-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  position: relative;
  border-left: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(24px);
  overflow-y: auto;
}

.assistant-stage-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
}

.leva-avatar-container {
  width: 220px;
  height: 220px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.leva-halo-glow {
  position: absolute;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212, 175, 55, 0.22) 0%, rgba(16, 185, 129, 0.1) 50%, transparent 75%);
  animation: ambientBreathe 3.5s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes ambientBreathe {
  0% { transform: scale(0.85); opacity: 0.6; }
  100% { transform: scale(1.2); opacity: 1; }
}

.leva-core-icon {
  width: 86px;
  height: 96px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  animation: emblemPulse 3.5s ease-in-out infinite alternate;
  filter: drop-shadow(0 0 12px rgba(212, 175, 55, 0.5));
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes emblemPulse {
  0% { transform: scale(0.96); filter: drop-shadow(0 0 8px rgba(212, 175, 55, 0.35)); }
  100% { transform: scale(1.04); filter: drop-shadow(0 0 18px rgba(212, 175, 55, 0.65)); }
}

.leva-avatar-container:hover .leva-core-icon {
  transform: scale(1.12);
}

.stereoscope-canvas {
  width: 200px;
  height: 48px;
  margin-top: 14px;
  pointer-events: none;
  z-index: 4;
}

#voice-rail-label {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--text-title);
  margin-top: 14px;
  text-align: center;
}

#voice-sub-caption {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  max-width: 280px;
  margin-top: 6px;
  line-height: 1.45;
}

/* Strategic Indications Panel */
.analysis-insights-view {
  display: none;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  padding-bottom: 70px;
}

.analysis-insights-view.active {
  display: flex;
}

.insight-section-card {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.insight-header {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--gold-primary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.insight-p {
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.55;
}

.docked-iridescent-sphere {
  position: absolute;
  bottom: 18px;
  right: 20px;
  left: 20px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
  z-index: 10;
}

.docked-iridescent-sphere:hover {
  border-color: var(--gold-primary);
  transform: translateY(-2px);
}

.mini-sphere-core {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFF4D1 0%, #D4AF37 40%, #10B981 75%, #05140C 100%);
  box-shadow: 0 0 8px rgba(212, 175, 55, 0.35);
}

.mini-sphere-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-title);
}

/* =========================================================================
   7. MOBILE VOICE TAKEOVER (< 768px)
   ========================================================================= */
@media (max-width: 768px) {
  #voice-rail {
    display: none;
  }
}
