/**
 * TrainersEye V5 — Desktop Layout Stylesheet
 * App shell, topbar, camera stage, HUD, side panel, overlays, modals
 * Desktop-first layout with responsive enhancements
 * Version: 5.0.0
 */

/* ============================================
   1. APP SHELL
   ============================================ */

.app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: var(--bg-primary);
  overflow: hidden;
  position: relative;
}

/* ============================================
   2. TOPBAR
   ============================================ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  padding: 0 var(--space-4);
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: var(--header-blur);
  -webkit-backdrop-filter: var(--header-blur);
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
  z-index: var(--z-header);
  flex-shrink: 0;
  gap: var(--space-4);
}

/* --- Logo Group --- */
.topbar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.logo-text {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
  line-height: var(--leading-none);
}

.logo-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  font-size: var(--text-3xs);
  font-weight: var(--font-bold);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  background: var(--accent);
  color: var(--text-inverse);
  border-radius: var(--radius-sm);
  line-height: 1;
}

/* --- Topbar Mode Selector --- */
.topbar-mode-selector {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 2px;
  flex-shrink: 0;
}

.topbar-mode-btn {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-2xs);
  font-weight: var(--font-semibold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--text-tertiary);
  border-radius: calc(var(--radius-md) - 2px);
  border: none;
  background: transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
  min-height: 28px;
}

.topbar-mode-btn:hover {
  color: var(--text-secondary);
  background: var(--surface-raised);
}

.topbar-mode-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-mid);
}

.topbar-mode-btn .mode-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
  opacity: 0.5;
  transition: opacity var(--transition-fast);
}

.topbar-mode-btn.active .mode-dot {
  opacity: 1;
}

/* --- Topbar Voice Toggle --- */
.topbar-voice {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.voice-label {
  font-size: var(--text-2xs);
  font-weight: var(--font-medium);
  color: var(--text-tertiary);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
}

.voice-toggle-group {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 2px;
}

.voice-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-2xs);
  font-weight: var(--font-semibold);
  color: var(--text-tertiary);
  border-radius: calc(var(--radius-md) - 2px);
  border: none;
  background: transparent;
  transition: all var(--transition-fast);
  min-height: 28px;
  gap: var(--space-1);
}

.voice-toggle-btn:hover {
  color: var(--text-secondary);
}

.voice-toggle-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
}

/* --- Camera Status --- */
.camera-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.camera-status-label {
  font-size: var(--text-2xs);
  font-weight: var(--font-medium);
  color: var(--text-tertiary);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
}

/* ============================================
   3. MAIN LAYOUT (Camera + Side Panel)
   ============================================ */

.main-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* --- Camera Panel --- */
.camera-panel {
  flex: 1 1 60%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background: #000000;
  overflow: hidden;
}

/* --- Side Panel --- */
.side-panel {
  flex: 0 0 380px;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  border-left: 1px solid var(--border-subtle);
  overflow: hidden;
}

.side-panel-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* ============================================
   4. CAMERA STAGE
   ============================================ */

.camera-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000000;
  overflow: hidden;
}

.camera-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: var(--z-elevated);
}

/* Camera placeholder / offline state */
.camera-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  color: var(--text-tertiary);
  text-align: center;
  padding: var(--space-8);
}

.camera-placeholder-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-2xl);
  color: var(--text-tertiary);
  border: 1px solid var(--border-subtle);
}

.camera-placeholder-text {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  max-width: 240px;
}

/* Grid overlay (subtle alignment grid) */
.camera-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: calc(var(--z-elevated) + 1);
  opacity: 0.06;
  background-image: linear-gradient(var(--border-strong) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-strong) 1px, transparent 1px);
  background-size: 33.33% 33.33%;
}

/* Scanline effect */
.camera-scanline {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: calc(var(--z-elevated) + 2);
  overflow: hidden;
}

.camera-scanline::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--accent) 50%,
    transparent 100%
  );
  opacity: 0.3;
  animation: scanline 3s linear infinite;
}

/* Corner brackets (motion capture aesthetic) */
.camera-brackets {
  position: absolute;
  inset: var(--space-4);
  pointer-events: none;
  z-index: calc(var(--z-elevated) + 3);
}

.camera-brackets::before,
.camera-brackets::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: var(--accent);
  border-style: solid;
  opacity: 0.4;
}

.camera-brackets::before {
  top: 0;
  left: 0;
  border-width: 2px 0 0 2px;
}

.camera-brackets::after {
  top: 0;
  right: 0;
  border-width: 2px 2px 0 0;
}

.camera-brackets-bottom::before,
.camera-brackets-bottom::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: var(--accent);
  border-style: solid;
  opacity: 0.4;
}

.camera-brackets-bottom::before {
  bottom: 0;
  left: 0;
  border-width: 0 0 2px 2px;
}

.camera-brackets-bottom::after {
  bottom: 0;
  right: 0;
  border-width: 0 2px 2px 0;
}

/* ============================================
   5. HUD OVERLAY
   ============================================ */

.hud-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: calc(var(--z-elevated) + 4);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hud-overlay > * {
  pointer-events: auto;
}

/* --- HUD Top Row --- */
.hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}

/* --- HUD Top Left: Exercise + Score --- */
.hud-top-left {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: flex-start;
}

.hud-exercise-name {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: #ffffff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  line-height: var(--leading-tight);
}

.hud-exercise-sub {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: rgba(255, 255, 255, 0.7);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* Score badge on camera */
.hud-score-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
}

.hud-score-value {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--accent);
  line-height: var(--leading-none);
}

.hud-score-label {
  font-size: var(--text-2xs);
  font-weight: var(--font-semibold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

/* --- HUD Top Right: Mode + Voice --- */
.hud-top-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
}

.hud-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-2xs);
  font-weight: var(--font-bold);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-mid);
  border-radius: var(--radius-full);
  backdrop-filter: blur(8px);
}

.hud-voice-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-2xs);
  font-weight: var(--font-medium);
  color: rgba(255, 255, 255, 0.6);
  background: rgba(0, 0, 0, 0.4);
  border-radius: var(--radius-full);
  backdrop-filter: blur(8px);
}

.hud-voice-indicator.active {
  color: var(--accent);
}

.hud-voice-indicator.active .voice-wave {
  animation: pulse 1.5s ease-in-out infinite;
}

/* --- HUD Bottom: Live Cue Bar --- */
.hud-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
}

.hud-cue-bar {
  width: 100%;
  padding: var(--space-3) var(--space-5);
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  text-align: center;
  transition: all var(--transition-base);
}

.hud-cue-bar.has-cue {
  border-color: var(--accent-mid);
  box-shadow: 0 0 20px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  animation: cueFlash 0.5s ease;
}

.hud-cue-text {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: #ffffff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  line-height: var(--leading-snug);
}

.hud-cue-sub {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

/* --- HUD Angle Readout --- */
.hud-angle-readout {
  position: absolute;
  bottom: var(--space-4);
  left: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  pointer-events: none;
}

.hud-angle-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  color: rgba(255, 255, 255, 0.5);
}

.hud-angle-label {
  min-width: 60px;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
}

.hud-angle-value {
  font-weight: var(--font-bold);
  color: rgba(255, 255, 255, 0.7);
}

.hud-angle-value.good {
  color: var(--good);
}
.hud-angle-value.warn {
  color: var(--warn);
}
.hud-angle-value.bad {
  color: var(--bad);
}

/* ============================================
   6. SIDE PANEL SECTIONS
   ============================================ */

/* --- Section Header --- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.section-title {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.section-action {
  font-size: var(--text-2xs);
  font-weight: var(--font-semibold);
  color: var(--accent);
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.section-action:hover {
  opacity: 0.8;
}

/* --- Mode Cards --- */
.mode-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}

.mode-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-2);
  background: var(--surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  text-align: center;
}

.mode-card:hover {
  border-color: var(--border-default);
  background: var(--surface-raised);
}

.mode-card.active {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.mode-card-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  font-size: var(--text-lg);
  transition: all var(--transition-base);
}

.mode-card.active .mode-card-icon {
  background: var(--accent-mid);
  color: var(--accent);
}

.mode-card-label {
  font-size: var(--text-2xs);
  font-weight: var(--font-semibold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--text-tertiary);
  transition: color var(--transition-base);
}

.mode-card.active .mode-card-label {
  color: var(--accent);
}

.mode-card-desc {
  font-size: var(--text-3xs);
  font-weight: var(--font-regular);
  color: var(--text-tertiary);
  line-height: var(--leading-normal);
  display: none;
}

/* --- Exercise Selector --- */
.exercise-selector {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.exercise-select-row {
  display: flex;
  gap: var(--space-2);
}

.exercise-select-row .select {
  flex: 1;
}

/* --- Voice Selector (Side Panel) --- */
.voice-selector {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.voice-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.voice-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  min-height: 44px;
}

.voice-option:hover {
  border-color: var(--border-default);
  background: var(--surface-raised);
}

.voice-option.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

/* --- Stats Grid --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-2);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  text-align: center;
  min-height: 72px;
  justify-content: center;
  transition: all var(--transition-fast);
}

.stat-card:hover {
  border-color: var(--border-default);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  line-height: var(--leading-none);
  color: var(--text-primary);
  transition: color var(--transition-base);
}

.stat-label {
  font-size: var(--text-3xs);
  font-weight: var(--font-semibold);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.stat-card.highlight .stat-value {
  color: var(--accent);
}

.stat-card.good .stat-value {
  color: var(--good);
}

.stat-card.warn .stat-value {
  color: var(--warn);
}

.stat-card.bad .stat-value {
  color: var(--bad);
}

/* --- Control Buttons Row --- */
.controls-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
}

.controls-row .btn {
  width: 100%;
}

/* --- Camera Controls --- */
.camera-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.camera-controls .btn {
  flex: 1;
}

/* --- Calibration Card --- */
.calibration-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.calibration-status {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.calibration-status-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--accent-dim);
  color: var(--accent);
  font-size: var(--text-lg);
  flex-shrink: 0;
}

.calibration-status-icon.calibrated {
  background: var(--good-dim);
  color: var(--good);
}

.calibration-status-text {
  flex: 1;
  min-width: 0;
}

.calibration-status-title {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.calibration-status-desc {
  font-size: var(--text-xs);
  font-weight: var(--font-regular);
  color: var(--text-tertiary);
  margin-top: 2px;
}

.calibration-bar {
  height: 4px;
  background: var(--surface-raised);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.calibration-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.calibration-bar-fill.complete {
  background: var(--good);
}

/* --- Live Feedback List --- */
.feedback-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  max-height: 200px;
  overflow-y: auto;
}

.feedback-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  animation: fadeInUp 250ms ease forwards;
  min-height: 36px;
}

.feedback-item-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  font-size: var(--text-xs);
}

.feedback-item-icon.good {
  background: var(--good-dim);
  color: var(--good);
}

.feedback-item-icon.warn {
  background: var(--warn-dim);
  color: var(--warn);
}

.feedback-item-icon.bad {
  background: var(--bad-dim);
  color: var(--bad);
}

.feedback-item-icon.info {
  background: var(--info-dim);
  color: var(--info);
}

.feedback-item-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feedback-item-time {
  font-family: var(--font-mono);
  font-size: var(--text-3xs);
  color: var(--text-tertiary);
  flex-shrink: 0;
}

/* --- Session Log --- */
.session-log {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  max-height: 160px;
  overflow-y: auto;
}

.log-entry {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-2xs);
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  border-left: 2px solid transparent;
  transition: background var(--transition-fast);
}

.log-entry:hover {
  background: var(--surface);
}

.log-entry-time {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.log-entry-message {
  flex: 1;
  min-width: 0;
}

.log-entry.good {
  border-left-color: var(--good);
}
.log-entry.warn {
  border-left-color: var(--warn);
}
.log-entry.bad {
  border-left-color: var(--bad);
}
.log-entry.info {
  border-left-color: var(--info);
}

/* ============================================
   7. OVERLAY SCREENS
   ============================================ */

.overlay-screen {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn 300ms ease forwards;
}

.overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-6);
  padding: var(--space-8);
  max-width: 400px;
  width: 90%;
}

.overlay-icon {
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xl);
  background: var(--surface);
  border: 1px solid var(--border-default);
  font-size: var(--text-3xl);
  color: var(--accent);
}

.overlay-icon.success {
  color: var(--good);
}

.overlay-icon.error {
  color: var(--bad);
}

.overlay-icon.warning {
  color: var(--warn);
}

.overlay-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  line-height: var(--leading-tight);
}

.overlay-subtitle {
  font-size: var(--text-sm);
  font-weight: var(--font-regular);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

.overlay-actions {
  display: flex;
  gap: var(--space-3);
  width: 100%;
}

.overlay-actions .btn {
  flex: 1;
}

/* --- Start Screen --- */
.start-screen {
  background: var(--bg-primary);
}

.start-screen .overlay-content {
  max-width: 480px;
}

.start-screen-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.start-screen-logo-icon {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-xl);
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-3xl);
  color: var(--accent);
  border: 2px solid var(--accent-mid);
  box-shadow: 0 0 30px var(--accent-glow);
}

.start-screen-logo-text {
  font-size: var(--text-3xl);
  font-weight: var(--font-black);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}

.start-screen-logo-badge {
  font-size: var(--text-2xs);
  font-weight: var(--font-bold);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--accent);
  padding: var(--space-1) var(--space-3);
  background: var(--accent-dim);
  border: 1px solid var(--accent-mid);
  border-radius: var(--radius-full);
}

.start-screen-features {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
  text-align: left;
}

.start-feature {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.start-feature-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--accent-dim);
  color: var(--accent);
  font-size: var(--text-lg);
  flex-shrink: 0;
}

.start-feature-text {
  flex: 1;
}

.start-feature-title {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.start-feature-desc {
  font-size: var(--text-xs);
  font-weight: var(--font-regular);
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* --- Loading Screen --- */
.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--surface-highlight);
  border-top-color: var(--accent);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

.loading-text {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
}

.loading-progress {
  width: 100%;
  max-width: 240px;
  height: 3px;
  background: var(--surface-raised);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.loading-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

/* --- Error Screen --- */
.error-screen .overlay-icon {
  color: var(--bad);
  background: var(--bad-dim);
  border-color: var(--bad-glow);
}

.error-details {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  color: var(--text-tertiary);
  background: var(--surface);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  max-width: 100%;
  overflow-x: auto;
  text-align: left;
}

/* ============================================
   8. MODAL / DIALOG STYLES
   ============================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 200ms ease forwards;
  padding: var(--space-4);
}

.modal {
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: fadeInScale 250ms ease forwards;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-size: var(--text-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--surface);
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-5);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

/* --- Bottom Sheet (Modal variant) --- */
.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-modal);
  display: flex;
  flex-direction: column;
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  border-bottom: none;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
  max-height: 80vh;
  animation: slideInUp 350ms ease forwards;
}

.bottom-sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border-strong);
  border-radius: var(--radius-full);
  margin: var(--space-3) auto;
  flex-shrink: 0;
}

.bottom-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5) var(--space-4);
  flex-shrink: 0;
}

.bottom-sheet-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.bottom-sheet-body {
  padding: 0 var(--space-5) var(--space-5);
  overflow-y: auto;
  flex: 1;
}

.bottom-sheet-footer {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.bottom-sheet-footer .btn {
  flex: 1;
}

/* ============================================
   9. TOAST NOTIFICATIONS
   ============================================ */

.toast-container {
  position: fixed;
  top: calc(var(--topbar-height) + var(--space-3));
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: slideInRight 300ms ease forwards;
  max-width: 360px;
  min-height: 44px;
}

.toast-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  font-size: var(--text-sm);
}

.toast-icon.success {
  background: var(--good-dim);
  color: var(--good);
}

.toast-icon.error {
  background: var(--bad-dim);
  color: var(--bad);
}

.toast-icon.warning {
  background: var(--warn-dim);
  color: var(--warn);
}

.toast-icon.info {
  background: var(--info-dim);
  color: var(--info);
}

.toast-message {
  flex: 1;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  line-height: var(--leading-snug);
}

.toast-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  cursor: pointer;
  flex-shrink: 0;
}

.toast-close:hover {
  color: var(--text-primary);
}

/* ============================================
   10. RESPONSIVE BREAKPOINTS (Desktop)
   ============================================ */

/* Large desktop: wider side panel */
@media (min-width: 1400px) {
  .side-panel {
    flex: 0 0 420px;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Hide topbar mode selector on smaller desktop (mobile handles it) */
@media (max-width: 1023px) {
  .topbar-mode-selector {
    display: none;
  }

  .topbar-voice {
    display: none;
  }
}

/* Compact desktop: narrower side panel */
@media (min-width: 1024px) and (max-width: 1199px) {
  .side-panel {
    flex: 0 0 340px;
  }
}

/* ============================================
   11. REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  .hud-cue-bar.has-cue {
    animation: none;
  }

  .camera-scanline::after {
    animation: none;
    display: none;
  }

  .loading-spinner {
    animation: none;
    border: 3px solid var(--accent);
  }
}
