/* ===== APP SHELL ===== */
.app-body {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== APP NAV ===== */
.app-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-nav .nav-logo {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -0.5px;
}

.app-nav .nav-logo span { color: var(--fg); }

.app-nav-links {
  display: flex;
  gap: 4px;
}

.app-nav-link {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--fg-muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.app-nav-link:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.app-nav-link.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

/* ===== APP LAYOUT ===== */
.app-layout {
  flex: 1;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  padding: 32px 24px;
}

/* ===== CHAT PAGE ===== */
.chat-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 73px);
}

.chat-page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
}

.chat-page-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--fg);
}

.chat-page-sub {
  font-size: 0.8rem;
  color: var(--fg-muted);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-input-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 16px 20px;
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.suggestion-chip {
  background: var(--accent-light);
  color: var(--accent);
  border: none;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  font-family: 'Plus Jakarta Sans', sans-serif;
  transition: background 0.15s;
}

.suggestion-chip:hover {
  background: #d0eddd;
}

.chat-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-textarea {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--fg);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
}

.chat-textarea:focus {
  border-color: var(--accent);
}

.send-btn {
  width: 44px;
  height: 44px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}

.send-btn:hover:not(:disabled) { background: var(--accent-glow); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Thinking animation */
.thinking {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 14px 18px;
}

.thinking span {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
  opacity: 0.6;
}

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

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ===== LOG PAGE ===== */
.log-page {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.log-header { margin-bottom: 4px; }
.log-title {
  font-family: 'Outfit', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}
.log-sub { color: var(--fg-muted); font-size: 1rem; }

.log-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}

.log-label {
  display: block;
  font-weight: 600;
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.log-textarea {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--fg);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.95rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

.log-textarea:focus { border-color: var(--accent); }

.log-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
  align-items: center;
}

.log-example-label {
  font-size: 0.8rem;
  color: var(--fg-muted);
  font-weight: 500;
}

.log-submit-btn {
  width: 100%;
  padding: 16px;
  font-size: 1rem;
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

/* Score result */
.log-result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}

.score-display {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 8px;
}

.score-ring {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 6px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.score-ring-good { border-color: var(--accent); }
.score-ring-ok { border-color: #6ab04c; }
.score-ring-fair { border-color: var(--warm); }
.score-ring-poor { border-color: #e55039; }

.score-big {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 2.2rem;
  line-height: 1;
  color: var(--fg);
}

.score-label-small {
  font-size: 0.75rem;
  color: var(--fg-muted);
}

.score-grade {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--fg);
  margin-bottom: 6px;
}

.score-desc { color: var(--fg-muted); font-size: 0.9rem; }

.analysis-text {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 0.95rem;
  color: var(--fg);
  line-height: 1.65;
  margin-bottom: 20px;
}

.log-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* Score colors */
.score-good { color: var(--accent); }
.score-ok   { color: #6ab04c; }
.score-fair { color: var(--warm); }
.score-poor { color: #e55039; }

.score-fill-good { background: linear-gradient(90deg, var(--accent), var(--accent-glow)); }
.score-fill-ok   { background: linear-gradient(90deg, #6ab04c, #82c341); }
.score-fill-fair { background: linear-gradient(90deg, var(--warm), #f0c040); }
.score-fill-poor { background: linear-gradient(90deg, #e55039, #c0392b); }

/* Recent meals */
.recent-meals-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 28px; }
.recent-title { font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 1.1rem; margin-bottom: 16px; }
.recent-list { display: flex; flex-direction: column; gap: 12px; }

.recent-meal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.recent-meal-item:last-child { border-bottom: none; }

.recent-meal-desc {
  font-size: 0.9rem;
  color: var(--fg);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}
.recent-meal-time { font-size: 0.78rem; color: var(--fg-muted); }

.recent-score {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.5rem;
  flex-shrink: 0;
  min-width: 44px;
  text-align: right;
}

/* ===== DASHBOARD ===== */
.dashboard-page { display: flex; flex-direction: column; gap: 24px; }
.dashboard-header { margin-bottom: 4px; }
.dashboard-title { font-family: 'Outfit', sans-serif; font-size: 2rem; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 8px; }
.dashboard-sub { color: var(--fg-muted); font-size: 1rem; }

.dash-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.dash-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}

.dash-stat-num {
  font-family: 'Outfit', sans-serif;
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -1px;
}

.dash-stat-label {
  font-size: 0.8rem;
  color: var(--fg-muted);
  margin-top: 4px;
  font-weight: 500;
}

.dash-chart-card, .dash-meals-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
}

.dash-card-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 20px;
}

.dash-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

/* Chart */
.chart-container { min-height: 60px; }

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.chart-bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 40px;
  flex: 1;
  max-width: 60px;
}

.chart-score-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--fg-muted);
  margin-bottom: 4px;
}

.chart-bar-wrap {
  display: flex;
  align-items: flex-end;
  width: 100%;
}

.chart-bar {
  width: 100%;
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.3s;
}

.chart-date-label {
  font-size: 0.68rem;
  color: var(--fg-muted);
  margin-top: 6px;
  white-space: nowrap;
}

/* Dashboard meal rows */
.dash-meal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.dash-meal-row:last-child { border-bottom: none; }

.dash-meal-desc {
  font-size: 0.9rem;
  color: var(--fg);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 380px;
}
.dash-meal-time { font-size: 0.78rem; color: var(--fg-muted); }

.dash-meal-score-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.dash-bar-mini {
  width: 80px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.dash-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s;
}

/* Empty state */
.empty-state {
  text-align: center;
  color: var(--fg-muted);
  font-size: 0.9rem;
  padding: 24px 0;
}
.empty-state a { color: var(--accent); }

/* ===== LOG TABS ===== */
.log-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.log-tab {
  flex: 1;
  padding: 10px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--fg-muted);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.log-tab.active {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

.log-tab:hover:not(.active) {
  border-color: var(--fg-muted);
  color: var(--fg);
}

/* ===== PHOTO UPLOAD ZONE ===== */
.photo-upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, background 0.2s;
  background: var(--bg);
}

.photo-upload-zone:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.photo-zone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  pointer-events: none;
}

.photo-zone-icon { font-size: 2.5rem; line-height: 1; }
.photo-zone-text { font-size: 0.95rem; font-weight: 600; color: var(--fg); }
.photo-zone-hint { font-size: 0.78rem; color: var(--fg-muted); }

/* Photo preview inside zone */
.photo-preview-wrap { width: 100%; position: relative; }

.photo-preview-img {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  display: block;
  border-radius: calc(var(--radius) - 2px);
}

.photo-remove-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  background: rgba(0,0,0,0.55);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.photo-remove-btn:hover { background: rgba(0,0,0,0.8); }

/* Analyzing state */
.photo-analyzing {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  color: var(--fg-muted);
  font-size: 0.9rem;
}
.photo-analyzing-text { font-weight: 500; color: var(--accent); }

/* Foods confirm panel */
.photo-confirm { margin-top: 16px; }
.photo-confirm-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}
.photo-foods-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }

.food-chip {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid transparent;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

/* Unclear fallback */
.photo-unclear { margin-top: 16px; }
.photo-unclear-msg {
  font-size: 0.9rem;
  color: var(--fg-muted);
  margin-bottom: 12px;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* Result card photo */
.result-photo-wrap {
  margin-bottom: 20px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.result-photo-img { width: 100%; max-height: 200px; object-fit: cover; display: block; }

/* Recent meal thumbnail */
.recent-meal-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .app-nav { padding: 14px 16px; }
  .app-nav-link { padding: 8px 10px; font-size: 0.82rem; }
  .app-layout { padding: 16px; }

  .dash-stats { grid-template-columns: 1fr 1fr; }
  .dash-stats .dash-stat:last-child { grid-column: span 2; }

  .recent-meal-desc, .dash-meal-desc { max-width: 200px; }

  .chat-page { height: calc(100vh - 65px); }
  .photo-zone-text { font-size: 0.88rem; }
}
