/* ==========================================================================
   AI KIDS LAB - Modern, Dynamic & Kid-Friendly Design System
   ========================================================================== */

:root {
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --secondary: #06B6D4;
  --accent: #F59E0B;
  --success: #10B981;
  --danger: #EF4444;
  --bg-gradient: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 50%, #F0F9FF 100%);
  --card-bg: #FFFFFF;
  --text-main: #1E293B;
  --text-muted: #64748B;
  --border-radius: 20px;
  --shadow-soft: 0 10px 25px -5px rgba(79, 70, 229, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  --shadow-hover: 0 20px 30px -10px rgba(79, 70, 229, 0.2);
  --font-heading: 'Fredoka', cursive, sans-serif;
  --font-body: 'Quicksand', sans-serif;
}

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

body {
  font-family: var(--font-body);
  background: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 2rem;
  line-height: 1.5;
}

/* Header Styling */
.app-header {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  padding: 1.25rem 2.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid rgba(224, 231, 255, 0.8);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 4px 15px rgba(0,0,0,0.03);
}

.logo-container {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.logo-badge {
  font-family: var(--font-heading);
  background: #EEF2FF;
  color: var(--primary);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  width: fit-content;
}

.logo-title {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  color: var(--primary);
  letter-spacing: 0.5px;
}

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

.badge {
  padding: 8px 16px;
  border-radius: 30px;
  font-weight: 700;
  font-size: 0.9rem;
}

.privacy-badge {
  background: #ECFDF5;
  color: #047857;
  border: 1px solid #A7F3D0;
}

.status-badge {
  background: #FEF3C7;
  color: #B45309;
  border: 1px solid #FDE68A;
}

.status-badge.ready {
  background: #ECFDF5;
  color: #047857;
  border: 1px solid #A7F3D0;
}

/* Main Layout Structure */
.main-layout {
  max-width: 1280px;
  width: 92%;
  margin: 2rem auto;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

/* Banner Step Indicator & Preset Selector */
.banner-card {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 1.5rem 2rem;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.steps-indicator {
  display: flex;
  justify-content: space-around;
  position: relative;
  gap: 1rem;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--text-muted);
  opacity: 0.6;
  transition: all 0.3s ease;
}

.step-item.active {
  opacity: 1;
  color: var(--primary);
  transform: scale(1.05);
}

.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #E0E7FF;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.step-item.active .step-num {
  background: var(--primary);
  color: #FFFFFF;
}

.preset-section {
  display: flex;
  align-items: center;
  gap: 1rem;
  border-top: 1px dashed #E2E8F0;
  padding-top: 1rem;
  flex-wrap: wrap;
}

.preset-label {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.preset-buttons {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.preset-btn {
  background: #F1F5F9;
  border: 2px solid transparent;
  padding: 8px 16px;
  border-radius: 20px;
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
}

.preset-btn:hover {
  background: #E2E8F0;
}

.preset-btn.active {
  background: #EEF2FF;
  border-color: var(--primary);
  color: var(--primary);
}

/* Call to Action Banner */
.cta-banner-card {
  background: linear-gradient(135deg, #F59E0B 0%, #EA580C 100%);
  border-radius: var(--border-radius);
  padding: 1.25rem 2rem;
  color: #FFFFFF;
  box-shadow: 0 10px 25px -5px rgba(234, 88, 12, 0.3);
}

.cta-content {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.cta-icon {
  font-size: 2.8rem;
  background: rgba(255, 255, 255, 0.2);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cta-text h2 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
}

.cta-text p {
  font-size: 1.1rem;
  font-weight: 500;
  color: #FEF3C7;
}

.cta-text strong {
  color: #FFFFFF;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Cards Layout Grid */
.workspace-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.75rem;
}

@media (max-width: 900px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

.card-shadow {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 1.75rem;
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.card-header h2 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  color: var(--text-main);
}

/* Webcam Container */
.webcam-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #0F172A;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid #E2E8F0;
}

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

.webcam-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  backdrop-filter: blur(4px);
}

.overlay-content .camera-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.5rem;
}

.detect-pill {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  color: #FFFFFF;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  gap: 6px;
  align-items: center;
  border: 1px solid rgba(255,255,255,0.2);
}

.detect-value {
  color: #38BDF8;
}

/* Predictions Panel */
.prediction-panel {
  margin-top: 1.25rem;
  background: #F8FAFC;
  border-radius: 16px;
  padding: 1.25rem;
  border: 1px solid #E2E8F0;
}

.prediction-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.prediction-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.confidence-text {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--primary);
}

.prediction-bars {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.pred-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pred-info {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 0.9rem;
}

.pred-bar-bg {
  width: 100%;
  height: 12px;
  background: #E2E8F0;
  border-radius: 10px;
  overflow: hidden;
}

.pred-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 10px;
  transition: width 0.15s ease-out;
}

.placeholder-text {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.9rem;
  text-align: center;
  padding: 1rem;
}

/* Class Card Item Styling */
.section-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.classes-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}

.class-card {
  background: #F8FAFC;
  border: 2px solid #E2E8F0;
  border-radius: 16px;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  transition: all 0.2s ease;
}

.class-card:hover {
  border-color: #CBD5E1;
}

.class-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.class-icon-btn {
  font-size: 1.5rem;
  background: #FFFFFF;
  border: 1px solid #CBD5E1;
  border-radius: 12px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.class-input {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 8px;
  border-radius: 8px;
  width: 140px;
  color: var(--text-main);
  font-weight: 700;
}

.class-input:focus {
  background: #FFFFFF;
  border-color: var(--primary);
  outline: none;
}

.sample-count-badge {
  font-size: 0.85rem;
  font-weight: 700;
  background: #E0E7FF;
  color: var(--primary);
  padding: 4px 10px;
  border-radius: 20px;
}

.class-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Button Styles */
button {
  font-family: var(--font-heading);
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-btn {
  background: var(--primary);
  color: #FFFFFF;
  padding: 8px 16px;
  font-size: 0.9rem;
}

.action-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.train-hold-btn {
  background: linear-gradient(135deg, #10B981 0%, #059669 100%);
  color: #FFFFFF;
  padding: 10px 18px;
  font-size: 0.95rem;
  border-radius: 14px;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
  user-select: none;
}

.train-hold-btn:active, .train-hold-btn.training {
  transform: scale(0.96);
  background: #047857;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.4);
}

.delete-class-btn {
  background: #FEE2E2;
  color: var(--danger);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.delete-class-btn:hover {
  background: #FCA5A5;
}

.secondary-btn {
  background: #E2E8F0;
  color: var(--text-main);
  padding: 8px 16px;
}

.secondary-btn:hover {
  background: #CBD5E1;
}

.danger-btn {
  background: #FEF2F2;
  color: var(--danger);
  border: 1px solid #FCA5A5;
  padding: 10px 16px;
}

.danger-btn:hover {
  background: #FEE2E2;
}

.hero-btn {
  background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
  color: #FFFFFF;
  padding: 12px 24px;
  font-size: 1.1rem;
  border-radius: 16px;
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.35);
  flex-grow: 1;
}

.hero-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(245, 158, 11, 0.45);
}

.hero-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.model-controls {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #E2E8F0;
}

/* Arcade Section */
.arcade-card {
  border: 3px solid var(--accent);
}

.arcade-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem 0;
}

.arcade-cam-box {
  position: relative;
  width: 220px;
  height: 165px;
  background: #0F172A;
  border-radius: 16px;
  overflow: hidden;
  border: 3px solid #38BDF8;
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
  margin-bottom: 0.5rem;
}

#arcade-webcam-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.arcade-cam-badge {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.8);
  color: #38BDF8;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 12px;
  white-space: nowrap;
}

.game-stage {
  width: 100%;
  background: linear-gradient(135deg, #1E1B4B 0%, #312E81 100%);
  border-radius: 20px;
  padding: 2rem;
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.stage-info {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-family: var(--font-heading);
  margin-bottom: 2rem;
}

.score-badge {
  background: rgba(255,255,255,0.15);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 1.1rem;
}

.timer-badge {
  background: rgba(255,255,255,0.15);
  padding: 6px 16px;
  border-radius: 20px;
  color: #FDE047;
}

.interactive-avatar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0;
}

.avatar-face {
  font-size: 5rem;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.avatar-speech {
  background: #FFFFFF;
  color: var(--text-main);
  padding: 12px 24px;
  border-radius: 20px;
  font-family: var(--font-heading);
  font-size: 1.2rem;
  box-shadow: 0 8px 20px rgba(0,0,0,0.2);
  position: relative;
}

.game-challenge-box {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  padding: 1.25rem 2rem;
  text-align: center;
  width: 80%;
  max-width: 500px;
}

.mission-text {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  color: #38BDF8;
  margin: 0.5rem 0;
}

.mission-timer-bar {
  height: 8px;
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}

.timer-progress {
  height: 100%;
  width: 100%;
  background: #34D399;
  transition: width 0.1s linear;
}

/* Explainer Section */
.explainer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

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

.info-card {
  background: rgba(255, 255, 255, 0.7);
  border-radius: 16px;
  padding: 1.25rem;
  border: 1px solid rgba(224, 231, 255, 0.6);
}

.info-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.info-card h3 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--primary);
  margin-bottom: 0.4rem;
}

.info-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: auto;
}
