/* ============================================================
   RegGuardian — War Room Dark Theme
   ============================================================ */

:root {
  --bg-base:      #0b0d11;
  --bg-surface:   #111418;
  --bg-elevated:  #191d24;
  --bg-card:      #1e2330;

  --border:       #2a2f3d;
  --border-bright:#3a4255;

  --text-primary: #e8ecf5;
  --text-secondary:#9ba3b8;
  --text-muted:   #5a6178;

  --accent-blue:  #3b82f6;
  --accent-cyan:  #06b6d4;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-red:   #ef4444;
  --accent-purple:#8b5cf6;

  --p1-color:     #ef4444;
  --p2-color:     #f59e0b;
  --p3-color:     #10b981;

  --font-sans:    'Inter', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', monospace;

  --radius-sm:    4px;
  --radius-md:    8px;
  --radius-lg:    12px;

  --shadow-sm:    0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:    0 4px 12px rgba(0,0,0,0.5);
  --shadow-glow:  0 0 20px rgba(59,130,246,0.15);

  --transition:   0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

/* ─── Top Bar ────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
}

.topbar-left, .topbar-center, .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.topbar-center { justify-content: center; }
.topbar-right  { justify-content: flex-end; }

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}
.logo-shield { font-size: 20px; }

/* ─── ARIA Status Badge ───────────────────────────────────── */
.aria-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  border: 1px solid transparent;
  transition: all var(--transition);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.aria-idle   { color: var(--text-muted);  border-color: var(--border); }
.aria-active { color: var(--accent-green); border-color: var(--accent-green);
               background: rgba(16,185,129,0.08);
               box-shadow: 0 0 8px rgba(16,185,129,0.2); }
.aria-active .status-dot { animation: pulse-green 1.5s infinite; }

.aria-listening { color: var(--accent-blue); border-color: var(--accent-blue);
                  background: rgba(59,130,246,0.08); }
.aria-listening .status-dot { animation: pulse-blue 1.5s infinite; }

@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.4); }
  50%       { box-shadow: 0 0 0 4px rgba(16,185,129,0); }
}
@keyframes pulse-blue {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59,130,246,0.4); }
  50%       { box-shadow: 0 0 0 4px rgba(59,130,246,0); }
}

/* ─── Incident Meta (center) ─────────────────────────────── */
.incident-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.incident-id {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--accent-cyan);
}

.severity-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.severity-P1 { background: rgba(239,68,68,0.2); color: var(--p1-color); border: 1px solid var(--p1-color); }
.severity-P2 { background: rgba(245,158,11,0.2); color: var(--p2-color); border: 1px solid var(--p2-color); }
.severity-P3 { background: rgba(16,185,129,0.2); color: var(--p3-color); border: 1px solid var(--p3-color); }

.dora-clock {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--accent-amber);
  font-weight: 700;
  padding: 4px 12px;
  border: 1px solid rgba(245,158,11,0.4);
  border-radius: 6px;
  background: rgba(245,158,11,0.08);
  letter-spacing: 0.5px;
}
.dora-clock.urgent {
  color: var(--accent-red);
  border-color: var(--accent-red);
  background: rgba(239,68,68,0.1);
  animation: dora-pulse 1s ease-in-out infinite;
}

@keyframes dora-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.5); opacity: 1; }
  50%       { box-shadow: 0 0 12px 4px rgba(239,68,68,0.3); opacity: 0.85; }
}

/* ─── Persona Badge ──────────────────────────────────────── */
.persona-badge {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  background: rgba(139,92,246,0.15);
  border: 1px solid var(--accent-purple);
  color: var(--accent-purple);
  transition: all var(--transition);
}

/* ─── Barge-In Badge ─────────────────────────────────────── */
.barge-badge {
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: rgba(245,158,11,0.15);
  border: 1px solid var(--accent-amber);
  color: var(--accent-amber);
  animation: barge-pulse 0.5s ease-in-out 4;
}

@keyframes barge-pulse {
  0%, 100% { transform: scale(1);    opacity: 1; }
  50%       { transform: scale(1.05); opacity: 0.8; }
}

/* ─── War Room Layout ────────────────────────────────────── */
.war-room {
  display: grid;
  grid-template-columns: 260px 1fr 380px;
  height: calc(100vh - 52px);
  overflow: hidden;
}

/* ─── Panels ─────────────────────────────────────────────── */
.panel {
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%; /* strict container bound */
  min-height: 0;
}
.panel:last-child { border-right: none; }

.panel-heading {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* ─── Controls Panel ─────────────────────────────────────── */
.panel-controls {
  padding: 0;
  overflow-y: auto;
}

.control-group {
  padding: 10px 16px 0;
}

.control-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.control-input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}
.control-input:focus { border-color: var(--accent-blue); }
.control-textarea { resize: none; }

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: block;
  width: calc(100% - 32px);
  margin: 10px 16px 0;
  padding: 9px 14px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.btn-primary  { background: var(--accent-blue); color: #fff; }
.btn-primary:hover { background: #2563eb; transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-secondary { background: var(--bg-elevated); color: var(--text-primary);
                 border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent-blue); color: var(--accent-blue); }

.btn-danger { background: rgba(239,68,68,0.15); color: var(--accent-red);
              border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }

/* Demo buttons */
.btn-demo {
  background: linear-gradient(135deg, rgba(139,92,246,0.25), rgba(59,130,246,0.2));
  color: var(--accent-purple);
  border: 1px solid rgba(139,92,246,0.4);
}
.btn-demo:hover { background: linear-gradient(135deg, rgba(139,92,246,0.4), rgba(59,130,246,0.3)); transform: translateY(-1px); }

.btn-demo-sm {
  background: rgba(245,158,11,0.12);
  color: var(--accent-amber);
  border: 1px solid rgba(245,158,11,0.35);
  font-size: 12px;
}
.btn-demo-sm:hover { background: rgba(245,158,11,0.22); }

.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border);
             font-size: 12px; padding: 5px 10px; width: auto; margin: 0; }
.btn-ghost:hover { color: var(--text-primary); border-color: var(--border-bright); }

.btn.active { border-color: var(--accent-green); color: var(--accent-green); }

.btn-demo {
  background: linear-gradient(135deg, rgba(139,92,246,0.2), rgba(59,130,246,0.2));
  color: #a78bfa;
  border: 1px solid rgba(139,92,246,0.5);
}
.btn-demo:hover { background: linear-gradient(135deg, rgba(139,92,246,0.35), rgba(59,130,246,0.35)); transform: translateY(-1px); }

.btn-demo-sm {
  background: rgba(139,92,246,0.1);
  color: #a78bfa;
  border: 1px solid rgba(139,92,246,0.3);
  font-size: 12px;
  padding: 6px 12px;
}
.btn-demo-sm:hover { background: rgba(139,92,246,0.2); }

/* ─── Separator ──────────────────────────────────────────── */
.separator {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}

/* ─── Status Grid ────────────────────────────────────────── */
.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 16px;
}

.status-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.status-label {
  display: block;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.status-value {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}
.status-off  { color: var(--text-muted); }
.status-ok   { color: var(--accent-green); }
.status-warn { color: var(--accent-amber); }
.status-err  { color: var(--accent-red); }

/* ─── Audio Meter ────────────────────────────────────────── */
#audio-meter-container { padding: 0 16px; }
.audio-meter {
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.audio-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-green), var(--accent-blue));
  border-radius: 4px;
  transition: width 0.05s linear;
}

/* ─── Transcript Panel ───────────────────────────────────── */
.panel-transcript { flex: 1; }

.transcript-feed {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.transcript-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 8px;
  color: var(--text-secondary);
  text-align: center;
  font-size: 13px;
}

.transcript-entry {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  animation: slide-in 0.3s ease-out;
}
.transcript-entry.aria-entry {
  border-color: rgba(59,130,246,0.3);
  background: rgba(59,130,246,0.05);
}

@keyframes slide-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.entry-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.entry-speaker {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.speaker-ENGINEER   { color: var(--accent-cyan); }
.speaker-COMPLIANCE { color: var(--accent-purple); }
.speaker-EXECUTIVE  { color: var(--accent-amber); }
.speaker-ARIA       { color: var(--accent-blue); }
.speaker-UNKNOWN    { color: var(--text-muted); }

.entry-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  margin-left: auto;
}

.entry-severity {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
}

.entry-text { font-size: 13px; color: var(--text-primary); line-height: 1.5; }
.entry-aria { font-size: 12px; color: var(--text-secondary); font-style: italic; margin-top: 4px; }

.muted { color: var(--text-muted); font-size: 12px; }

/* ─── Report Panel ───────────────────────────────────────── */
.panel-report {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.report-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.report-header .panel-heading { padding: 0; border: none; }

.report-sections {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  flex: 1;
  min-height: 0; /* critical — without this, flex children won't scroll */
}

.section-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 20px;
  color: var(--text-secondary);
  text-align: center;
  font-size: 13px;
}
.section-placeholder-icon { font-size: 32px; margin-bottom: 8px; }

.report-section {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  animation: section-appear 0.4s ease-out;
}

@keyframes section-appear {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.report-section h3 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

.section-content {
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-primary);
  word-break: break-word;
  overflow-wrap: anywhere;
  max-height: 250px;
  overflow-y: auto;
}

/* Markdown-rendered element styles */
.section-content p           { margin-bottom: 8px; }
.section-content p:last-child { margin-bottom: 0; }
.section-content strong      { color: var(--accent-cyan); font-weight: 600; }
.section-content em          { color: var(--text-secondary); font-style: italic; }
.section-content code        { background: var(--bg-card); padding: 1px 6px;
                               border-radius: 3px; font-family: var(--font-mono);
                               font-size: 11.5px; color: var(--accent-amber); }
.section-content ul          { padding-left: 18px; margin: 6px 0; }
.section-content li          { margin-bottom: 5px; color: var(--text-primary); }

.regulatory-section { border-color: rgba(239,68,68,0.3); }
.regulatory-section h3 { color: var(--accent-red); background: rgba(239,68,68,0.06); }

.summary-section { border-color: rgba(59,130,246,0.3); }
.summary-section h3 { color: var(--accent-blue); background: rgba(59,130,246,0.06); }

/* ─── Confidence Indicator ───────────────────────────────── */
.confidence-bar {
  height: 2px;
  background: var(--border);
  margin-top: 8px;
  border-radius: 1px;
  overflow: hidden;
}
.confidence-fill {
  height: 100%;
  background: var(--accent-green);
  transition: width var(--transition);
}

/* ─── Scrollbars ─────────────────────────────────────────── */
::-webkit-scrollbar       { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Utilities ──────────────────────────────────────────── */
.hidden { display: none !important; }
