/* Family Health Tracker — light, high-contrast, large-type UI. */

:root {
    --bg: #fafaf7;
    --card: #ffffff;
    --text: #1a1a1a;
    --muted: #52525b;
    --line: #d9d9d3;
    --accent: #1660a8;
    --accent-dark: #114b84;
    --accent-soft: #e8f1fa;
    --good: #1c7a3d;
    --good-soft: #e6f4ea;
    --warn: #9a6700;
    --warn-soft: #fff4d6;
    --bad: #b3261e;
    --bad-soft: #fbe9e7;
    --radius: 12px;
    --nav-h: 76px;
}

* { box-sizing: border-box; }

html { font-size: 19px; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

/* ---------- Header & navigation ---------- */

.app-header { background: var(--accent); color: #fff; }
.app-header-inner {
    max-width: 1000px; margin: 0 auto; padding: 0.6rem 1rem;
    display: flex; justify-content: space-between; align-items: center;
}
.app-brand { font-weight: 700; font-size: 1.1rem; }
.app-user { font-size: 0.95rem; }

.app-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: var(--card); border-top: 2px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
}
.app-nav-inner {
    max-width: 1000px; margin: 0 auto;
    display: flex; justify-content: space-around;
}
.nav-tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 0.5rem 0.25rem; min-height: var(--nav-h);
    justify-content: center;
    color: var(--muted); text-decoration: none;
    font-size: 0.8rem; font-weight: 600;
}
.nav-tab svg { width: 28px; height: 28px; }
.nav-tab.active { color: var(--accent); }
.nav-tab:hover { color: var(--accent-dark); }

.app-main {
    max-width: 1000px; margin: 0 auto;
    padding: 1rem 1rem calc(var(--nav-h) + 2rem);
}

@media (min-width: 800px) {
    .app-nav { position: sticky; top: 0; bottom: auto; border-top: 0; border-bottom: 2px solid var(--line); }
    .nav-tab { flex-direction: row; gap: 8px; min-height: 56px; font-size: 1rem; }
    .nav-tab svg { width: 24px; height: 24px; }
    .app-main { padding-bottom: 3rem; }
}

.page-title { font-size: 1.5rem; margin: 0.5rem 0 1rem; }

/* ---------- Cards ---------- */

.card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 1.1rem; margin-bottom: 1rem;
}
.card h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }
.card-grid { display: grid; gap: 1rem; }
@media (min-width: 800px) { .card-grid.two { grid-template-columns: 1fr 1fr; } }

.stat-number { font-size: 2.3rem; font-weight: 700; line-height: 1.15; }
.stat-label { color: var(--muted); font-size: 0.9rem; }
.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.stat-row > div { flex: 1; min-width: 130px; }

/* ---------- Forms ---------- */

label, .field-label {
    display: block; font-weight: 600; margin-bottom: 0.3rem; font-size: 0.95rem;
}
.field { margin-bottom: 1rem; }
.hint { color: var(--muted); font-size: 0.85rem; margin-top: 0.25rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="time"], select, textarea {
    width: 100%; font-size: 1.05rem; font-family: inherit;
    padding: 0.7rem 0.8rem; min-height: 52px;
    border: 2px solid var(--line); border-radius: 10px;
    background: #fff; color: var(--text);
}
textarea { min-height: 100px; resize: vertical; }

input:focus, select:focus, textarea:focus, button:focus, a:focus, summary:focus {
    outline: 3px solid var(--accent); outline-offset: 2px;
}

.form-row { display: flex; gap: 0.8rem; flex-wrap: wrap; }
.form-row .field { flex: 1; min-width: 140px; }
form.narrow, .narrow { max-width: 640px; }

/* Number stepper: big − / + buttons flanking the input */
.stepper { display: flex; align-items: stretch; gap: 0.4rem; }
.stepper input { text-align: center; flex: 1; min-width: 90px; }
.stepper button {
    width: 56px; min-height: 52px; font-size: 1.6rem; font-weight: 700;
    border: 2px solid var(--line); border-radius: 10px;
    background: var(--accent-soft); color: var(--accent-dark); cursor: pointer;
}
.stepper button:active { background: var(--accent); color: #fff; }

/* Segmented 1–10 rating buttons (replaces sliders) */
.segmented { display: flex; gap: 4px; flex-wrap: wrap; }
.segmented label {
    flex: 1; min-width: 44px; margin: 0;
}
.segmented input[type="radio"] { position: absolute; opacity: 0; width: 0; height: 0; }
.segmented span {
    display: flex; align-items: center; justify-content: center;
    min-height: 48px; border: 2px solid var(--line); border-radius: 8px;
    font-weight: 600; cursor: pointer; background: #fff;
}
.segmented input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.segmented input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Password field with eyeball toggle */
.password-wrap { position: relative; }
.password-wrap input { padding-right: 60px; }
.password-toggle {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    width: 48px; height: 44px; border: 0; background: transparent;
    cursor: pointer; color: var(--muted); border-radius: 8px;
}
.password-toggle:hover { color: var(--accent); }
.password-toggle svg { width: 26px; height: 26px; }

/* Collapsible optional sections */
details.section {
    border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--card); margin-bottom: 0.8rem;
}
details.section summary {
    cursor: pointer; font-weight: 600; padding: 0.9rem 1rem;
    list-style: none; display: flex; justify-content: space-between; align-items: center;
    min-height: 56px; font-size: 1.02rem;
}
details.section summary::-webkit-details-marker { display: none; }
details.section summary::after { content: "▸"; color: var(--muted); font-size: 1.1rem; }
details.section[open] summary::after { content: "▾"; }
details.section .section-body { padding: 0 1rem 1rem; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    font-size: 1.1rem; font-weight: 700; font-family: inherit;
    min-height: 56px; padding: 0.6rem 1.4rem;
    border-radius: 12px; border: 2px solid transparent;
    cursor: pointer; text-decoration: none; text-align: center;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: #fff; color: var(--accent-dark); border-color: var(--accent); }
.btn-secondary:hover { background: var(--accent-soft); }
.btn-danger { background: #fff; color: var(--bad); border-color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-block { display: flex; width: 100%; }
.btn-small { min-height: 44px; font-size: 0.95rem; padding: 0.35rem 0.9rem; }

.btn-row { display: flex; gap: 0.8rem; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

/* Big "+ Log" launcher buttons on the dashboard */
.launcher-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.launcher {
    display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
    padding: 1rem 0.5rem; min-height: 92px; justify-content: center;
    background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
    text-decoration: none; color: var(--text); font-weight: 700; font-size: 1.02rem;
}
.launcher:hover { border-color: var(--accent); background: var(--accent-soft); }
.launcher .emoji { font-size: 1.7rem; }

/* Favorites / quick-pick chips */
.chips { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.chip {
    border: 2px solid var(--line); border-radius: 999px; background: #fff;
    padding: 0.45rem 1rem; min-height: 48px; font-size: 0.98rem; font-weight: 600;
    cursor: pointer; font-family: inherit; color: var(--text);
    display: inline-flex; align-items: center;
}
.chip:hover { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- Flash messages ---------- */

.flash {
    padding: 0.9rem 1rem; border-radius: 10px; margin-bottom: 1rem;
    font-weight: 600; border: 2px solid;
}
.flash-success { background: var(--good-soft); color: var(--good); border-color: var(--good); }
.flash-error { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }

/* ---------- Progress bar (goal card) ---------- */

.progress-track {
    background: var(--line); border-radius: 999px; height: 22px; overflow: hidden;
}
.progress-fill {
    background: var(--good); height: 100%; border-radius: 999px;
    min-width: 8px; transition: width 0.4s;
}
.goal-points { display: flex; justify-content: space-between; margin-top: 0.4rem; font-size: 0.9rem; color: var(--muted); }

/* ---------- Status badges (BP category etc.) ---------- */

.badge {
    display: inline-block; padding: 0.15rem 0.7rem; border-radius: 999px;
    font-size: 0.85rem; font-weight: 700;
}
.badge-good { background: var(--good-soft); color: var(--good); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-muted { background: var(--accent-soft); color: var(--accent-dark); }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }
table.data {
    width: 100%; border-collapse: collapse; background: var(--card);
    border: 1px solid var(--line); border-radius: var(--radius);
    font-size: 0.98rem;
}
table.data th, table.data td {
    padding: 0.7rem 0.8rem; text-align: left; border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
table.data th { background: var(--accent-soft); color: var(--accent-dark); font-size: 0.9rem; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.wrap { white-space: normal; min-width: 200px; }

/* ---------- Lists ---------- */

.list-item {
    display: flex; justify-content: space-between; align-items: center; gap: 0.8rem;
    padding: 0.9rem 0; border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 700; }
.list-item .sub { color: var(--muted); font-size: 0.9rem; }

/* "More" menu */
.menu-link {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1rem 1.1rem; margin-bottom: 0.7rem; min-height: 64px;
    text-decoration: none; color: var(--text); font-weight: 700; font-size: 1.05rem;
}
.menu-link:hover { border-color: var(--accent); background: var(--accent-soft); }
.menu-link::after { content: "›"; color: var(--muted); font-size: 1.5rem; }

/* ---------- Login ---------- */

.login-wrap { max-width: 440px; margin: 8vh auto 0; }
.login-brand { text-align: center; font-size: 1.6rem; font-weight: 800; color: var(--accent-dark); margin-bottom: 1.2rem; }

/* Checkbox row */
.check-row { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 1rem; }
.check-row input[type="checkbox"] { width: 26px; height: 26px; accent-color: var(--accent); }
.check-row label { margin: 0; font-weight: 600; }

/* Chart range toggles */
.range-toggle { display: flex; gap: 0.5rem; margin-bottom: 0.8rem; }
.range-toggle button {
    flex: 1; min-height: 48px; font-size: 0.95rem; font-weight: 700; font-family: inherit;
    border: 2px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; color: var(--text);
}
.range-toggle button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.chart-box { position: relative; width: 100%; height: 320px; }

.muted { color: var(--muted); }
.center { text-align: center; }
.mt { margin-top: 1rem; }
.mb0 { margin-bottom: 0; }

/* Day navigation (meals) */
.day-nav { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin-bottom: 1rem; }
.day-nav .day-label { font-weight: 700; font-size: 1.05rem; text-align: center; flex: 1; }

/* ---------- Print (medical report) ---------- */

@media print {
    .app-nav, .app-header, .no-print, .btn { display: none !important; }
    body { background: #fff; }
    .app-main { padding: 0; max-width: none; }
    .card { border: 1px solid #999; break-inside: avoid; }
    html { font-size: 13px; }
}
