/* ==========================================================================
   PostureGuard AI - Modern Ergonomic Dashboard & Alert Design System
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(31, 41, 55, 0.85);
  --bg-card-border: rgba(255, 255, 255, 0.08);
  --bg-card-border-glow: rgba(56, 189, 248, 0.2);

  /* Status Colors */
  --color-good: #10b981;
  --color-good-glow: rgba(16, 185, 129, 0.35);
  --color-good-bg: rgba(16, 185, 129, 0.12);

  --color-bad: #ef4444;
  --color-bad-glow: rgba(239, 68, 68, 0.45);
  --color-bad-bg: rgba(239, 68, 68, 0.15);

  --color-warning: #f59e0b;
  --color-warning-glow: rgba(245, 158, 11, 0.35);
  --color-warning-bg: rgba(245, 158, 11, 0.12);

  --color-primary: #3b82f6;
  --color-primary-glow: rgba(59, 130, 246, 0.35);
  --color-cyan: #06b6d4;
  --color-purple: #8b5cf6;

  /* Typography */
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  /* Geometry & Shadows */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
  --shadow-glow-bad: 0 0 40px rgba(239, 68, 68, 0.6);
  --shadow-glow-good: 0 0 30px rgba(16, 185, 129, 0.4);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Background Ambient Orbs */
.bg-glow-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
  transition: opacity var(--transition-slow);
}

.orb-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.4) 0%, rgba(139, 92, 246, 0.1) 70%);
  top: -150px;
  left: -150px;
}

.orb-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.25) 0%, rgba(6, 182, 212, 0.05) 70%);
  bottom: -200px;
  right: -150px;
}

.orb-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(239, 68, 68, 0.2) 0%, transparent 70%);
  top: 40%;
  left: 35%;
}

/* App Wrapper */
.app-wrapper {
  position: relative;
  z-index: 1;
  max-width: 1480px;
  margin: 0 auto;
  padding: 1.5rem 2rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Protocol Warning Banner */
.protocol-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.25), rgba(245, 158, 11, 0.2));
  border: 1px solid rgba(239, 68, 68, 0.5);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.25rem;
  color: #fecaca;
  font-size: 0.85rem;
  animation: fadeIn 0.3s ease;
}

.protocol-banner.hidden {
  display: none !important;
}

.protocol-banner svg {
  width: 20px;
  height: 20px;
  color: #ef4444;
  flex-shrink: 0;
}

.protocol-banner .banner-text {
  flex: 1;
}

.protocol-banner code {
  background: rgba(0, 0, 0, 0.35);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  color: #facc15;
}

.cam-select {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-family: inherit;
  outline: none;
  max-width: 180px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 20px var(--color-primary-glow);
}

.brand-text h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.brand-text h1 span {
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text .subtitle {
  font-size: 0.825rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Layout Grid */
.main-layout {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 1080px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

/* Common Card Styles */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-main);
}

.card-title svg {
  color: var(--color-cyan);
  width: 18px;
  height: 18px;
}

.card-title h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-normal);
  text-decoration: none;
  white-space: nowrap;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  box-shadow: 0 4px 14px var(--color-primary-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  box-shadow: 0 4px 14px var(--color-good-glow);
}

.btn-success:hover {
  background: linear-gradient(135deg, #047857, #059669);
  box-shadow: 0 6px 22px rgba(16, 185, 129, 0.55);
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  color: #fff;
  box-shadow: 0 4px 14px var(--color-bad-glow);
}

.btn-danger:hover {
  background: linear-gradient(135deg, #b91c1c, #dc2626);
  box-shadow: 0 6px 22px rgba(239, 68, 68, 0.55);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
}

.btn-icon {
  padding: 0.6rem;
  border-radius: var(--radius-md);
}

.btn-outline {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-muted);
}

.btn-outline:hover, .btn-outline.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--color-primary);
  color: #fff;
}

.btn-lg {
  padding: 0.8rem 1.75rem;
  font-size: 1rem;
  border-radius: var(--radius-md);
}

.btn-xs {
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-xs svg {
  width: 12px;
  height: 12px;
}

.btn-xs:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

/* ==========================================================================
   Model Config Tabs & Form
   ========================================================================== */

.config-card {
  margin-bottom: 1.25rem;
}

.config-tabs {
  display: flex;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.35rem;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.825rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-normal);
}

.tab-btn svg {
  width: 15px;
  height: 15px;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  background: var(--bg-card-hover);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.tab-pane {
  display: none;
  animation: fadeIn 0.2s ease-out;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.input-group {
  display: flex;
  align-items: center;
  position: relative;
  gap: 0.5rem;
}

.input-icon {
  position: absolute;
  left: 1rem;
  color: var(--text-dim);
  pointer-events: none;
  display: flex;
  align-items: center;
}

.input-icon svg {
  width: 18px;
  height: 18px;
}

.input-group input[type="text"] {
  flex: 1;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 0.65rem 1rem 0.65rem 2.75rem;
  color: #fff;
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-group input[type="text"]:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.input-hint {
  font-size: 0.775rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.local-folder-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.local-folder-info .info-icon svg {
  color: var(--color-cyan);
  width: 22px;
  height: 22px;
}

.local-folder-info .info-text {
  flex: 1;
  font-size: 0.825rem;
  color: var(--text-muted);
}

.local-folder-info code {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  color: #38bdf8;
  font-family: monospace;
}

.file-inputs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr) auto;
  gap: 0.75rem;
  align-items: end;
}

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

.file-input-box {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.file-input-box label {
  font-size: 0.775rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.file-input-box label svg {
  width: 14px;
  height: 14px;
}

.file-input-box input[type="file"] {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  width: 100%;
}

.model-meta-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.825rem;
}

.model-type-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.model-type-badge label {
  color: var(--text-muted);
}

.model-type-badge select {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-family: inherit;
  outline: none;
}

.model-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.model-status .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
}

.model-status.ready {
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
}
.model-status.ready .status-dot { background: #60a5fa; }

.model-status.loaded {
  background: var(--color-good-bg);
  color: var(--color-good);
}
.model-status.loaded .status-dot { background: var(--color-good); box-shadow: 0 0 8px var(--color-good); }

.model-status.loading {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}
.model-status.loading .status-dot { 
  background: var(--color-warning); 
  animation: pulseDot 1s infinite alternate;
}

.model-status.error {
  background: var(--color-bad-bg);
  color: var(--color-bad);
}
.model-status.error .status-dot { background: var(--color-bad); }

@keyframes pulseDot {
  from { transform: scale(0.8); opacity: 0.5; }
  to { transform: scale(1.3); opacity: 1; }
}

/* ==========================================================================
   Camera Viewport & Posture Status
   ========================================================================== */

.viewport-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow: hidden;
  position: relative;
}

/* Camera Mode Tabs (Video Live vs Foto Capture) */
.camera-mode-tabs {
  display: flex;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.35);
  padding: 0.35rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.cam-mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-normal);
}

.cam-mode-btn svg {
  width: 16px;
  height: 16px;
}

.cam-mode-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.cam-mode-btn.active {
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
  color: #fff;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.4);
}

.placeholder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  margin-top: 1.25rem;
  z-index: 5;
}

/* Posture Status Badge (Top of Camera) */
.posture-badge {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all var(--transition-normal);
}

.posture-badge .badge-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: all var(--transition-normal);
}

.posture-badge .badge-icon svg {
  width: 22px;
  height: 22px;
}

.posture-badge .badge-content {
  display: flex;
  flex-direction: column;
}

.posture-badge .badge-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.posture-badge .badge-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Badge States */
.posture-badge.idle {
  border-color: rgba(255, 255, 255, 0.1);
}
.posture-badge.idle .badge-icon {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}
.posture-badge.idle .badge-title {
  color: var(--text-muted);
}

.posture-badge.good {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.2), rgba(16, 185, 129, 0.05));
  border-color: var(--color-good);
  box-shadow: 0 0 25px var(--color-good-glow);
}
.posture-badge.good .badge-icon {
  background: var(--color-good);
  color: #fff;
  box-shadow: 0 0 15px var(--color-good-glow);
}
.posture-badge.good .badge-title {
  color: #34d399;
}

.posture-badge.slouch {
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.3), rgba(239, 68, 68, 0.1));
  border-color: var(--color-bad);
  box-shadow: 0 0 35px var(--color-bad-glow);
  animation: badgeAlertPulse 1s infinite alternate;
}
.posture-badge.slouch .badge-icon {
  background: var(--color-bad);
  color: #fff;
  box-shadow: 0 0 20px var(--color-bad-glow);
}
.posture-badge.slouch .badge-title {
  color: #f87171;
}

@keyframes badgeAlertPulse {
  0% { transform: scale(1); border-color: #ef4444; }
  100% { transform: scale(1.01); border-color: #ff8888; box-shadow: 0 0 45px rgba(239, 68, 68, 0.7); }
}

/* Camera Container & Canvas */
.camera-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255, 255, 255, 0.1);
  transition: border-color var(--transition-normal);
}

.camera-container.status-good {
  border-color: rgba(16, 185, 129, 0.5);
}

.camera-container.status-slouch {
  border-color: rgba(239, 68, 68, 0.9);
  box-shadow: inset 0 0 30px rgba(239, 68, 68, 0.4);
}

#camera-canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.camera-container.flipped #camera-canvas {
  transform: scaleX(-1);
}

/* Placeholder */
.camera-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  background: radial-gradient(circle, rgba(30, 41, 59, 0.8) 0%, rgba(10, 14, 23, 0.95) 100%);
  color: var(--text-muted);
  z-index: 2;
}

.camera-placeholder.hidden {
  display: none;
}

.placeholder-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.placeholder-icon svg {
  width: 32px;
  height: 32px;
  color: var(--text-dim);
}

.camera-placeholder h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.camera-placeholder p {
  font-size: 0.875rem;
  max-width: 360px;
  line-height: 1.4;
}

/* Camera Guides Overlay */
.camera-guides {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  transition: opacity var(--transition-normal);
}

.camera-guides.hidden {
  opacity: 0;
}

.guide-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  transform: translate(-50%, -50%);
  border: 1px dashed rgba(255, 255, 255, 0.3);
  border-radius: 50%;
}

.guide-zone.top-zone {
  position: absolute;
  top: 10%;
  left: 20%;
  right: 20%;
  height: 40%;
  border: 1px dashed rgba(56, 189, 248, 0.4);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 4px;
}

.guide-zone.top-zone span {
  font-size: 0.65rem;
  color: rgba(56, 189, 248, 0.7);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Border Flash on Slouch */
.camera-border-flash {
  position: absolute;
  inset: 0;
  border: 4px solid var(--color-bad);
  border-radius: calc(var(--radius-md) - 2px);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.camera-container.status-slouch .camera-border-flash {
  opacity: 1;
  animation: borderFlash 0.8s infinite alternate;
}

@keyframes borderFlash {
  0% { opacity: 0.4; }
  100% { opacity: 1; }
}

/* Camera Toolbar */
.camera-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#btn-toggle-cam {
  flex: 1;
}

/* ==========================================================================
   Sidebar: Live Predictions, Statistics & Settings
   ========================================================================== */

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.sidebar-card {
  position: relative;
}

.live-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: #34d399;
  background: rgba(16, 185, 129, 0.12);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  letter-spacing: 0.05em;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
  animation: liveDotPulse 1.2s infinite ease-in-out;
}

@keyframes liveDotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* Prediction Bars */
.prediction-bars {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.pred-item {
  background: rgba(0, 0, 0, 0.25);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: all var(--transition-normal);
}

.pred-item.highlight-good {
  border-color: rgba(16, 185, 129, 0.5);
  background: rgba(16, 185, 129, 0.08);
}

.pred-item.highlight-bad {
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.08);
}

.pred-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.45rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.class-prob {
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
}

.prob-track {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.prob-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.12s ease-out, background 0.2s ease;
}

.fill-siap, .fill-good {
  background: linear-gradient(90deg, #059669, #10b981);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

.fill-bungkuk, .fill-bad {
  background: linear-gradient(90deg, #dc2626, #ef4444);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

.fill-neutral {
  background: linear-gradient(90deg, #2563eb, #38bdf8);
}

/* Score Circle & Summary */
.score-summary {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 0.5rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  margin-bottom: 1rem;
}

.score-circle-wrap {
  position: relative;
  width: 90px;
  height: 90px;
  flex-shrink: 0;
}

.score-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.score-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 8;
}

.score-fill {
  fill: none;
  stroke: var(--color-good);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.4s ease, stroke 0.4s ease;
}

.score-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.score-number {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1;
}

.score-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.score-meta {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

.meta-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.825rem;
}

.meta-title {
  color: var(--text-muted);
}

.meta-val {
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
}

.meta-val.val-green { color: var(--color-good); }
.meta-val.val-amber { color: var(--color-warning); }
.meta-val.val-red { color: var(--color-bad); }

/* Stats 4-Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.stat-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-box .stat-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-box .stat-icon svg {
  width: 18px;
  height: 18px;
}

.stat-box.good .stat-icon {
  background: var(--color-good-bg);
  color: var(--color-good);
}

.stat-box.bad .stat-icon {
  background: var(--color-bad-bg);
  color: var(--color-bad);
}

.stat-box.warning .stat-icon {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.stat-box.info .stat-icon {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.stat-data {
  display: flex;
  flex-direction: column;
}

.stat-num {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1.1;
}

.stat-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Settings List */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.setting-info {
  display: flex;
  flex-direction: column;
}

.setting-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.setting-name svg {
  width: 14px;
  height: 14px;
  color: var(--color-cyan);
}

.setting-sub {
  font-size: 0.725rem;
  color: var(--text-muted);
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--color-primary);
  box-shadow: 0 0 10px var(--color-primary-glow);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* Sliders */
.setting-slider-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.825rem;
  color: var(--text-main);
}

.slider-header span {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.slider-header span svg {
  width: 14px;
  height: 14px;
  color: var(--color-cyan);
}

.slider-header strong {
  color: #38bdf8;
  font-family: 'Outfit', sans-serif;
}

.setting-slider-group input[type="range"] {
  width: 100%;
  accent-color: var(--color-primary);
  background: rgba(255, 255, 255, 0.1);
  height: 6px;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.slider-hint {
  font-size: 0.725rem;
  color: var(--text-dim);
  line-height: 1.3;
}

.class-mapping-box {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.class-mapping-box label {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.class-mapping-box label svg {
  width: 14px;
  height: 14px;
}

.class-mapping-box input {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.75rem;
  color: #fff;
  font-size: 0.8rem;
  font-family: inherit;
  outline: none;
}

/* Activity Log */
.activity-card {
  max-height: 220px;
  display: flex;
  flex-direction: column;
}

.activity-log-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  overflow-y: auto;
  max-height: 130px;
  padding-right: 0.25rem;
}

.log-entry {
  display: flex;
  gap: 0.5rem;
  font-size: 0.75rem;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.2);
  line-height: 1.3;
}

.log-time {
  color: var(--text-dim);
  font-family: monospace;
  flex-shrink: 0;
}

.log-msg {
  color: var(--text-muted);
}

.log-entry.log-alert {
  background: var(--color-bad-bg);
  border-left: 3px solid var(--color-bad);
}
.log-entry.log-alert .log-msg { color: #fca5a5; font-weight: 600; }

.log-entry.log-recovery {
  background: var(--color-good-bg);
  border-left: 3px solid var(--color-good);
}
.log-entry.log-recovery .log-msg { color: #86efac; }

/* ==========================================================================
   Full Slouch Alert Screen Overlay
   ========================================================================== */

.alert-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(15, 5, 5, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  visibility: visible;
  transition: all 0.25s ease;
  padding: 1.5rem;
}

.alert-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.alert-box {
  position: relative;
  max-width: 520px;
  width: 100%;
  background: linear-gradient(135deg, #2b0c0c, #1a0808);
  border: 2px solid var(--color-bad);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  text-align: center;
  box-shadow: var(--shadow-glow-bad), 0 25px 50px -12px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  animation: shakeAlert 0.5s ease-in-out;
}

@keyframes shakeAlert {
  0%, 100% { transform: scale(1); }
  20% { transform: scale(1.03) rotate(-1deg); }
  40% { transform: scale(1.03) rotate(1deg); }
  60% { transform: scale(1.02) rotate(-0.5deg); }
  80% { transform: scale(1.01) rotate(0.5deg); }
}

.alert-icon-wrap {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--color-bad);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 30px var(--color-bad);
  animation: alertIconPulse 1s infinite alternate;
}

.alert-icon-wrap svg {
  width: 38px;
  height: 38px;
}

@keyframes alertIconPulse {
  from { transform: scale(0.95); }
  to { transform: scale(1.08); box-shadow: 0 0 45px rgba(239, 68, 68, 0.9); }
}

.alert-text-content h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.75rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 0.5rem;
  text-shadow: 0 0 20px rgba(239, 68, 68, 0.7);
}

.alert-text-content p {
  color: #fecaca;
  font-size: 1.05rem;
  line-height: 1.4;
}

.alert-text-content p strong {
  color: #86efac;
  text-decoration: underline;
}

.slouch-timer-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 0.4rem 1rem;
  border-radius: var(--radius-full);
  margin-top: 1rem;
  font-size: 0.9rem;
  color: #fca5a5;
}

.slouch-timer-badge svg {
  width: 16px;
  height: 16px;
}

.slouch-timer-badge strong {
  font-family: 'Outfit', sans-serif;
  color: #fff;
  font-size: 1rem;
}

/* ==========================================================================
   Guide Modal
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  transition: all var(--transition-normal);
}

.modal-backdrop.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal-box {
  max-width: 650px;
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-title svg {
  color: var(--color-cyan);
}

.modal-title h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-body {
  padding: 1.5rem;
  max-height: 70vh;
  overflow-y: auto;
}

.guide-steps {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.guide-step {
  display: flex;
  gap: 1rem;
}

.step-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  color: #fff;
  font-weight: 800;
  font-family: 'Outfit', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-content h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.35rem;
}

.step-content p, .step-content ul {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.step-content ul {
  padding-left: 1.25rem;
  margin-top: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.step-content a {
  color: #38bdf8;
  text-decoration: none;
}

.step-content a:hover {
  text-decoration: underline;
}

.step-content code {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  color: #facc15;
  font-family: monospace;
  font-size: 0.8rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: flex-end;
}
