/* ==========================================================================
   PostureGuard AI — Master Design System & Stylesheet
   Theme: Futuristic Ergonomic Dark Glassmorphism
   ========================================================================== */

:root {
  /* Color Palette - HSL Tailored Tokens */
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-tertiary: #1f293d;
  --bg-glass: rgba(17, 24, 39, 0.72);
  --bg-glass-card: rgba(22, 32, 54, 0.65);
  --bg-glass-hover: rgba(30, 42, 69, 0.85);

  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.4);
  --border-glow: rgba(56, 189, 248, 0.25);

  --text-main: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --text-inverse: #0b0f19;

  /* Status Colors */
  --emerald-500: #10b981;
  --emerald-400: #34d399;
  --emerald-glow: rgba(16, 185, 129, 0.35);
  --emerald-bg: rgba(16, 185, 129, 0.12);

  --crimson-500: #ef4444;
  --crimson-400: #f87171;
  --crimson-glow: rgba(239, 68, 68, 0.45);
  --crimson-bg: rgba(239, 68, 68, 0.12);

  --amber-500: #f59e0b;
  --amber-400: #fbbf24;
  --amber-glow: rgba(245, 158, 11, 0.35);
  --amber-bg: rgba(245, 158, 11, 0.12);

  --cyan-500: #06b6d4;
  --cyan-400: #22d3ee;
  --cyan-glow: rgba(6, 182, 212, 0.35);

  --indigo-500: #6366f1;
  --indigo-600: #4f46e5;
  --indigo-glow: rgba(99, 102, 241, 0.4);

  /* Shadows & Blurs */
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 20px 30px -8px rgba(0, 0, 0, 0.5), 0 8px 12px -4px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 25px var(--indigo-glow);
  --backdrop-blur: blur(16px);

  /* Font Families */
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;

  /* Transitions */
  --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */

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

html {
  scroll-behavior: smooth;
  color-scheme: dark;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Ambient Glowing Background Orbs */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(120px);
  z-index: 0;
  opacity: 0.45;
  animation: floatAmbient 18s ease-in-out infinite alternate;
}

.glow-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--indigo-500), transparent 70%);
  top: -100px;
  left: -100px;
}

.glow-2 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, var(--cyan-500), transparent 70%);
  bottom: 5%;
  right: -50px;
  animation-delay: -6s;
}

.glow-3 {
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, var(--emerald-500), transparent 70%);
  top: 40%;
  left: 30%;
  opacity: 0.2;
  animation-delay: -12s;
}

@keyframes floatAmbient {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, 30px) scale(1.1); }
  100% { transform: translate(-30px, -40px) scale(0.95); }
}

/* ==========================================================================
   Header & Brand Styles
   ========================================================================== */

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: var(--backdrop-blur);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 24px;
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon-wrapper {
  position: relative;
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--indigo-600), var(--cyan-500));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px var(--indigo-glow);
}

.brand-icon {
  font-size: 1.4rem;
  color: #fff;
}

.live-dot-pulse {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 12px;
  height: 12px;
  background-color: var(--emerald-400);
  border-radius: 50%;
  border: 2px solid var(--bg-primary);
  box-shadow: 0 0 8px var(--emerald-400);
  animation: pulseDot 1.8s infinite;
}

@keyframes pulseDot {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.8; }
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.brand-title span {
  color: var(--cyan-400);
}

.badge-ai {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: linear-gradient(90deg, var(--indigo-600), var(--cyan-500));
  padding: 2px 7px;
  border-radius: 6px;
  margin-left: 6px;
  vertical-align: middle;
}

.brand-subtitle {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.header-status-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.model-status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: 50px;
  font-size: 0.82rem;
  font-weight: 500;
  transition: var(--transition-normal);
}

.model-status-pill.ready {
  border-color: rgba(16, 185, 129, 0.4);
  background: var(--emerald-bg);
  color: var(--emerald-400);
}

.model-status-pill.error {
  border-color: rgba(239, 68, 68, 0.4);
  background: var(--crimson-bg);
  color: var(--crimson-400);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-indicator.loading {
  background-color: var(--amber-400);
  box-shadow: 0 0 6px var(--amber-400);
  animation: pulseDot 1.2s infinite;
}

.status-indicator.ready {
  background-color: var(--emerald-400);
  box-shadow: 0 0 6px var(--emerald-400);
}

.status-indicator.error {
  background-color: var(--crimson-400);
  box-shadow: 0 0 6px var(--crimson-400);
}

/* ==========================================================================
   Buttons & Interactive Controls
   ========================================================================== */

button {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  outline: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  border-radius: 10px;
  transition: var(--transition-fast);
}

.btn-primary {
  background: linear-gradient(135deg, var(--indigo-600), #4338ca);
  color: #fff;
  padding: 10px 20px;
  font-size: 0.92rem;
  box-shadow: 0 4px 14px var(--indigo-glow);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #4f46e5, #3730a3);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--indigo-glow);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary.btn-active-stop {
  background: linear-gradient(135deg, var(--crimson-500), #b91c1c);
  box-shadow: 0 4px 14px var(--crimson-glow);
}

.btn-primary.btn-active-stop:hover:not(:disabled) {
  background: linear-gradient(135deg, #dc2626, #991b1b);
  box-shadow: 0 6px 20px var(--crimson-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 10px 18px;
  font-size: 0.92rem;
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  padding: 10px 16px;
  font-size: 0.9rem;
}

.btn-outline:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-outline-sm {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  padding: 7px 12px;
  font-size: 0.8rem;
  border-radius: 8px;
}

.btn-outline-sm:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  border-color: var(--border-focus);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
}

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

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

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

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

/* ==========================================================================
   Layout & Cards
   ========================================================================== */

.app-main {
  max-width: 1400px;
  margin: 24px auto;
  padding: 0 24px 40px;
  position: relative;
  z-index: 1;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 24px;
  align-items: start;
}

.card {
  background: var(--bg-glass-card);
  backdrop-filter: var(--backdrop-blur);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.14);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 12px;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-icon {
  font-size: 1.2rem;
  color: var(--cyan-400);
}

.card-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* Camera Select Dropdown */
.camera-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.select-camera {
  background: rgba(11, 15, 25, 0.9);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: 8px;
  outline: none;
  cursor: pointer;
  max-width: 170px;
  transition: var(--transition-fast);
}

.select-camera:focus {
  border-color: var(--indigo-500);
}

/* ==========================================================================
   Vision HUD & Camera Viewport
   ========================================================================== */

.vision-card {
  position: relative;
}

.hud-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 480px;
  background: #060911;
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.8);
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
}

/* Posture State Glows on HUD */
.hud-viewport.state-tegak {
  border-color: var(--emerald-400);
  box-shadow: inset 0 0 30px var(--emerald-glow), 0 0 25px var(--emerald-glow);
}

.hud-viewport.state-bungkuk {
  border-color: var(--crimson-400);
  box-shadow: inset 0 0 35px var(--crimson-glow), 0 0 30px var(--crimson-glow);
  animation: pulseBungkuk 1.5s infinite;
}

@keyframes pulseBungkuk {
  0% { box-shadow: inset 0 0 25px var(--crimson-glow), 0 0 20px var(--crimson-glow); }
  50% { box-shadow: inset 0 0 45px var(--crimson-glow), 0 0 35px var(--crimson-glow); }
  100% { box-shadow: inset 0 0 25px var(--crimson-glow), 0 0 20px var(--crimson-glow); }
}

#webcamVideo {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* Default mirrored */
  opacity: 0; /* Hidden, we draw on Canvas */
  pointer-events: none;
}

#hudCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
}

/* Futuristic Scanning Grid Overlay */
.hud-grid-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background-image: 
    linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 32px 32px;
  opacity: 0.6;
}

/* Futuristic HUD Corners */
.hud-corner {
  position: absolute;
  width: 22px;
  height: 22px;
  z-index: 4;
  pointer-events: none;
  border: 2px solid rgba(56, 189, 248, 0.6);
}

.hud-corner.top-left { top: 12px; left: 12px; border-right: none; border-bottom: none; }
.hud-corner.top-right { top: 12px; right: 12px; border-left: none; border-bottom: none; }
.hud-corner.bottom-left { bottom: 12px; left: 12px; border-right: none; border-top: none; }
.hud-corner.bottom-right { bottom: 12px; right: 12px; border-left: none; border-top: none; }

/* Camera Placeholder */
.camera-placeholder {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, #131b2e 0%, #080c16 100%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
  gap: 14px;
}

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

.placeholder-icon-ring {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.1);
  border: 2px dashed rgba(99, 102, 241, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--cyan-400);
  animation: rotateRing 20s linear infinite;
}

@keyframes rotateRing {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.camera-placeholder h3 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
}

.camera-placeholder p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  max-width: 320px;
}

/* Live Posture Status Banner inside HUD */
.live-posture-banner {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: var(--backdrop-blur);
  border: 1px solid var(--border-color);
  padding: 8px 18px;
  border-radius: 50px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  min-width: 250px;
  justify-content: space-between;
}

.banner-icon-box {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  color: var(--text-secondary);
  transition: var(--transition-fast);
}

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

.banner-label {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
}

.banner-status-text {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--text-main);
  transition: color 0.3s ease;
}

.banner-confidence {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

/* Banner Status Color Variations */
.live-posture-banner.status-tegak {
  border-color: var(--emerald-400);
  box-shadow: 0 0 16px var(--emerald-glow);
}
.live-posture-banner.status-tegak .banner-icon-box {
  background: var(--emerald-bg);
  color: var(--emerald-400);
}
.live-posture-banner.status-tegak .banner-status-text {
  color: var(--emerald-400);
}
.live-posture-banner.status-tegak .banner-confidence {
  background: var(--emerald-bg);
  color: var(--emerald-400);
}

.live-posture-banner.status-bungkuk {
  border-color: var(--crimson-400);
  box-shadow: 0 0 20px var(--crimson-glow);
}
.live-posture-banner.status-bungkuk .banner-icon-box {
  background: var(--crimson-bg);
  color: var(--crimson-400);
}
.live-posture-banner.status-bungkuk .banner-status-text {
  color: var(--crimson-400);
}
.live-posture-banner.status-bungkuk .banner-confidence {
  background: var(--crimson-bg);
  color: var(--crimson-400);
}

/* Audio Alert Floating Banner */
.audio-alert-indicator {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(50px);
  opacity: 0;
  z-index: 6;
  background: linear-gradient(135deg, var(--crimson-500), #991b1b);
  color: #fff;
  padding: 8px 20px;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 0 25px var(--crimson-glow);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.audio-alert-indicator.active {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ==========================================================================
   Vision Controls & Quick Metrics
   ========================================================================== */

.vision-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  flex-wrap: wrap;
  gap: 12px;
}

.btn-group-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quick-status-pills {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mini-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.mini-pill i {
  color: var(--cyan-400);
}

/* ==========================================================================
   Live Confidence Meters
   ========================================================================== */

.confidence-container {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border-color);
}

.confidence-title {
  font-size: 0.84rem;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.meter-item {
  margin-bottom: 12px;
}

.meter-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.tegak-meter .meter-name {
  color: var(--emerald-400);
}

.bungkuk-meter .meter-name {
  color: var(--crimson-400);
}

.meter-val {
  font-family: var(--font-heading);
  font-weight: 700;
}

.meter-track {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 20px;
  overflow: hidden;
  position: relative;
}

.meter-fill {
  height: 100%;
  border-radius: 20px;
  transition: width 0.15s ease-out;
}

.tegak-fill {
  background: linear-gradient(90deg, #059669, var(--emerald-400));
  box-shadow: 0 0 10px var(--emerald-glow);
}

.bungkuk-fill {
  background: linear-gradient(90deg, #b91c1c, var(--crimson-400));
  box-shadow: 0 0 10px var(--crimson-glow);
}

/* ==========================================================================
   Sidebar Metrics: Health Score Card
   ========================================================================== */

.sidebar-metrics {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.score-card {
  position: relative;
}

.score-rating-badge {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--emerald-bg);
  color: var(--emerald-400);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.score-display-wrapper {
  display: flex;
  align-items: center;
  gap: 28px;
  margin-top: 10px;
}

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

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

.score-circle-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 12;
}

.score-circle-progress {
  fill: none;
  stroke: var(--emerald-400);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 440; /* 2 * PI * 70 */
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.8s ease, stroke 0.4s ease;
  filter: drop-shadow(0 0 8px var(--emerald-glow));
}

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

.score-number {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text-main);
}

.score-unit {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

.score-label {
  font-size: 0.75rem;
  color: var(--emerald-400);
  font-weight: 600;
  margin-top: 2px;
}

.score-breakdown {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}

.breakdown-stat {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
}

.stat-caption {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.stat-data {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.text-emerald { color: var(--emerald-400) !important; }
.text-crimson { color: var(--crimson-400) !important; }
.text-amber { color: var(--amber-400) !important; }

/* ==========================================================================
   Real-Time Timeline Chart Card
   ========================================================================== */

.chart-card .chart-wrapper {
  background: rgba(11, 15, 25, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  position: relative;
}

#timelineChart {
  width: 100%;
  height: 80px;
  display: block;
}

.chart-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  margin-top: 8px;
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

.legend-dot.tegak { background: var(--emerald-400); box-shadow: 0 0 5px var(--emerald-400); }
.legend-dot.bungkuk { background: var(--crimson-400); box-shadow: 0 0 5px var(--crimson-400); }
.legend-dot.idle { background: var(--text-muted); }

/* ==========================================================================
   Settings Card & Form Sliders
   ========================================================================== */

.settings-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.setting-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}

.setting-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Custom 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.12);
  border: 1px solid var(--border-color);
  transition: var(--transition-fast);
  border-radius: 34px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: var(--transition-fast);
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: var(--indigo-600);
  border-color: var(--indigo-500);
}

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

/* Slider Controls */
.setting-slider-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slider-value {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--cyan-400);
}

.range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  outline: none;
  cursor: pointer;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--cyan-400);
  box-shadow: 0 0 10px var(--cyan-glow);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.settings-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ==========================================================================
   Modals & Popups
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 15, 0.8);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  background: var(--bg-secondary);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  max-width: 620px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  transform: translateY(20px) scale(0.96);
  transition: transform var(--transition-bounce);
}

.modal-backdrop.show .modal-container {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-header-icon {
  font-size: 1.2rem;
  color: var(--cyan-400);
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.6rem;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

.modal-close:hover {
  color: #fff;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Guide Grid */
.guide-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.guide-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: 12px;
  position: relative;
}

.guide-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 22px;
  height: 22px;
  background: rgba(99, 102, 241, 0.2);
  color: var(--indigo-500);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

.guide-card h4 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  margin-bottom: 6px;
  color: var(--cyan-400);
}

.guide-card p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.guide-tip-banner {
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.25);
  padding: 14px 16px;
  border-radius: 12px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 0.82rem;
}

.guide-tip-banner i {
  font-size: 1.2rem;
  color: var(--cyan-400);
  margin-top: 2px;
}

.guide-tip-banner p {
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Stretching Modal Workout Specifics */
.stretch-modal {
  max-width: 500px;
}

.stretch-progress-header {
  text-align: center;
  margin-bottom: 20px;
}

.stretch-timer-display {
  font-family: var(--font-heading);
  font-size: 3rem;
  font-weight: 800;
  color: var(--emerald-400);
  letter-spacing: -0.02em;
}

.stretch-step-indicator {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.stretch-card-active {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 24px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  margin-bottom: 24px;
}

.stretch-icon-box {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--emerald-bg);
  border: 2px solid rgba(16, 185, 129, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stretch-big-icon {
  font-size: 2.2rem;
  color: var(--emerald-400);
}

.stretch-instruction h4 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  margin-bottom: 6px;
}

.stretch-instruction p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.stretch-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* Report Text Box */
.report-box {
  background: #060911;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  font-family: monospace;
  font-size: 0.85rem;
  white-space: pre-wrap;
  color: #a7f3d0;
  max-height: 320px;
  overflow-y: auto;
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 150;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: var(--backdrop-blur);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  transform: translateX(120%);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.show {
  transform: translateX(0);
}

.toast.toast-success { border-color: var(--emerald-400); }
.toast.toast-success i { color: var(--emerald-400); }

.toast.toast-error { border-color: var(--crimson-400); }
.toast.toast-error i { color: var(--crimson-400); }

.toast.toast-info { border-color: var(--cyan-400); }
.toast.toast-info i { color: var(--cyan-400); }

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  
  .hud-viewport {
    max-height: 420px;
  }
}

@media (max-width: 640px) {
  .app-header {
    padding: 12px 16px;
  }
  
  .app-main {
    padding: 0 14px 30px;
  }
  
  .header-container {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-status-group {
    width: 100%;
    justify-content: space-between;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .btn-ghost span {
    display: none;
  }
  
  .guide-grid {
    grid-template-columns: 1fr;
  }

  .score-display-wrapper {
    flex-direction: column;
    align-items: center;
    gap: 16px;
  }

  .score-breakdown {
    grid-template-columns: 1fr;
  }
}
