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

:root {
  /* Light Theme Colors */
  --primary-color: #007aff;
  --primary-hover: #0056cc;
  --secondary-color: #5856d6;
  --success-color: #34c759;
  --warning-color: #ff9500;
  --danger-color: #ff3b30;
  --eaten-color: #007aff;
  --burned-color: #ff6b35;
  --net-color: #34c759;

  --bg-primary: #ffffff;
  --bg-secondary: #f2f2f7;
  --bg-tertiary: #ffffff;
  --bg-card: #ffffff;

  --text-primary: #000000;
  --text-secondary: #3c3c43;
  --text-tertiary: #8e8e93;

  --border-color: #e5e5ea;
  --shadow-light: 0 2px 10px rgba(0, 0, 0, 0.1);
  --shadow-medium: 0 4px 20px rgba(0, 0, 0, 0.15);
  --shadow-heavy: 0 8px 30px rgba(0, 0, 0, 0.2);

  --border-radius: 12px;
  --border-radius-small: 8px;
  --border-radius-large: 20px;

  --transition-fast: 0.2s ease;
  --transition-medium: 0.3s ease;
  --transition-slow: 0.5s ease;
}

[data-theme="dark"] {
  --bg-primary: #000000;
  --bg-secondary: #1c1c1e;
  --bg-tertiary: #2c2c2e;
  --bg-card: #1c1c1e;

  --text-primary: #ffffff;
  --text-secondary: #ebebf5;
  --text-tertiary: #8e8e93;

  --border-color: #38383a;
  --shadow-light: 0 2px 10px rgba(0, 0, 0, 0.3);
  --shadow-medium: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-heavy: 0 8px 30px rgba(0, 0, 0, 0.5);
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background-color var(--transition-medium), color var(--transition-medium);
}

/* Utility Classes */
.hidden {
  display: none !important;
}
.fade-in {
  animation: fadeIn 0.3s ease forwards;
}
.fade-out {
  animation: fadeOut 0.3s ease forwards;
}
.slide-up {
  animation: slideUp 0.4s ease forwards;
}
.slide-down {
  animation: slideDown 0.4s ease forwards;
}

/* Loading Screen */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-content {
  text-align: center;
  color: white;
}

.loading-logo {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: bounce 2s infinite;
}

.loading-text {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 2rem;
  opacity: 0.9;
}

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

/* Main App */
.main-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  transition: background-color var(--transition-medium);
}

/* Header */
.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: all var(--transition-medium);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1.5rem;
  max-width: 500px;
  margin: 0 auto;
}

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

.icon-btn {
  background: none;
  border: none;
  padding: 0.5rem;
  border-radius: var(--border-radius-small);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  transform: scale(1.05);
}

/* Navigation */
.tab-nav {
  display: flex;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 0.5rem;
  position: sticky;
  bottom: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: all var(--transition-medium);
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.75rem 0.5rem;
  background: none;
  border: none;
  border-radius: var(--border-radius-small);
  color: var(--text-tertiary);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.tab-btn.active {
  color: var(--primary-color);
  background-color: rgba(0, 122, 255, 0.1);
}

.tab-btn:not(.active):hover {
  color: var(--text-secondary);
  background-color: var(--bg-secondary);
}

.tab-btn svg {
  transition: transform var(--transition-fast);
}

.tab-btn:active svg {
  transform: scale(0.95);
}

/* Tab Content */
.tab-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 100px;
}

.tab-pane {
  display: none;
  padding: 1.5rem;
  max-width: 500px;
  margin: 0 auto;
  animation: fadeIn 0.3s ease;
}

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

/* Home Tab */
.daily-summary {
  margin-bottom: 2rem;
}

.summary-card {
  background: var(--bg-card);
  border-radius: var(--border-radius-large);
  padding: 2rem;
  box-shadow: var(--shadow-light);
  text-align: center;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-color);
  transition: all var(--transition-medium);
}

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

.summary-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.date {
  font-size: 0.875rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* Separate Calorie Sections */
.calorie-sections {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

.calorie-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.calorie-ring {
  position: relative;
  display: inline-block;
}

.ring-svg {
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--bg-secondary);
  stroke-width: 6;
}

.ring-progress {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 251;
  stroke-dashoffset: 251;
  transition: stroke-dashoffset 1s ease;
}

.ring-progress.eaten {
  stroke: var(--eaten-color);
}

.ring-progress.burned {
  stroke: var(--burned-color);
}

.ring-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.calories-number {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.calories-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 0.25rem;
}

.calorie-goal {
  font-size: 0.875rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

.net-calories {
  text-align: center;
  padding: 1rem;
  background: linear-gradient(135deg, var(--net-color), #28a745);
  border-radius: var(--border-radius);
  color: white;
}

.net-label {
  font-size: 0.875rem;
  opacity: 0.9;
  margin-bottom: 0.25rem;
}

.net-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.quick-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.stat-item {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 1.5rem 1rem;
  text-align: center;
  box-shadow: var(--shadow-light);
  border: 1px solid var(--border-color);
  position: relative;
  transition: all var(--transition-fast);
}

.stat-item:hover {
  transform: translateY(-2px);
}

.stat-icon {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.stat-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

.stat-add {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  border: none;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-add:hover {
  background: var(--primary-hover);
  transform: scale(1.1);
}

/* Diet Composition */
.diet-composition {
  background: var(--bg-card);
  border-radius: var(--border-radius-large);
  padding: 1.5rem;
  box-shadow: var(--shadow-light);
  border: 1px solid var(--border-color);
  margin-bottom: 2rem;
  transition: all var(--transition-medium);
}

.diet-composition h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
  text-align: center;
}

.composition-chart {
  display: flex;
  align-items: center;
  gap: 2rem;
  justify-content: center;
}

.composition-legend {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.legend-color.eaten {
  background: var(--eaten-color);
}

.legend-color.burned {
  background: var(--burned-color);
}

.legend-color.net {
  background: var(--net-color);
}

/* Recent Meals */
.recent-meals h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

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

.view-more-btn {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-small);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.meals-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.meal-item {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 1rem;
  box-shadow: var(--shadow-light);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all var(--transition-fast);
  position: relative;
}

.meal-item:hover {
  transform: translateY(-1px);
}

.meal-image {
  width: 60px;
  height: 60px;
  border-radius: var(--border-radius-small);
  object-fit: cover;
  background: var(--bg-secondary);
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.meal-info {
  flex: 1;
}

.meal-name {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.meal-details {
  font-size: 0.875rem;
  color: var(--text-tertiary);
  display: flex;
  gap: 1rem;
  align-items: center;
}

.meal-note {
  background: var(--warning-color);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
}

.meal-calories {
  font-weight: 600;
  color: var(--primary-color);
  font-size: 1.125rem;
}

.meal-health-score {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--success-color);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.meal-health-score.medium {
  background: var(--warning-color);
}

.meal-health-score.low {
  background: var(--danger-color);
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-tertiary);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-subtitle {
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

/* Camera Tab */
.camera-container {
  text-align: center;
}

.camera-header {
  margin-bottom: 2rem;
}

.camera-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.camera-header p {
  color: var(--text-tertiary);
  font-size: 0.875rem;
}

.scan-mode-toggle {
  display: flex;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  padding: 0.25rem;
  margin-bottom: 2rem;
  justify-content: center;
}

.scan-mode-toggle .mode-btn {
  flex: 1;
  max-width: 100px;
}

.camera-area {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 0 auto 2rem;
  border-radius: var(--border-radius-large);
  overflow: hidden;
  background: var(--bg-secondary);
  aspect-ratio: 4 / 3;
}

.camera-video,
.camera-canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
}

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

.image-preview {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  border-radius: var(--border-radius);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
  min-height: 44px;
}

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

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

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

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-tertiary);
  transform: translateY(-1px);
}

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

.btn-danger:hover:not(:disabled) {
  background: #e6342a;
  transform: translateY(-1px);
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.mode-btn {
  padding: 0.5rem 1rem;
  background: none;
  border: none;
  border-radius: var(--border-radius-small);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.mode-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-light);
}

/* Analysis Results */
.analysis-results {
  margin-top: 2rem;
  background: var(--bg-card);
  border-radius: var(--border-radius-large);
  padding: 1.5rem;
  box-shadow: var(--shadow-light);
  border: 1px solid var(--border-color);
  transition: all var(--transition-medium);
}

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

.analysis-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.analysis-metric {
  text-align: center;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
}

.metric-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.metric-label {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 0.25rem;
}

.health-score {
  background: var(--success-color);
  color: white;
}

.health-score.medium {
  background: var(--warning-color);
}

.health-score.low {
  background: var(--danger-color);
}

.food-items {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.food-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: var(--bg-secondary);
  border-radius: var(--border-radius-small);
}

.food-name {
  font-weight: 500;
  color: var(--text-primary);
}

.food-calories {
  font-weight: 600;
  color: var(--primary-color);
}

.log-meal-btn {
  width: 100%;
  margin-top: 1rem;
}

/* Chat Tab */
.chat-container {
  height: calc(100vh - 200px);
  display: flex;
  flex-direction: column;
}

.chat-header {
  margin-bottom: 1rem;
}

.chat-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.chat-mode-toggle {
  display: flex;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  padding: 0.25rem;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.message {
  display: flex;
  gap: 0.75rem;
  animation: slideUp 0.3s ease;
}

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

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.bot-avatar {
  background: var(--secondary-color);
}

.message-content {
  max-width: 80%;
  padding: 0.875rem 1rem;
  border-radius: var(--border-radius);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-light);
  transition: all var(--transition-medium);
}

.message-content p {
  margin: 0;
  line-height: 1.5;
}

.message-content strong {
  font-weight: 600;
  color: var(--text-primary);
}

.message-content em {
  font-style: italic;
  color: var(--text-secondary);
}

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

.welcome-message {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.welcome-message .bot-avatar {
  width: 40px;
  height: 40px;
  font-size: 1.25rem;
}

.starter-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.prompt-chip {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.prompt-chip:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
  transform: translateY(-1px);
}

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

.chat-input-wrapper {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  padding: 0.875rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.875rem;
  resize: none;
  max-height: 100px;
  min-height: 44px;
  transition: all var(--transition-medium);
}

.chat-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.voice-btn,
.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.voice-btn {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.voice-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.voice-btn.recording {
  background: var(--danger-color);
  color: white;
  animation: pulse 1s infinite;
}

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

.send-btn:hover {
  background: var(--primary-hover);
  transform: scale(1.05);
}

.send-btn:disabled {
  background: var(--bg-secondary);
  color: var(--text-tertiary);
  cursor: not-allowed;
  transform: none;
}

/* Stats Tab */
.stats-container {
  padding-bottom: 2rem;
}

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

.stats-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

.time-filter {
  display: flex;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  padding: 0.25rem;
}

.filter-btn {
  padding: 0.5rem 1rem;
  background: none;
  border: none;
  border-radius: var(--border-radius-small);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-light);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-light);
  border: 1px solid var(--border-color);
  text-align: center;
  transition: all var(--transition-medium);
}

.stat-card h3 {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-tertiary);
  margin-bottom: 0.5rem;
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 0.25rem;
}

.stat-unit {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.stat-trend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--success-color);
  margin-top: 0.5rem;
}

.chart-container,
.weight-chart-container,
.health-chart-container {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-light);
  border: 1px solid var(--border-color);
  margin-bottom: 2rem;
  transition: all var(--transition-medium);
}

.chart-container h3,
.weight-chart-container h3,
.health-chart-container h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.chart-legend {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--border-radius-large);
  width: 100%;
  max-width: 400px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-heavy);
  animation: slideUp 0.3s ease;
  transition: all var(--transition-medium);
}

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

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* Settings */
.settings-content {
  padding: 1.5rem;
}

.setting-group {
  margin-bottom: 2rem;
}

.setting-group:last-child {
  margin-bottom: 0;
}

.setting-group h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-color);
}

.setting-item:last-child {
  border-bottom: none;
}

.setting-item label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}

.toggle-switch {
  position: relative;
  width: 50px;
  height: 28px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  transition: 0.3s;
  border-radius: 14px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

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

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

select,
input[type="number"] {
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-small);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: all var(--transition-medium);
}

select:focus,
input[type="number"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

/* Note Modal */
.note-content {
  padding: 1.5rem;
}

.note-content textarea {
  width: 100%;
  padding: 0.875rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
  transition: all var(--transition-medium);
}

.note-content textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.note-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
  justify-content: flex-end;
}

/* Clarification Modal */
.clarification-content {
  padding: 1.5rem;
}

.clarification-question {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  text-align: center;
}

.clarification-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.clarification-btn {
  padding: 0.875rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
}

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

.clarification-input {
  width: 100%;
  padding: 0.875rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  transition: all var(--transition-medium);
}

.clarification-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1rem 1.5rem;
  box-shadow: var(--shadow-medium);
  min-width: 300px;
  animation: slideInRight 0.3s ease;
  position: relative;
  transition: all var(--transition-medium);
}

.toast.success {
  border-left: 4px solid var(--success-color);
}

.toast.error {
  border-left: 4px solid var(--danger-color);
}

.toast.warning {
  border-left: 4px solid var(--warning-color);
}

.toast-message {
  font-size: 0.875rem;
  color: var(--text-primary);
  font-weight: 500;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

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

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

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes bounce {
  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

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

@keyframes typing {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Responsive Design */
@media (max-width: 480px) {
  .tab-pane {
    padding: 1rem;
  }

  .summary-card {
    padding: 1.5rem;
  }

  .calorie-sections {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .quick-stats {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .clarification-options {
    grid-template-columns: 1fr;
  }

  .camera-controls {
    flex-direction: column;
  }

  .toast-container {
    left: 1rem;
    right: 1rem;
  }

  .toast {
    min-width: auto;
  }

  .composition-chart {
    flex-direction: column;
    gap: 1rem;
  }

  .chart-legend {
    justify-content: flex-start;
  }
}

/* iOS Safari Specific */
@supports (-webkit-touch-callout: none) {
  .main-app {
    min-height: -webkit-fill-available;
  }

  .chat-container {
    height: calc(-webkit-fill-available - 200px);
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles for keyboard navigation */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border-color: #000000;
    --shadow-light: 0 2px 10px rgba(0, 0, 0, 0.3);
    --shadow-medium: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-heavy: 0 8px 30px rgba(0, 0, 0, 0.5);
  }

  [data-theme="dark"] {
    --border-color: #ffffff;
  }
}

.meal-items-detail {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 0.25rem;
  font-style: italic;
}

.meal-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  position: relative;
}

.delete-meal-btn {
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--danger-color);
  color: white;
  border: none;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all var(--transition-fast);
}

.meal-item:hover .delete-meal-btn {
  opacity: 1;
}

.delete-meal-btn:hover {
  background: #e6342a;
  transform: scale(1.1);
}

.calculator-content {
  padding: 1.5rem;
}

.calc-input-group {
  margin-bottom: 1rem;
}

.calc-input-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.calc-input-group input,
.calc-input-group select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-small);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: all var(--transition-medium);
}

.calc-input-group input:focus,
.calc-input-group select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.calc-results {
  margin-top: 2rem;
  padding: 1.5rem;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
}

.calc-results h4 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.875rem;
}

.result-item:last-of-type {
  border-bottom: none;
  font-weight: 600;
  color: var(--primary-color);
}

.result-item span:first-child {
  color: var(--text-secondary);
}

.result-item span:last-child {
  font-weight: 600;
  color: var(--text-primary);
}

.health-score-tooltip {
  position: relative;
  cursor: help;
}

.health-score-tooltip:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: var(--bg-primary);
  padding: 0.5rem;
  border-radius: var(--border-radius-small);
  font-size: 0.75rem;
  white-space: nowrap;
  z-index: 1000;
  margin-bottom: 0.25rem;
}
