/* Food Tracker — dark mobile-first theme */

:root {
    --bg-root: #080808;
    --bg-app: #0C0C0C;
    --card: #141414;
    --surface: #1A1A1A;
    --line: #1C1C1C;
    --rim: #222222;
    --bright: #FAFAFA;
    --mid: #666666;
    --sub: #555555;
    --muted: #444444;
    --faint: #333333;
    --accent: #4ADE80;
    --danger: #F87171;
    --c-protein: #60A5FA;
    --c-carbs: #FB923C;
    --c-fat: #FBBF24;
    --c-fiber: #A78BFA;
    --c-sugar: #F472B6;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
    background: var(--bg-root);
    color: var(--bright);
    font-family: "DM Sans", system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    line-height: 1.4;
}

a { color: inherit; text-decoration: none; }

::-webkit-scrollbar { width: 0; height: 0; }

input, button, textarea, select {
    font-family: inherit;
    color: var(--bright);
    background: transparent;
    border: none;
    outline: none;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* ---- App shell ---- */
.app {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--bg-app);
    position: relative;
}
.screen {
    padding: 56px 20px 96px;
    display: flex;
    flex-direction: column;
}
.screen.pad-tight { padding-left: 16px; padding-right: 16px; }

/* ---- Screen header ---- */
.scr-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 0 4px; margin-bottom: 22px; }
.scr-date { font-size: 11px; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; color: var(--sub); }
.scr-title { font-size: 30px; font-weight: 800; letter-spacing: -0.8px; margin-top: 2px; }
.scr-sub { font-size: 13px; color: var(--sub); margin-top: 4px; }

/* Dashboard toggle: chevron beside the title that swaps Nutrition <-> Exercise */
.title-row { display: flex; align-items: center; gap: 10px; }
.dash-swap {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 99px; flex: none;
    background: var(--card); border: 1px solid var(--rim); color: var(--accent);
    font-size: 22px; font-weight: 700; line-height: 1; text-decoration: none; margin-top: 2px;
}
.dash-swap:hover { background: #131313; }

.cal-pill {
    font-size: 12px; font-weight: 700; padding: 6px 12px; border-radius: 99px;
    background: rgba(74, 222, 128, 0.10); color: var(--accent); white-space: nowrap;
}
.cal-pill.over { background: rgba(248, 113, 113, 0.10); color: var(--danger); }

/* ---- Calorie ring ---- */
.ring-row { display: flex; align-items: center; justify-content: center; gap: 20px; margin-bottom: 26px; }
.ring-wrap { position: relative; width: 160px; height: 160px; flex: none; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-num { font-size: 38px; font-weight: 800; letter-spacing: -2px; line-height: 1; }
.ring-cap { font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--sub); margin-top: 4px; }
.ring-sub { font-size: 11px; color: var(--muted); margin-top: 6px; }

.side-macros { display: flex; flex-direction: column; gap: 9px; }
.smacro { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.smacro-dot { width: 7px; height: 7px; border-radius: 99px; flex: none; }
.smacro-name { color: var(--sub); width: 48px; }
.smacro-val { color: var(--bright); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- Macro bars ---- */
.bars { display: flex; flex-direction: column; gap: 7px; margin-bottom: 20px; }
.bar-row .bar-top { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 5px; }
.bar-label { font-weight: 600; letter-spacing: 0.3px; }
.bar-val { color: var(--sub); font-variant-numeric: tabular-nums; }
.bar { height: 4px; background: var(--surface); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; transition: width 0.9s cubic-bezier(0.4, 0, 0.2, 1); }

.divider { height: 1px; background: #161616; margin: 6px 0 18px; }
.sect-label { font-size: 11px; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; color: var(--sub); margin-bottom: 12px; padding: 0 4px; }

/* ---- Meal cards ---- */
.meals { display: flex; flex-direction: column; gap: 8px; }
.meal-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.meal-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px; cursor: pointer; }
.meal-emoji { font-size: 20px; }
.meal-name { font-size: 15px; font-weight: 600; }
.meal-meta { font-size: 11px; color: var(--muted); margin-left: 2px; }
.meal-spacer { flex: 1; }
.meal-add {
    width: 28px; height: 28px; border-radius: 99px; display: flex; align-items: center; justify-content: center;
    background: rgba(74, 222, 128, 0.10); color: var(--accent); font-size: 18px; font-weight: 700; flex: none;
}
.chev { color: var(--faint); transition: transform 0.2s; display: flex; }
.meal-card.open .chev { transform: rotate(180deg); }
.meal-body { border-top: 1px solid var(--line); padding: 4px 14px 8px; }
.meal-card:not(.open) .meal-body { display: none; }
.meal-empty { font-size: 12px; font-style: italic; color: var(--muted); padding: 12px 2px; }

.litem { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.litem:last-child { border-bottom: none; }
.litem-main { min-width: 0; flex: 1; }
.litem-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.litem-macros { font-size: 11px; color: var(--muted); margin-top: 3px; }
.litem-right { text-align: right; }
.litem-kcal { font-size: 14px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.litem-del {
    width: 26px; height: 26px; border-radius: 99px; display: flex; align-items: center; justify-content: center;
    color: var(--sub); font-size: 14px; flex: none; cursor: pointer;
}
.litem-del:active { color: var(--danger); }

/* ---- Cards / generic ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.card + .card { margin-top: 12px; }

/* ---- Forms ---- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase; color: var(--sub); margin-bottom: 7px; }
.input {
    width: 100%; background: var(--card); border: 1px solid var(--rim); border-radius: 12px;
    padding: 13px 14px; font-size: 15px; font-weight: 500;
}
.input:focus { border-color: rgba(74, 222, 128, 0.4); }
textarea.input { min-height: 64px; resize: vertical; }

.num-lg { font-size: 30px; font-weight: 800; letter-spacing: -1px; color: var(--accent); padding: 8px 14px; text-align: left; }
.num-md { font-size: 18px; font-weight: 700; padding: 10px 12px; }

.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.macro-lbl { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.5px; margin-bottom: 6px; }

/* ---- Meal picker pills ---- */
.meal-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.mpill {
    flex: 1; min-width: 0; text-align: center; padding: 11px 6px; border-radius: 99px;
    background: var(--card); border: 1px solid var(--rim); color: var(--sub);
    font-size: 12px; font-weight: 600; cursor: pointer;
}
.mpill.active { background: rgba(74, 222, 128, 0.12); color: var(--accent); border-color: rgba(74, 222, 128, 0.25); }

/* ---- Buttons ---- */
.btn-cta {
    display: block; width: 100%; text-align: center; padding: 15px; border-radius: 14px;
    background: var(--accent); color: #000; font-size: 16px; font-weight: 800; cursor: pointer; letter-spacing: -0.2px;
}
.btn-cta:active { opacity: 0.85; }
.btn-cta[disabled] { opacity: 0.5; }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 12px 16px; border-radius: 12px; background: var(--card); border: 1px solid var(--rim);
    color: var(--bright); font-size: 14px; font-weight: 600; cursor: pointer; width: 100%;
}
.btn-danger { color: var(--danger); border-color: rgba(248, 113, 113, 0.3); background: rgba(248, 113, 113, 0.06); }
.btn-sm { padding: 8px 12px; font-size: 13px; width: auto; }
.link { color: var(--accent); font-size: 13px; font-weight: 600; }

/* ---- AI search bar ---- */
.ai-bar { display: flex; gap: 8px; align-items: center; background: var(--card); border: 1px solid var(--rim); border-radius: 14px; padding: 6px 6px 6px 14px; }
.ai-bar .ai-input { flex: 1; font-size: 15px; padding: 8px 0; }
.ai-pill { padding: 9px 14px; border-radius: 10px; background: var(--accent); color: #000; font-size: 13px; font-weight: 700; cursor: pointer; flex: none; }
.ai-icon { width: 34px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--surface); color: var(--sub); cursor: pointer; flex: none; }
.ai-error { color: var(--danger); font-size: 12px; margin-top: 8px; }
.ai-note { color: var(--mid); font-size: 12px; margin-top: 8px; }
.spin { width: 15px; height: 15px; border: 2px solid rgba(0,0,0,0.25); border-top-color: #000; border-radius: 99px; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.or-divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 11px; letter-spacing: 0.5px; margin: 18px 0; }
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---- Saved-food search results ---- */
.food-results { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; max-height: 230px; overflow-y: auto; }
.food-opt { display: flex; justify-content: space-between; gap: 10px; padding: 11px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.food-opt:active { border-color: rgba(74,222,128,0.3); }
.food-opt .fo-name { font-size: 14px; font-weight: 600; }
.food-opt .fo-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.food-opt .fo-kcal { font-size: 13px; font-weight: 700; color: var(--accent); white-space: nowrap; }

/* ---- History ---- */
.hist-list { display: flex; flex-direction: column; gap: 8px; }
.hist-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: block; }
.hist-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.hist-date { font-size: 14px; font-weight: 600; }
.hist-macros { font-size: 12px; color: var(--muted); margin-top: 4px; }
.hist-kcal { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.hist-kcal small { font-size: 11px; font-weight: 600; color: var(--sub); display: block; text-align: right; }
.hist-barwrap { height: 3px; background: var(--surface); border-radius: 99px; overflow: hidden; margin-top: 11px; }
.hist-bar { height: 100%; border-radius: 99px; }

/* ---- Progress chart ---- */
.chart-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.chart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.chart-title { font-size: 13px; font-weight: 600; color: var(--mid); }
.chart-legend { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--sub); }
.chart-legend i { width: 14px; height: 0; border-top: 1px dashed rgba(74,222,128,0.5); display: inline-block; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.stat-label { font-size: 11px; font-weight: 600; letter-spacing: 0.8px; text-transform: uppercase; color: var(--sub); }
.stat-val { font-size: 26px; font-weight: 800; letter-spacing: -1px; margin-top: 6px; }
.stat-unit { font-size: 11px; color: var(--muted); font-weight: 500; margin-left: 3px; }

/* ---- Goals ---- */
.goal-cal { background: var(--card); border: 1.5px solid rgba(74, 222, 128, 0.18); border-radius: 16px; padding: 18px; margin-bottom: 12px; }
.goal-cal .glabel { font-size: 11px; font-weight: 600; letter-spacing: 0.8px; text-transform: uppercase; color: var(--accent); }
.goal-cal input { font-size: 42px; font-weight: 800; letter-spacing: -2px; color: var(--bright); width: 100%; padding: 6px 0 0; }
.goal-cal .gcap { font-size: 12px; color: var(--sub); }
.goal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.goal-cell { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.goal-cell .glabel { font-size: 11px; font-weight: 600; letter-spacing: 0.5px; }
.goal-cell input { font-size: 28px; font-weight: 800; letter-spacing: -1px; width: 100%; padding: 4px 0 0; }
.goal-cell .gcap { font-size: 11px; color: var(--muted); }

/* ---- Empty states ---- */
.empty { text-align: center; color: var(--muted); padding: 48px 20px; }
.empty .emoji { font-size: 52px; }
.empty h3 { font-size: 16px; color: var(--sub); margin-top: 16px; font-weight: 600; }
.empty p { font-size: 13px; margin-top: 6px; }

/* ---- Flash ---- */
.flash { padding: 12px 14px; border-radius: 12px; font-size: 13px; margin-bottom: 14px; }
.flash-success { background: rgba(74, 222, 128, 0.10); color: var(--accent); }
.flash-error { background: rgba(248, 113, 113, 0.10); color: var(--danger); }

/* ---- Date nav ---- */
.datenav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.datenav .d-label { font-weight: 700; font-size: 14px; text-align: center; flex: 1; }
.datenav .d-btn { width: 40px; height: 40px; border-radius: 99px; background: var(--card); border: 1px solid var(--rim); display: flex; align-items: center; justify-content: center; color: var(--sub); }

/* ---- Bottom tab bar ---- */
.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    max-width: 480px; margin: 0 auto;
    display: flex;
    background: rgba(10, 10, 10, 0.96);
    backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid #191919;
    padding-bottom: env(safe-area-inset-bottom, 8px);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 11px 0 7px; color: var(--faint); }
.tab.active { color: var(--accent); }
.tab-ico { display: flex; }
.tab-lbl { font-size: 9px; font-weight: 600; letter-spacing: 0.8px; text-transform: uppercase; }

/* ---- Auth ---- */
.auth-wrap { max-width: 380px; margin: 14vh auto 0; padding: 0 24px; }
.auth-logo { text-align: center; font-size: 30px; font-weight: 800; letter-spacing: -1px; }
.auth-logo span { color: var(--accent); }
.auth-sub { text-align: center; color: var(--sub); font-size: 13px; margin: 8px 0 28px; }

.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mb-0 { margin-bottom: 0; }
.muted { color: var(--muted); } .tnum { font-variant-numeric: tabular-nums; }

/* ============ Desktop / wide screens (responsive) ============ */
.nav-brand { display: none; }

@media (min-width: 820px) {
    /* Bottom tab bar -> left sidebar */
    .tabbar {
        top: 0; bottom: auto; left: 0; right: auto;
        width: 216px; height: 100vh; max-width: none; margin: 0;
        flex-direction: column; justify-content: flex-start; gap: 4px;
        background: #0A0A0A; border-top: none; border-right: 1px solid #191919;
        padding: 22px 14px; backdrop-filter: none; -webkit-backdrop-filter: none;
    }
    .nav-brand { display: block; font-size: 22px; font-weight: 800; letter-spacing: -0.5px; padding: 4px 12px 20px; }
    .nav-brand span { color: var(--accent); }
    .tab { flex: none; flex-direction: row; justify-content: flex-start; gap: 14px; padding: 12px 14px; border-radius: 12px; }
    .tab:hover { background: #131313; }
    .tab.active { background: rgba(74, 222, 128, 0.10); }
    .tab-ico svg { width: 20px; height: 20px; }
    .tab-lbl { font-size: 14px; font-weight: 600; letter-spacing: 0; text-transform: none; }

    /* Content sits to the right of the sidebar, wider and centered */
    .app--shell { max-width: none; margin: 0 0 0 216px; background: transparent; min-height: 100vh; }
    .app--shell .screen { max-width: 720px; margin: 0 auto; padding: 44px 36px 64px; }

    .scr-title { font-size: 34px; }

    /* Use the extra width: uniform card lists (History, Foods) go two-up */
    .hist-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
}

@media (min-width: 1240px) {
    .app--shell .screen { max-width: 820px; }
}
