/* ── FOOD DETAIL AI MODAL ── */
:root {
  --fd-ring-bg: rgba(0,0,0,0.08);
  --fd-ring-color: #22c55e;
  --fd-good: #22c55e;
  --fd-moderate: #f59e0b;
  --fd-low: #ef4444;
  --fd-overlay-bg: rgba(0,0,0,0.55);
}
body.dark {
  --fd-ring-bg: rgba(255,255,255,0.1);
  --fd-overlay-bg: rgba(0,0,0,0.75);
}

/* Overlay */
.fd-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: var(--fd-overlay-bg);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fd-fade-in 0.2s ease;
}
@keyframes fd-fade-in { from { opacity:0 } to { opacity:1 } }

/* Modal sheet */
.fd-modal {
  width: 100%;
  max-width: 480px;
  max-height: 92dvh;
  border-radius: 28px 28px 0 0;
  background: var(--card-bg, #fff);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fd-slide-up 0.32s cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: 0 -8px 40px rgba(0,0,0,0.18);
}
@keyframes fd-slide-up {
  from { transform: translateY(100%) }
  to   { transform: translateY(0) }
}

/* Header */
.fd-modal-header {
  padding: 1.1rem 1.2rem 0.8rem;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  background: linear-gradient(135deg, rgba(99,102,241,0.08) 0%, rgba(16,185,129,0.05) 100%);
  flex-shrink: 0;
}
.fd-close-btn {
  position: absolute;
  top: 0.9rem; right: 1.1rem;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--border-color, #e5e7eb);
  color: var(--text-secondary, #6b7280);
  font-size: 1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, transform 0.15s;
  z-index: 10;
}
.fd-close-btn:hover { background: var(--accent-red, #ef4444); color:#fff; transform: scale(1.1); }

.fd-modal { position: relative; }

.fd-header-content {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 0.85rem;
}
.fd-food-emoji {
  font-size: 2.6rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}
.fd-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary, #111);
  margin: 0 0 0.15rem;
  line-height: 1.25;
}
.fd-subtitle {
  font-size: 0.78rem;
  color: var(--text-secondary, #6b7280);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.fd-subtitle::before { content: '✨'; font-size: 0.8rem; }

/* Health Score Row */
.fd-health-score-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg, rgba(255,255,255,0.5));
  border-radius: 14px;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border-color, #e5e7eb);
}
.fd-score-ring {
  position: relative;
  width: 56px; height: 56px;
  flex-shrink: 0;
}
.fd-score-ring svg { width: 100%; height: 100%; }
.fd-score-val {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
}
.fd-score-labels {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.fd-score-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.fd-health-badge {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.15rem 0.6rem;
  border-radius: 20px;
  display: inline-block;
}
.fd-health-badge.excellent { background: #dcfce7; color: #16a34a; }
.fd-health-badge.good      { background: #d1fae5; color: #059669; }
.fd-health-badge.moderate  { background: #fef3c7; color: #d97706; }
.fd-health-badge.poor      { background: #fee2e2; color: #dc2626; }

/* Body scroll area */
.fd-body {
  overflow-y: auto;
  flex: 1;
  padding: 1rem 1.2rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
.fd-body::-webkit-scrollbar { width: 4px; }
.fd-body::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

/* Loading */
.fd-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  padding: 3rem 1rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.fd-spinner {
  width: 38px; height: 38px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-teal, #14b8a6);
  border-radius: 50%;
  animation: fd-spin 0.75s linear infinite;
}
@keyframes fd-spin { to { transform: rotate(360deg) } }

/* Summary */
.fd-summary {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.65;
  background: rgba(99,102,241,0.05);
  border-left: 3px solid #6366f1;
  border-radius: 0 10px 10px 0;
  padding: 0.7rem 0.9rem;
}

/* Section heading */
.fd-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin: 0 0 0.5rem;
  display: flex; align-items: center; gap: 0.4rem;
}

/* Risk / Benefits chips */
.fd-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.fd-chip {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.7rem;
  border-radius: 20px;
  line-height: 1.4;
}
.fd-chip.risk    { background: #fee2e2; color: #b91c1c; }
.fd-chip.benefit { background: #dcfce7; color: #15803d; }

/* Nutrient Tables */
.fd-table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border-color, #e5e7eb);
}
.fd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.fd-table thead tr {
  background: linear-gradient(90deg, rgba(99,102,241,0.1), rgba(16,185,129,0.08));
}
.fd-table th {
  padding: 0.5rem 0.7rem;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  white-space: nowrap;
}
.fd-table td {
  padding: 0.48rem 0.7rem;
  border-top: 1px solid var(--border-color, #e5e7eb);
  color: var(--text-primary);
  vertical-align: middle;
}
.fd-table tr:hover td { background: rgba(99,102,241,0.04); }
.fd-table .fd-dv-bar {
  display: flex; align-items: center; gap: 0.4rem;
}
.fd-dv-pill {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 10px;
  background: rgba(99,102,241,0.12);
  color: #6366f1;
  white-space: nowrap;
}
.fd-note { font-size: 0.72rem; color: var(--text-secondary); }

/* Micro status dot */
.fd-status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 0.3rem;
}
.fd-status-dot.good     { background: var(--fd-good); }
.fd-status-dot.moderate { background: var(--fd-moderate); }
.fd-status-dot.low      { background: var(--fd-low); }

/* Recommendation */
.fd-recommendation {
  background: linear-gradient(135deg, rgba(20,184,166,0.1), rgba(99,102,241,0.08));
  border-radius: 12px;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--text-primary);
  line-height: 1.6;
  border: 1px solid rgba(20,184,166,0.2);
}
.fd-recommendation::before { content: '💡 '; }

/* Make meal items in list clickable */
.meal-header-row {
  cursor: pointer;
}
.meal-title {
  cursor: pointer;
  transition: color 0.15s;
}
.meal-title:hover { color: var(--accent-teal, #14b8a6); }

/* Tap hint on meal item */
.meal-tap-hint {
  font-size: 0.68rem;
  color: var(--text-secondary);
  opacity: 0.7;
  margin-top: 0.15rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
