/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #6366f1;
  --primary-hover: #5855eb;
  --secondary-color: #f1f5f9;
  --accent-color: #10b981;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --background: #ffffff;
  --surface: #f8fafc;
  --error-color: #ef4444;
  --warning-color: #f59e0b;
  --success-color: #10b981;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: var(--text-primary);
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header */
.header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
}

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

.logo-icon {
  font-size: 2rem;
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav {
  display: flex;
  gap: 0.5rem;
}

.nav-btn {
  padding: 0.5rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  font-size: 0.875rem;
}

.nav-btn:hover {
  background: var(--secondary-color);
  color: var(--text-primary);
}

.nav-btn.active {
  background: var(--primary-color);
  color: white;
}

/* Main Content */
.main {
  padding: 2rem 0;
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s ease-in-out;
}

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

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

/* Chat Styles */
.chat-container {
  background: var(--background);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  max-width: 800px;
  margin: 0 auto;
}

.chat-header {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
  color: white;
  padding: 2rem;
  text-align: center;
}

.chat-header h2 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.chat-header p {
  opacity: 0.9;
  font-size: 1rem;
}

.chat-messages {
  height: 400px;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.message {
  display: flex;
  gap: 0.75rem;
  max-width: 80%;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.user-message {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.bot-message .message-avatar {
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
}

.user-message .message-avatar {
  background: linear-gradient(135deg, var(--accent-color), var(--primary-color));
}

.message-content {
  background: var(--surface);
  padding: 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.user-message .message-content {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.chat-input-container {
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--surface);
}

.input-group {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

#messageInput {
  flex: 1;
  padding: 0.875rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  font-size: 1rem;
  transition: all 0.2s ease;
  background: var(--background);
}

#messageInput:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.send-btn {
  padding: 0.875rem;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

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

.input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.disclaimer {
  font-style: italic;
}

/* Emotion Detection Styles */
.emotion-container {
  background: var(--background);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  max-width: 900px;
  margin: 0 auto;
}

.emotion-header {
  background: linear-gradient(135deg, var(--accent-color), var(--primary-color));
  color: white;
  padding: 2rem;
  text-align: center;
}

.emotion-header h2 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.camera-container {
  position: relative;
  padding: 2rem;
  text-align: center;
}

.camera-placeholder {
  background: var(--surface);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: 3rem 2rem;
  text-align: center;
}

.camera-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.camera-placeholder h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.camera-placeholder p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.primary-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 0.875rem 2rem;
  border-radius: var(--radius-lg);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1rem;
}

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

.video-feed, .emotion-canvas {
  display: none;
  width: 100%;
  max-width: 640px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.emotion-canvas {
  position: absolute;
  top: 2rem;
  left: 50%;
  transform: translateX(-50%);
}

.camera-controls {
  display: none;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.camera-controls.active {
  display: flex;
}

.control-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-lg);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.875rem;
}

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

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

.toggle-btn {
  background: var(--warning-color);
  color: white;
}

.toggle-btn:hover {
  background: #d97706;
  transform: translateY(-1px);
}

.stop-btn {
  background: var(--error-color);
  color: white;
}

.stop-btn:hover {
  background: #dc2626;
  transform: translateY(-1px);
}

.captured-photos {
  padding: 2rem;
  border-top: 1px solid var(--border-color);
  background: var(--surface);
}

.captured-photos h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.no-photos {
  color: var(--text-secondary);
  font-style: italic;
  text-align: center;
  padding: 2rem;
  grid-column: 1 / -1;
}

.photo-card {
  background: white;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

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

.photo-card img {
  width: 100%;
  height: 150px;
  object-fit: cover;
}

.photo-info {
  padding: 1rem;
}

.photo-emotion {
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 0.25rem;
}

.photo-timestamp {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.photo-confidence {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Voice Modal */
.voice-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  backdrop-filter: blur(8px);
}

.voice-modal.active {
  display: flex;
}

.voice-modal-content {
  background: white;
  padding: 3rem 2rem;
  border-radius: var(--radius-xl);
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}

.voice-animation {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.voice-circle {
  width: 12px;
  height: 12px;
  background: var(--accent-color);
  border-radius: 50%;
  animation: voiceWave 1.4s infinite ease-in-out;
}

.voice-circle:nth-child(2) {
  animation-delay: -0.16s;
}

.voice-circle:nth-child(3) {
  animation-delay: -0.32s;
}

@keyframes voiceWave {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1.2);
    opacity: 1;
  }
}

.voice-modal h3 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

#voiceTranscript {
  background: var(--surface);
  padding: 1rem;
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-style: italic;
}

.stop-voice-btn {
  background: var(--error-color);
  color: white;
  border: none;
  padding: 0.875rem 2rem;
  border-radius: var(--radius-lg);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.stop-voice-btn:hover {
  background: #dc2626;
  transform: translateY(-1px);
}
.emotion-results {
  padding: 2rem;
  border-top: 1px solid var(--border-color);
}

.emotion-card {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: var(--surface);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.emotion-icon {
  font-size: 3rem;
  width: 4rem;
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

.emotion-info h4 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.confidence-bar {
  width: 200px;
  height: 8px;
  background: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.confidence-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-color), var(--primary-color));
  width: 0%;
  transition: width 0.3s ease;
}

.emotion-tips {
  padding: 2rem;
  border-top: 1px solid var(--border-color);
  background: var(--surface);
}

.emotion-tips h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.loading-overlay.active {
  display: flex;
}

.loading-spinner {
  width: 3rem;
  height: 3rem;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top: 3px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

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

.loading-overlay p {
  color: white;
  font-size: 1.125rem;
  font-weight: 500;
}

/* Responsive Design */
@media (max-width: 768px) {
  .header .container {
    flex-direction: column;
    gap: 1rem;
  }

  .logo h1 {
    font-size: 1.25rem;
  }

  .nav {
    width: 100%;
    justify-content: center;
  }

  .nav-btn {
    flex: 1;
    text-align: center;
  }

  .chat-messages {
    height: 300px;
    padding: 1rem;
  }

  .message {
    max-width: 90%;
  }

  .emotion-card {
    flex-direction: column;
    text-align: center;
  }

  .confidence-bar {
    width: 100%;
    max-width: 200px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 0.75rem;
  }

  .main {
    padding: 1rem 0;
  }

  .chat-header, .emotion-header {
    padding: 1.5rem;
  }

  .chat-header h2, .emotion-header h2 {
    font-size: 1.5rem;
  }

  .camera-placeholder {
    padding: 2rem 1rem;
  }

  .camera-icon {
    font-size: 3rem;
  }
}