@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@500;600&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
  --amber-50:  #FFFBEB;
  --amber-100: #FEF3C7;
  --amber-200: #FCD34D;
  --amber-300: #F59E0B;
  --amber-400: #D97706;
  --green-50:  #ECFDF5;
  --green-100: #D1FAE5;
  --green-200: #6EE7B7;
  --green-400: #059669;
  --green-600: #065F46;
  --red-50:    #FEF2F2;
  --red-100:   #FEE2E2;
  --red-400:   #EF4444;
  --red-600:   #991B1B;
  --slate-50:  #F8FAFC;
  --slate-100: #F1F5F9;
  --slate-200: #E2E8F0;
  --slate-400: #94A3B8;
  --slate-600: #475569;
  --slate-800: #1E293B;
  --slate-900: #0F172A;

  --bg:        #FFFDF7;
  --surface:   #FFFFFF;
  --surface2:  #FEF9EE;
  --border:    #F0E8D0;
  --text:      #1E293B;
  --muted:     #64748B;
  --hint:      #94A3B8;

  --accent:    #F59E0B;
  --accent-dk: #D97706;
  --safe:      #059669;
  --caution:   #D97706;
  --avoid:     #DC2626;

  --radius-sm: 10px;
  --radius:    16px;
  --radius-lg: 24px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 4px 16px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { font-size: 16px; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Screens ─────────────────────────────── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

.screen-inner {
  flex: 1;
  max-width: 440px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px 40px;
}

/* ── Splash / decorative header ─────────── */
.app-hero {
  background: linear-gradient(160deg, var(--amber-300) 0%, var(--amber-400) 100%);
  padding: 48px 24px 36px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.app-hero::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 180px; height: 180px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
}

.app-hero::after {
  content: '';
  position: absolute;
  bottom: -60px; left: -30px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
}

.logo-lockup {
  position: relative;
  z-index: 1;
}

.logo-icon {
  width: 64px;
  height: 64px;
  background: rgba(255,255,255,0.95);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.logo-icon svg {
  width: 36px;
  height: 36px;
}

.app-name {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 600;
  color: #FFFFFF;
  letter-spacing: -0.5px;
  line-height: 1;
  margin-bottom: 6px;
}

.app-tagline {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.85);
  font-weight: 400;
}

/* ── Compact header (scan/results screens) ─ */
.app-header {
  background: var(--amber-300);
  padding: 16px 20px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 100%;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-icon {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.9);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-icon svg { width: 20px; height: 20px; }

.header-name {
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  font-weight: 600;
  color: #FFFFFF;
}

.btn-settings {
  background: rgba(255,255,255,0.25);
  border: none;
  border-radius: 10px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-settings:active { background: rgba(255,255,255,0.4); }
.btn-settings svg { width: 18px; height: 18px; color: white; }

/* ── Profile badge strip ─────────────────── */
.profile-strip {
  background: var(--amber-100);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.profile-pill {
  background: var(--amber-300);
  color: var(--slate-800);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.profile-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-left: auto;
  cursor: pointer;
  font-weight: 500;
}

/* ── Section headings ────────────────────── */
.section-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.section-sub {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 20px;
}

/* ── Cards ───────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

/* ── Profile form ────────────────────────── */
.profile-content { padding-top: 24px; }

.field-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.field-group-label {
  padding: 12px 16px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent-dk);
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

/* ── Dietary code cards ──────────────────── */
.diet-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
}

.diet-card {
  position: relative;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 12px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.diet-card input { display: none; }

.diet-card-icon {
  font-size: 2rem;
  line-height: 1;
}

.diet-card-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.diet-card-tick {
  position: absolute;
  top: 8px; right: 8px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--border);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}

.diet-card-tick svg { width: 10px; height: 10px; opacity: 0; transition: opacity 0.15s; }

.diet-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--amber-50);
  box-shadow: 0 0 0 3px rgba(245,158,11,0.15);
}

.diet-card:has(input:checked) .diet-card-tick {
  background: var(--accent);
}

.diet-card:has(input:checked) .diet-card-tick svg { opacity: 1; }

.diet-card:active { opacity: 0.8; }

.diet-hint {
  padding: 0 12px 12px;
  font-size: 0.78rem;
  color: var(--hint);
  text-align: center;
}

/* ── Life stage rows ─────────────────────── */
.stage-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  gap: 14px;
  transition: background 0.15s;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.stage-row:last-child { border-bottom: none; }

.stage-row input { display: none; }

.stage-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--slate-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
  transition: background 0.2s;
}

.stage-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.stage-name {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
}

.stage-sub {
  font-size: 0.78rem;
  color: var(--hint);
}

.stage-dot {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}

.stage-dot::after {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: white;
  opacity: 0;
  transition: opacity 0.15s;
}

.stage-row:has(input:checked) {
  background: var(--amber-50);
}

.stage-row:has(input:checked) .stage-icon {
  background: var(--amber-100);
}

.stage-row:has(input:checked) .stage-dot {
  border-color: var(--accent);
  background: var(--accent);
}

.stage-row:has(input:checked) .stage-dot::after { opacity: 1; }

.stage-row:active { background: var(--surface2); }

/* ── Buttons ─────────────────────────────── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px 20px;
  border: none;
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  margin-bottom: 10px;
}

.btn-primary {
  background: var(--accent);
  color: var(--slate-900);
  box-shadow: 0 4px 12px rgba(245,158,11,0.4);
}

.btn-primary:active {
  transform: scale(0.98);
  box-shadow: 0 2px 6px rgba(245,158,11,0.3);
}

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

.btn-secondary:active { background: var(--surface2); }

.btn svg { width: 20px; height: 20px; flex-shrink: 0; }

/* ── Scan screen ─────────────────────────── */
.scan-content { padding-top: 24px; }

.scan-zone {
  background: var(--surface);
  border: 2px dashed var(--amber-200);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

.scan-zone-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, var(--amber-50) 0%, transparent 70%);
}

.scan-zone-icon {
  width: 72px;
  height: 72px;
  background: var(--amber-100);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  position: relative;
  z-index: 1;
}

.scan-zone-icon svg { width: 36px; height: 36px; color: var(--accent-dk); }

.scan-zone p {
  font-size: 0.9rem;
  color: var(--muted);
  position: relative;
  z-index: 1;
  margin-bottom: 20px;
}

.scan-zone-btns { position: relative; z-index: 1; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--hint);
  font-size: 0.8rem;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Preview ─────────────────────────────── */
#preview-container { animation: fadeIn 0.3s ease; }

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

.preview-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

#preview-image {
  width: 100%;
  display: block;
  max-height: 300px;
  object-fit: cover;
}

.preview-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 32px 16px 16px;
  background: linear-gradient(transparent, rgba(0,0,0,0.5));
  display: flex;
  gap: 8px;
}

/* ── Loading screen ──────────────────────── */
#screen-loading {
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 24px;
  background: var(--bg);
}

.loading-inner { display: flex; flex-direction: column; align-items: center; gap: 24px; }

.loading-ring {
  width: 72px;
  height: 72px;
  border: 4px solid var(--amber-100);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

.loading-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.loading-dots span {
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 1.4s ease infinite;
}

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

@keyframes pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }

.loading-label {
  font-size: 1rem;
  color: var(--muted);
  font-weight: 400;
}

/* ── Results screen ──────────────────────── */
.results-content { padding-top: 0; }

.verdict-hero {
  padding: 28px 20px;
  text-align: center;
  position: relative;
}

.verdict-hero.safe    { background: linear-gradient(160deg, var(--green-50), var(--green-100)); border-bottom: 1px solid var(--green-200); }
.verdict-hero.caution { background: linear-gradient(160deg, var(--amber-50), var(--amber-100)); border-bottom: 1px solid var(--amber-200); }
.verdict-hero.avoid   { background: linear-gradient(160deg, var(--red-50), var(--red-100)); border-bottom: 1px solid #FCA5A5; }
.verdict-hero.unknown { background: var(--surface2); border-bottom: 1px solid var(--border); }

.verdict-badge {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.verdict-hero.safe    .verdict-badge { background: var(--safe); }
.verdict-hero.caution .verdict-badge { background: var(--caution); }
.verdict-hero.avoid   .verdict-badge { background: var(--avoid); }
.verdict-hero.unknown .verdict-badge { background: var(--slate-400); }

.verdict-badge svg { width: 36px; height: 36px; color: white; }

.verdict-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.verdict-hero.safe    .verdict-title { color: var(--green-600); }
.verdict-hero.caution .verdict-title { color: var(--amber-400); }
.verdict-hero.avoid   .verdict-title { color: var(--avoid); }
.verdict-hero.unknown .verdict-title { color: var(--slate-600); }

.verdict-reason {
  font-size: 0.9rem;
  color: var(--muted);
  max-width: 300px;
  margin: 0 auto;
  line-height: 1.5;
}

/* ── Results sections ────────────────────── */
.results-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.result-card-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.result-card-header svg { width: 16px; height: 16px; flex-shrink: 0; }
.result-card-header span {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.flagged-card .result-card-header { color: var(--avoid); }
.safe-card .result-card-header    { color: var(--safe); }
.info-card .result-card-header    { color: var(--accent-dk); }

.flagged-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

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

.flagged-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.flagged-name { font-weight: 600; font-size: 0.95rem; color: var(--text); }

.severity-pill {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.severity-avoid   { background: var(--red-100);   color: var(--red-600); }
.severity-caution { background: var(--amber-100);  color: var(--amber-400); }
.severity-info    { background: var(--green-100);  color: var(--green-600); }

.flagged-full-name { font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; }
.flagged-issue     { font-size: 0.875rem; color: var(--slate-600); line-height: 1.5; }

.safe-list {
  padding: 14px 16px;
  font-size: 0.875rem;
  color: var(--slate-600);
  line-height: 1.6;
}

.info-text {
  padding: 14px 16px;
  font-size: 0.875rem;
  color: var(--slate-600);
  line-height: 1.6;
}

.result-actions { padding: 0 20px 32px; }

/* ── Disclaimer ──────────────────────────── */
.disclaimer-notice {
  background: var(--amber-50);
  border: 1px solid var(--amber-200);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 20px;
}

.disclaimer-notice svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--caution);
  margin-top: 1px;
}

.disclaimer-notice p {
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.5;
}

.disclaimer-inline {
  font-size: 0.72rem;
  color: var(--hint);
  text-align: center;
  padding: 0 20px 12px;
  line-height: 1.5;
}

/* ── Footer ──────────────────────────────── */
.app-footer {
  border-top: 1px solid var(--border);
  padding: 14px 20px 20px;
  text-align: center;
  margin-top: auto;
}

.footer-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 5px;
}

.footer-nav a {
  font-size: 0.76rem;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
}

.footer-nav a:hover { text-decoration: underline; }

.footer-dot { color: var(--hint); font-size: 0.76rem; }

.footer-copy {
  font-size: 0.7rem;
  color: var(--hint);
}

/* ── Utilities ───────────────────────────── */
.hidden { display: none !important; }

.label-file-input { display: none; }

.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
