/* ============================================
   TEACH THE MACHINE - Kid-Friendly AI Demo
   ============================================ */

:root {
  --primary: #6C63FF;
  --primary-light: #8B85FF;
  --secondary: #FF6B9D;
  --success: #4ECDC4;
  --warning: #FFE66D;
  --danger: #FF6B6B;
  --dark: #2D3436;
  --light: #F8F9FA;
  --white: #FFFFFF;
  
  --gradient-fun: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-warm: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --gradient-cool: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --gradient-nature: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
  
  --shadow-soft: 0 4px 20px rgba(108, 99, 255, 0.15);
  --shadow-medium: 0 8px 30px rgba(108, 99, 255, 0.2);
  --shadow-strong: 0 15px 50px rgba(108, 99, 255, 0.3);
  
  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 30px;
  --radius-round: 50%;
  
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
}

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

body {
  background: linear-gradient(180deg, #E8F4FD 0%, #F0E6FF 50%, #FFF0F5 100%);
  min-height: 100vh;
  color: var(--dark);
  overflow-x: hidden;
}

/* ============================================
   LOADING SCREEN
   ============================================ */

.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--gradient-fun);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-content {
  text-align: center;
  color: var(--white);
  padding: 40px;
}

.brain-animation {
  position: relative;
  margin-bottom: 30px;
}

.brain {
  font-size: 80px;
  animation: pulse 1.5s ease-in-out infinite;
}

.sparkles {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  gap: 20px;
}

.sparkles span {
  font-size: 24px;
  animation: sparkle 1s ease-in-out infinite;
}

.sparkles span:nth-child(2) { animation-delay: 0.2s; }
.sparkles span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

@keyframes sparkle {
  0%, 100% { opacity: 0; transform: scale(0.5) translateY(0); }
  50% { opacity: 1; transform: scale(1) translateY(-10px); }
}

.loading-content h1 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 10px;
}

.loading-content p {
  font-size: 16px;
  opacity: 0.9;
  margin-bottom: 20px;
}

.progress-bar {
  width: 200px;
  height: 8px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  margin: 0 auto;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--white);
  border-radius: 10px;
  width: 0%;
  transition: width 0.3s ease;
}

/* ============================================
   MAIN APP
   ============================================ */

.main-app {
  opacity: 1;
  transition: opacity 0.5s ease;
}

.main-app.hidden {
  opacity: 0;
  pointer-events: none;
}

.header {
  text-align: center;
  padding: 30px 20px 20px;
  background: var(--gradient-fun);
  color: var(--white);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  margin-bottom: 20px;
  box-shadow: var(--shadow-medium);
}

.header h1 {
  font-size: clamp(28px, 6vw, 42px);
  font-weight: 800;
  margin-bottom: 8px;
}

.tagline {
  font-size: 16px;
  opacity: 0.9;
  margin-bottom: 20px;
}

.status-bar {
  display: flex;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.2);
  padding: 8px 16px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-weight: 600;
}

.status-icon {
  font-size: 18px;
}

/* ============================================
   CONTAINER & CARDS
   ============================================ */

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.step-card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-soft);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.step-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-medium);
}

.step-header {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 12px;
}

.step-number {
  width: 40px;
  height: 40px;
  background: var(--gradient-fun);
  color: var(--white);
  border-radius: var(--radius-round);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  flex-shrink: 0;
}

.step-header h2 {
  font-size: 20px;
  font-weight: 700;
}

.step-desc {
  color: #666;
  font-size: 15px;
  margin-bottom: 20px;
  line-height: 1.5;
}

/* ============================================
   CLASS CREATOR
   ============================================ */

.class-creator {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.class-creator input {
  flex: 1;
  padding: 14px 18px;
  border: 2px solid #E8E8E8;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: inherit;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.class-creator input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(108, 99, 255, 0.1);
}

.class-creator input::placeholder {
  color: #AAA;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: var(--gradient-fun);
  color: var(--white);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-medium);
}

.btn-success {
  background: var(--gradient-nature);
  color: var(--white);
}

.btn-success:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(78, 205, 196, 0.4);
}

.btn-danger {
  background: var(--gradient-warm);
  color: var(--white);
}

.btn-danger:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(255, 107, 107, 0.4);
}

.btn-ghost {
  background: transparent;
  color: var(--danger);
  border: 2px dashed var(--danger);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 107, 107, 0.1);
}

.btn-lg {
  padding: 16px 32px;
  font-size: 18px;
  border-radius: var(--radius-md);
}

.btn-icon span {
  font-size: 18px;
}

/* ============================================
   CLASS CARDS
   ============================================ */

.class-cards {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}

.class-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: linear-gradient(135deg, #f5f7fa 0%, #e4e8eb 100%);
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  transition: all 0.3s ease;
  cursor: pointer;
}

.class-card:hover {
  background: linear-gradient(135deg, #e8f4fd 0%, #dbeafe 100%);
}

.class-card.active {
  border-color: var(--primary);
  background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
  box-shadow: 0 4px 15px rgba(108, 99, 255, 0.2);
}

.class-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.class-emoji {
  font-size: 28px;
}

.class-name {
  font-weight: 700;
  font-size: 16px;
}

.class-count {
  font-size: 13px;
  color: #666;
}

.class-actions {
  display: flex;
  gap: 8px;
}

.class-btn {
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.class-btn.train {
  background: var(--success);
  color: var(--white);
}

.class-btn.train:hover {
  background: #3dbdb4;
}

.class-btn.delete {
  background: transparent;
  color: var(--danger);
}

.class-btn.delete:hover {
  background: rgba(255, 107, 107, 0.1);
}

/* ============================================
   SUGGESTION CHIPS
   ============================================ */

.suggestion-chips {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.chip-label {
  font-size: 14px;
  color: #888;
}

.chip {
  padding: 8px 16px;
  background: #F0F0F0;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chip:hover {
  background: var(--primary-light);
  color: var(--white);
  transform: scale(1.05);
}

/* ============================================
   CAMERA
   ============================================ */

.camera-container {
  margin-bottom: 20px;
}

.camera-wrapper {
  position: relative;
  aspect-ratio: 4/3;
  background: #1a1a2e;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 16px;
}

#camera, #overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#overlay {
  pointer-events: none;
}

.camera-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #666;
  background: linear-gradient(135deg, #2d3436 0%, #1a1a2e 100%);
}

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

.placeholder-icon {
  font-size: 60px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.camera-placeholder p {
  font-size: 14px;
  opacity: 0.7;
  color: #aaa;
}

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

/* ============================================
   TRAIN OVERLAY
   ============================================ */

.train-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.train-overlay.hidden {
  display: none;
}

.capture-frame {
  width: 70%;
  height: 70%;
  border: 4px dashed var(--success);
  border-radius: var(--radius-md);
  animation: framePulse 2s ease-in-out infinite;
}

@keyframes framePulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.02); }
}

.capture-hint {
  position: absolute;
  bottom: 20px;
  background: rgba(0, 0, 0, 0.7);
  color: var(--white);
  padding: 10px 20px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-weight: 600;
}

/* ============================================
   DETECT OVERLAY
   ============================================ */

.detect-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.detect-overlay.hidden {
  display: none;
}

.prediction-box {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-soft);
}

#predLabel {
  font-weight: 700;
  font-size: 18px;
  flex: 1;
}

.confidence-bar {
  width: 80px;
  height: 8px;
  background: #E0E0E0;
  border-radius: 10px;
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  background: var(--gradient-nature);
  width: 0%;
  transition: width 0.3s ease;
}

#confText {
  font-weight: 700;
  font-size: 14px;
  color: var(--success);
  min-width: 40px;
  text-align: right;
}

/* ============================================
   TRAINING SECTION
   ============================================ */

.training-section {
  border-top: 2px dashed #E8E8E8;
  padding-top: 20px;
  margin-top: 10px;
}

.training-section.hidden {
  display: none;
}

.active-class-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
  font-size: 16px;
}

.active-class-name {
  background: var(--gradient-fun);
  color: var(--white);
  padding: 8px 20px;
  border-radius: var(--radius-lg);
  font-weight: 700;
}

.capture-controls {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.btn-capture {
  background: var(--gradient-warm);
  color: var(--white);
  padding: 20px 40px;
  font-size: 20px;
  border-radius: var(--radius-lg);
  animation: captureGlow 2s ease-in-out infinite;
}

.btn-capture:hover:not(:disabled) {
  transform: scale(1.05);
}

.btn-capture:active:not(:disabled) {
  transform: scale(0.95);
}

@keyframes captureGlow {
  0%, 100% { box-shadow: 0 0 20px rgba(255, 107, 157, 0.4); }
  50% { box-shadow: 0 0 40px rgba(255, 107, 157, 0.6); }
}

.capture-icon {
  font-size: 28px;
}

.sample-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.sample-thumb {
  aspect-ratio: 1;
  border-radius: 10px;
  object-fit: cover;
  animation: popIn 0.3s ease;
}

@keyframes popIn {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.training-hint {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #FFF9E6;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: #8B7355;
}

.training-hint span {
  font-size: 20px;
}

.training-hint p {
  margin: 0;
  line-height: 1.4;
}

/* ============================================
   MODE TOGGLE
   ============================================ */

.mode-toggle {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  background: #F5F5F5;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s ease;
}

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

.mode-btn.active {
  background: var(--white);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: var(--shadow-soft);
}

.mode-btn span {
  font-size: 20px;
}

/* ============================================
   STATS
   ============================================ */

.finding-stats {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 20px;
}

.finding-stats.hidden {
  display: none;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 24px;
  background: linear-gradient(135deg, #f5f7fa 0%, #e8eaed 100%);
  border-radius: var(--radius-sm);
  min-width: 100px;
}

.stat-icon {
  font-size: 28px;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--primary);
}

.stat-label {
  font-size: 13px;
  color: #888;
}

/* ============================================
   HOW IT WORKS
   ============================================ */

.how-it-works {
  max-width: 600px;
  margin: 30px auto;
  padding: 24px;
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  text-align: center;
}

.how-it-works h3 {
  font-size: 20px;
  margin-bottom: 20px;
}

.steps-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.visual-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.visual-icon {
  width: 60px;
  height: 60px;
  background: var(--gradient-cool);
  border-radius: var(--radius-round);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.visual-step p {
  font-size: 13px;
  font-weight: 600;
  color: #666;
}

.arrow {
  font-size: 24px;
  color: #CCC;
}

.privacy-note {
  font-size: 13px;
  color: #888;
  background: #F8F9FA;
  padding: 10px 16px;
  border-radius: var(--radius-lg);
  display: inline-block;
}

/* ============================================
   FOOTER
   ============================================ */

.footer {
  text-align: center;
  padding: 30px 20px;
  color: #888;
  font-size: 14px;
}

/* ============================================
   BOUNDING BOX STYLES (drawn on canvas)
   ============================================ */

.hidden {
  display: none !important;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 480px) {
  .class-creator {
    flex-direction: column;
  }
  
  .steps-visual {
    flex-direction: column;
  }
  
  .arrow {
    transform: rotate(90deg);
  }
  
  .mode-toggle {
    flex-direction: column;
  }
}

@media (min-width: 768px) {
  .container {
    max-width: 700px;
  }
  
  .camera-wrapper {
    aspect-ratio: 16/10;
  }
}

/* ============================================
   ANIMATIONS FOR FOUND OBJECTS
   ============================================ */

@keyframes boxPop {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

/* Flash effect when capturing */
.flash {
  animation: flashEffect 0.3s ease;
}

@keyframes flashEffect {
  0% { filter: brightness(1); }
  50% { filter: brightness(2); }
  100% { filter: brightness(1); }
}
