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

:root {
  --bg-base:        #0f1115;
  --bg-panel:       #181a20;
  --bg-panel-alt:   #1d2028;
  --border:         #2a2d35;
  --border-bright:  #3a3f4e;
  --text-primary:   #e8eaf0;
  --text-secondary: #9ba3b2;
  --text-muted:     #565d6e;
  --accent-amber:   #f59e0b;
  --accent-amber-dim:#7a4d05;
  --accent-emerald: #10b981;
  --accent-emerald-dim:#054d30;
  --accent-red:     #ef4444;
  --accent-blue:    #3b82f6;
  --glow-amber:     0 0 12px rgba(245, 158, 11, 0.55);
  --glow-emerald:   0 0 12px rgba(16, 185, 129, 0.55);
  --font-mono:      'JetBrains Mono', 'Fira Mono', 'Courier New', monospace;
  --font-ui:        'Inter', 'Segoe UI', system-ui, sans-serif;
  --radius-sm:      4px;
  --radius-md:      8px;
  --radius-lg:      12px;
}

html {
  min-height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.5;
  overflow-x: hidden;
  overflow-y: auto;
}

body {
  min-height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.5;
}

/* ─── App Shell ─────────────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  grid-template-columns: 1fr 320px;
  grid-template-areas:
    "header  header"
    "meta    meta"
    "stage   sidebar"
    "controls controls";
  height: 100vh;
  gap: 0;
}

/* ─── Header ────────────────────────────────────────────────────────── */
.app-header {
  grid-area: header;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-logo {
  width: 30px;
  height: 30px;
}

.brand-name {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent-amber);
  text-transform: uppercase;
}

.brand-tagline {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 1px;
}

.take-identifier {
  text-align: center;
  flex: 1;
}

.take-label {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 600;
}

.take-scene {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.telemetry-banner {
  flex-shrink: 0;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  text-align: right;
}

.telemetry-label {
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.telemetry-value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-amber);
  margin-top: 2px;
}

/* ─── Meta Bar ──────────────────────────────────────────────────────── */
.meta-bar {
  grid-area: meta;
  background: var(--bg-panel-alt);
  border-bottom: 1px solid var(--border);
  padding: 6px 20px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.meta-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}

.meta-chip .label {
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10px;
}

.meta-chip .value {
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.meta-chip .value.live {
  color: var(--accent-emerald);
}

.meta-sep {
  width: 1px;
  height: 14px;
  background: var(--border);
}

.toggle-group {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 4px 10px;
  font-size: 11px;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: all 0.15s ease;
  letter-spacing: 0.03em;
}

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

.toggle-btn.active {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.4);
  color: var(--accent-amber);
}

.toggle-btn .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ─── Stage ─────────────────────────────────────────────────────────── */
.video-stage {
  grid-area: stage;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  background: var(--border);
  overflow: hidden;
  position: relative;
}

.video-well {
  position: relative;
  background: #000;
  overflow: hidden;
}

.video-well-label {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 10;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.06em;
  pointer-events: none;
}

.video-well video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Overlay canvas sits on top of the right (current) video well */
.overlay-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* Inactive placeholder when no video loaded */
.video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 12px;
}

.video-placeholder.hidden {
  display: none !important;
}

.video-placeholder svg {
  opacity: 0.3;
}

.pair-select {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  outline: none;
  cursor: pointer;
  max-width: 320px;
}

.pair-select:focus {
  border-color: var(--accent-amber);
}

/* ─── Playback Controls ──────────────────────────────────────────────── */
.playback-controls {
  grid-area: controls;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-icon:hover {
  border-color: var(--border-bright);
  color: var(--text-primary);
  background: var(--bg-panel-alt);
}

.btn-icon.btn-play-pause {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
  color: var(--accent-amber);
}

.btn-icon.btn-play-pause:hover {
  background: rgba(245, 158, 11, 0.22);
  border-color: rgba(245, 158, 11, 0.6);
  box-shadow: var(--glow-amber);
}

.btn-icon.btn-play-pause.playing {
  background: rgba(245, 158, 11, 0.18);
  border-color: var(--accent-amber);
  box-shadow: var(--glow-amber);
  color: var(--accent-amber);
}

.scrub-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.scrub-bar {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  cursor: pointer;
  outline: none;
}

.scrub-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-amber);
  cursor: pointer;
  box-shadow: var(--glow-amber);
  border: 2px solid var(--bg-base);
}

.scrub-bar::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-amber);
  cursor: pointer;
  box-shadow: var(--glow-amber);
  border: 2px solid var(--bg-base);
}

.scrub-bar:hover {
  height: 6px;
}

.scrub-incident-markers {
  position: relative;
  height: 3px;
  width: 100%;
}

.incident-marker {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: var(--accent-amber);
  border-radius: 1px;
  transform: translateX(-50%);
  opacity: 0.7;
}

.incident-marker.severity-critical { background: var(--accent-red); opacity: 1; }
.incident-marker.severity-high     { background: var(--accent-amber); }
.incident-marker.severity-medium   { background: #f97316; }
.incident-marker.severity-low      { background: var(--text-muted); }

.timecode-display {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--text-primary);
  letter-spacing: 0.1em;
  background: var(--bg-panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  min-width: 130px;
  text-align: center;
  flex-shrink: 0;
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: var(--glow-emerald);
}

/* ─── Sidebar ────────────────────────────────────────────────────────── */
.sidebar {
  grid-area: sidebar;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.incident-count {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-amber);
  padding: 1px 8px;
}

.sidebar-filter {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.filter-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 0;
  font-size: 11px;
  font-family: var(--font-ui);
  color: var(--text-muted);
  cursor: pointer;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: all 0.15s ease;
}

.filter-tab:hover {
  color: var(--text-secondary);
}

.filter-tab.active {
  color: var(--accent-amber);
  border-bottom-color: var(--accent-amber);
}

.filter-tab.active.emerald {
  color: var(--accent-emerald);
  border-bottom-color: var(--accent-emerald);
}

.incident-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.incident-list::-webkit-scrollbar { width: 4px; }
.incident-list::-webkit-scrollbar-track { background: transparent; }
.incident-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.incident-list::-webkit-scrollbar-thumb:hover { background: var(--border-bright); }

/* ─── Incident Card ──────────────────────────────────────────────────── */
.incident-card {
  background: var(--bg-panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.incident-card:hover {
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.04);
}

.incident-card.active {
  border-color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.08);
  box-shadow: inset 3px 0 0 var(--accent-amber);
}

.incident-card.pass-card:hover {
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.04);
}

.incident-card.pass-card.active {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.08);
  box-shadow: inset 3px 0 0 var(--accent-emerald);
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.card-timecode {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
  letter-spacing: 0.06em;
}

.category-badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid transparent;
  flex-shrink: 0;
}

.cat-prop-state     { background: rgba(245, 158, 11, 0.15); border-color: rgba(245, 158, 11, 0.35); color: var(--accent-amber); }
.cat-wardrobe       { background: rgba(239, 68, 68, 0.12);  border-color: rgba(239, 68, 68, 0.35);  color: #f87171; }
.cat-blocking       { background: rgba(139, 92, 246, 0.12); border-color: rgba(139, 92, 246, 0.35); color: #a78bfa; }
.cat-prop-position  { background: rgba(59, 130, 246, 0.12); border-color: rgba(59, 130, 246, 0.35); color: #60a5fa; }
.cat-set-dressing   { background: rgba(20, 184, 166, 0.12); border-color: rgba(20, 184, 166, 0.35); color: #2dd4bf; }

.confidence-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.confidence-bar-wrap {
  flex: 1;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.confidence-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent-amber);
  transition: width 0.3s ease;
}

.confidence-bar-fill.high   { background: var(--accent-emerald); }
.confidence-bar-fill.medium { background: var(--accent-amber); }
.confidence-bar-fill.low    { background: var(--text-muted); }

.confidence-pct {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
  flex-shrink: 0;
  min-width: 30px;
  text-align: right;
}

.card-summary {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.card-severity-dot {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.sev-critical { background: var(--accent-red); box-shadow: 0 0 6px rgba(239,68,68,0.7); }
.sev-high     { background: var(--accent-amber); box-shadow: 0 0 6px rgba(245,158,11,0.6); }
.sev-medium   { background: #f97316; }
.sev-low      { background: var(--text-muted); }

/* ─── Pass card ─────────────────────────────────────────────────────── */
.pass-badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 10px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--accent-emerald);
}

/* ─── Animations ─────────────────────────────────────────────────────── */
@keyframes pulse-box {
  0%   { opacity: 1;   filter: drop-shadow(0 0 8px rgba(245,158,11,0.9)); }
  50%  { opacity: 0.6; filter: drop-shadow(0 0 20px rgba(245,158,11,0.4)); }
  100% { opacity: 1;   filter: drop-shadow(0 0 8px rgba(245,158,11,0.9)); }
}

.canvas-pulse { animation: pulse-box 0.8s ease-in-out 4; }

@keyframes card-flash {
  0%   { background: rgba(245,158,11,0.22); }
  100% { background: rgba(245,158,11,0.08); }
}

.incident-card.flash {
  animation: card-flash 0.4s ease-out;
}

/* ─── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr 300px;
  }
  .telemetry-banner { display: none; }
}

@media (max-width: 900px) {
  html, body {
    overflow-y: auto;
  }
  .app-shell {
    display: flex;
    flex-direction: column;
    height: auto;
    max-height: none;
    min-height: 100vh;
    overflow-y: visible;
    overflow-x: hidden;
    width: 100%;
  }
  .app-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 12px 14px;
    width: 100%;
  }
  .brand {
    width: 100%;
    justify-content: space-between;
  }
  .take-identifier {
    width: 100%;
    min-width: 0;
    text-align: left;
  }
  .pair-select {
    width: 100%;
    max-width: 100%;
    font-size: 11px;
  }
  .header-actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
  }
  .meta-bar {
    flex-wrap: wrap;
    gap: 8px 14px;
    padding: 8px 14px;
    width: 100%;
  }
  .meta-sep {
    display: none;
  }
  .toggle-group {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
    gap: 8px;
  }
  .video-stage {
    display: flex;
    flex-direction: column;
    aspect-ratio: auto;
    height: auto;
    gap: 6px;
    background: var(--bg-base);
    width: 100%;
  }
  .video-well {
    aspect-ratio: 16 / 9;
    width: 100%;
    height: auto;
    min-height: 200px;
  }
  .playback-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    width: 100%;
  }
  .scrub-wrap {
    order: 10;
    width: 100%;
    flex: 1 1 100%;
    margin: 6px 0 0 0;
  }
  .sidebar {
    width: 100%;
    height: auto;
    max-height: none;
    border-left: none;
    border-top: 1px solid var(--border);
    overflow-y: visible;
  }
  .incident-list {
    max-height: 400px;
    overflow-y: auto;
  }
}

@media (max-width: 600px) {
  .app-header {
    padding: 10px 12px;
  }
  .nav-link {
    font-size: 10px;
    padding: 4px 8px;
  }
  .meta-chip {
    font-size: 10px;
  }
  .playback-controls {
    justify-content: flex-start;
  }
  .timecode-display {
    font-size: 11px;
  }
}
