/* ==========================================================================
   Real-Time Face Tracking & Emotion Analyzer - Glassmorphism UI Style System
   ========================================================================== */

:root {
  --bg-dark: #090d16;
  --bg-card: rgba(18, 25, 41, 0.75);
  --bg-card-hover: rgba(26, 36, 58, 0.85);
  --border-card: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(0, 255, 102, 0.3);
  
  --primary-neon: #00FF66; /* Green frame bounding box color */
  --primary-neon-glow: rgba(0, 255, 102, 0.4);
  --accent-cyan: #00E5FF;
  --accent-purple: #8A2BE2;
  --accent-pink: #FF007F;
  --accent-amber: #FFB300;
  
  --text-main: #F1F5F9;
  --text-muted: #94A3B8;
  --text-dim: #64748B;
  
  /* 7 Emotion Accent Colors */
  --color-surprise: #00E5FF; /* Cyan */
  --color-angry: #FF3B30;    /* Crimson Red */
  --color-fear: #AF52DE;     /* Violet Purple */
  --color-happy: #FFCC00;    /* Vibrant Yellow/Gold */
  --color-sad: #5856D6;      /* Deep Royal Blue */
  --color-neutral: #8E8E93;  /* Slate Silver */
  --color-disgust: #34C759;  /* Emerald Green */
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --shadow-main: 0 12px 32px rgba(0, 0, 0, 0.45);
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Outfit', sans-serif;
  
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(0, 229, 255, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(138, 43, 226, 0.07) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(0, 255, 102, 0.04) 0%, transparent 60%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  overflow-x: hidden;
}

/* App Container Layout */
.app-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem 2rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-height: 100vh;
}

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

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

.brand-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary-neon) 0%, var(--accent-cyan) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  box-shadow: 0 0 16px var(--primary-neon-glow);
}

.brand-icon i {
  width: 26px;
  height: 26px;
  stroke-width: 2.5;
}

.brand h1 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.2rem 0.5rem;
  background: linear-gradient(90deg, #FF007F, #8A2BE2);
  border-radius: var(--radius-full);
  color: #fff;
  letter-spacing: 0.05em;
}

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

.header-status {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-card);
}

.status-indicator.active {
  color: var(--text-main);
  border-color: rgba(0, 255, 102, 0.3);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary-neon);
  box-shadow: 0 0 10px var(--primary-neon);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.fps-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-cyan);
  background: rgba(0, 229, 255, 0.1);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-full);
  border: 1px solid rgba(0, 229, 255, 0.2);
}

/* Main Grid Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 1.5rem;
  flex: 1;
}

/* Glassmorphism Card System */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-main);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

.card-header h2 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-main);
}

.card-header h2 i {
  color: var(--primary-neon);
  width: 20px;
  height: 20px;
}

/* Buttons */
.btn {
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all var(--transition-fast);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-neon) 0%, #00C853 100%);
  color: #041207;
  box-shadow: 0 4px 14px var(--primary-neon-glow);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 255, 102, 0.6);
}

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

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

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-large {
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

/* Video Section */
.video-section {
  display: flex;
  flex-direction: column;
}

.video-card {
  height: 100%;
}

.camera-controls {
  display: flex;
  gap: 0.75rem;
}

.video-container {
  position: relative;
  width: 100%;
  height: 480px;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid rgba(0, 255, 102, 0.2);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8);
}

#webcam {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* Mirror view for natural webcam feel */
}

#outputCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transform: scaleX(-1); /* Mirror canvas to match webcam */
}

.video-placeholder {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #0b1120 0%, #151d30 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  text-align: center;
  padding: 2rem;
}

.placeholder-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  max-width: 320px;
}

.icon-circle {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(0, 255, 102, 0.08);
  border: 1px solid rgba(0, 255, 102, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-neon);
}

.icon-circle i {
  width: 36px;
  height: 36px;
}

.placeholder-content h3 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 600;
}

.placeholder-content p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Video HUD Overlay */
.hud-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 0.75rem;
  z-index: 5;
}

.hud-badge {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 255, 102, 0.3);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.hud-label {
  color: var(--text-muted);
}

.hud-value {
  font-weight: 700;
  color: #fff;
}

.hud-value.highlight {
  color: var(--primary-neon);
  text-shadow: 0 0 8px var(--primary-neon-glow);
}

/* Video Controls Footer Bar */
.video-controls-bar {
  display: flex;
  justify-content: space-around;
  background: rgba(255, 255, 255, 0.02);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-card);
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.control-group label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.control-group input[type="checkbox"] {
  accent-color: var(--primary-neon);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Analytics Section */
.analytics-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Hero Dominant Emotion Card */
.hero-emotion-card {
  background: linear-gradient(135deg, rgba(18, 25, 41, 0.85) 0%, rgba(30, 42, 69, 0.7) 100%);
  border-left: 4px solid var(--primary-neon);
  padding: 1.25rem 1.5rem;
}

.hero-emotion-content {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.emotion-emoji-box {
  font-size: 3.2rem;
  line-height: 1;
  width: 76px;
  height: 76px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-card);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(0,0,0,0.3);
  transition: transform var(--transition-fast);
}

.emotion-details {
  flex: 1;
}

.meta-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.emotion-details h3 {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--primary-neon);
  margin-bottom: 0.2rem;
}

.confidence-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

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

.confidence-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-neon), var(--accent-cyan));
  border-radius: var(--radius-full);
  transition: width var(--transition-smooth);
}

/* 7 Emotion Percentage Bars */
.metrics-card {
  padding: 1.25rem;
}

.live-tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: #FF3B30;
  background: rgba(255, 59, 48, 0.12);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 59, 48, 0.25);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.red-dot {
  width: 6px;
  height: 6px;
  background: #FF3B30;
  border-radius: 50%;
  animation: pulse 1.2s infinite;
}

.emotion-bars-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.emotion-row {
  display: grid;
  grid-template-columns: 110px 1fr 50px;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
}

.emotion-label-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.emotion-icon {
  font-size: 1.1rem;
}

.bar-wrapper {
  width: 100%;
}

.bar-background {
  height: 12px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.25s ease-out, background-color 0.25s ease;
}

.emotion-val {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.88rem;
  text-align: right;
  color: var(--text-main);
}

/* Individual Emotion Color Mapping */
.emotion-row[data-emotion="surprise"] .bar-fill { background: linear-gradient(90deg, #00B4DB, var(--color-surprise)); }
.emotion-row[data-emotion="angry"] .bar-fill    { background: linear-gradient(90deg, #FF416C, var(--color-angry)); }
.emotion-row[data-emotion="fear"] .bar-fill     { background: linear-gradient(90deg, #7F00FF, var(--color-fear)); }
.emotion-row[data-emotion="happy"] .bar-fill    { background: linear-gradient(90deg, #F7971E, var(--color-happy)); }
.emotion-row[data-emotion="sad"] .bar-fill      { background: linear-gradient(90deg, #2193b0, var(--color-sad)); }
.emotion-row[data-emotion="neutral"] .bar-fill  { background: linear-gradient(90deg, #757F9A, var(--color-neutral)); }
.emotion-row[data-emotion="disgust"] .bar-fill  { background: linear-gradient(90deg, #11998e, var(--color-disgust)); }

/* Timeline Chart */
.timeline-card {
  padding: 1rem 1.25rem;
}

.meta-tag {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.chart-container {
  height: 150px;
  position: relative;
  width: 100%;
}

/* Snapshot Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

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

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

.modal-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.modal-body img {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-card);
}

.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-card);
  display: flex;
  justify-content: flex-end;
}

.snapshot-details {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 1rem 0 0.5rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  
  .video-container {
    height: 480px;
  }
}

@media (max-width: 768px) {
  .app-container {
    padding: 1rem;
  }
  
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .header-status {
    width: 100%;
    justify-content: space-between;
  }
  
  .video-container {
    height: 380px;
  }
  
  .video-controls-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .hero-emotion-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  .video-container {
    height: 280px;
  }
  
  .camera-controls {
    flex-direction: column;
    width: 100%;
  }
  
  .btn {
    width: 100%;
    justify-content: center;
  }
  
  .emotion-row {
    grid-template-columns: 90px 1fr 40px;
  }
}
