/* ============================================================
   FitApp — Bitácora de salud
   Sistema de diseño: un cuaderno de a bordo para tu progreso.
   Paleta: papel frío + tinta + latón (instrumentos náuticos),
   nada de crema/terracota genérico. Los números llevan mono
   tabular, como en un cuaderno de mediciones reales.
   ============================================================ */

:root {
    --paper: #EDF1EE;
    --paper-raised: #FAFCFA;
    --ink: #16232E;
    --ink-soft: #33454E;
    --slate: #5B6B73;
    --slate-faint: #A9B4B6;
    --teal: #1F4B4C;
    --teal-deep: #123233;
    --teal-mist: #DCE8E4;
    --brass: #B8863B;
    --brass-soft: #EADFC5;
    --brick: #C74B3F;
    --brick-soft: #F3DEDA;
    --rule: #C7D0C9;

    --font-display: "Newsreader", "Iowan Old Style", "Georgia", serif;
    --font-body: "Inter", -apple-system, "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, monospace;

    --radius: 10px;
    --shadow-card: 0 1px 2px rgba(22, 35, 46, 0.06), 0 4px 16px rgba(22, 35, 46, 0.05);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
}

body {
    min-height: 100vh;
    padding-bottom: 88px; /* deja sitio a la barra de navegación fija */
}

a { color: inherit; }

/* ---------- Tipografía ---------- */

.eyebrow {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 0.95rem;
    color: var(--slate);
    margin: 0 0 4px;
    letter-spacing: 0.01em;
}

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--ink);
    margin: 0;
    line-height: 1.15;
}

h1 { font-size: 1.9rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }

.mono {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

p { line-height: 1.5; color: var(--ink-soft); }
.muted { color: var(--slate); }

/* ---------- Layout ---------- */

.page {
    max-width: 480px;
    margin: 0 auto;
    padding: 24px 20px 20px;
}

.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }

/* ---------- Tarjetas ---------- */

.card {
    background: var(--paper-raised);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-card);
    border: 1px solid rgba(22, 35, 46, 0.04);
}

.card + .card { margin-top: 14px; }

/* ---------- Cuaderno de bitácora (lista con regla lateral) ---------- */

.logbook {
    border-left: 2px solid var(--rule);
    margin-left: 6px;
    padding-left: 18px;
}

.log-entry {
    position: relative;
    padding: 10px 0;
    border-bottom: 1px solid var(--rule);
}
.log-entry:last-child { border-bottom: none; }

.log-entry::before {
    content: "";
    position: absolute;
    left: -23px;
    top: 18px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--teal);
}

.log-entry-title { font-weight: 600; font-size: 0.95rem; }
.log-entry-meta { font-size: 0.82rem; color: var(--slate); margin-top: 2px; }
.log-entry-value { font-family: var(--font-mono); font-size: 0.95rem; color: var(--ink); }

/* ---------- Botones ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 999px;
    padding: 13px 22px;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    box-sizing: border-box;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--teal); color: var(--paper-raised); }
.btn-primary:hover { background: var(--teal-deep); }

.btn-ghost { background: transparent; color: var(--teal); border: 1.5px solid var(--teal-mist); }
.btn-ghost:hover { background: var(--teal-mist); }

.btn-block { width: 100%; }

.fab-row { display: flex; gap: 10px; }
.fab {
    flex: 1;
    background: var(--paper-raised);
    border: 1.5px solid var(--rule);
    border-radius: var(--radius);
    padding: 14px 10px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ink-soft);
    cursor: pointer;
}
.fab:hover { border-color: var(--teal); color: var(--teal); }
.fab .fab-icon { display: block; font-size: 1.4rem; margin-bottom: 4px; }

.btn-small {
    background: none; border: 1.5px solid var(--rule); color: var(--slate);
    border-radius: 999px; padding: 8px 16px; font-size: 0.85rem; cursor: pointer; font-family: var(--font-body);
}
.btn-small.danger { color: var(--brick); border-color: var(--brick-soft); }

.log-thumb {
    width: 44px; height: 44px; border-radius: 8px; object-fit: cover;
    flex-shrink: 0; cursor: pointer; margin-right: 10px;
}

.meal-section-title { font-family: var(--font-display); font-style: italic; font-size: 0.9rem; color: var(--slate); margin: 14px 0 4px; }
.meal-section-title:first-child { margin-top: 0; }

/* ---------- Formularios ---------- */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.row > * { min-width: 0; }
.field label { font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); }

input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="datetime-local"] {
    font-family: var(--font-body);
    font-size: 1rem;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1.5px solid var(--rule);
    background: var(--paper-raised);
    color: var(--ink);
    width: 100%;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    min-height: 46px;
}
input:focus {
    outline: 2px solid var(--teal);
    outline-offset: 1px;
    border-color: var(--teal);
}

/* ---------- Racha (streak) ---------- */

.streak-badge {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    background: var(--brass-soft);
    color: var(--teal-deep);
    padding: 6px 14px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.85rem;
}
.streak-badge .mono { font-size: 1.05rem; color: var(--brass); }

/* ---------- Barra inferior de navegación ---------- */

.tabbar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--paper-raised);
    border-top: 1px solid var(--rule);
    display: flex;
    padding: 8px max(12px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom));
    z-index: 10;
}
.tabbar a {
    flex: 1;
    text-align: center;
    text-decoration: none;
    color: var(--slate-faint);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 6px 0;
}
.tabbar a.active { color: var(--teal); }
.tabbar .tab-icon { display: block; font-size: 1.3rem; margin-bottom: 2px; }

/* ---------- Diálogos (modal) ---------- */

dialog { border: none; border-radius: var(--radius); padding: 0; width: min(420px, 92vw); }
dialog::backdrop { background: rgba(22, 35, 46, 0.4); }
.dialog-inner { padding: 22px; }

/* ---------- Estados vacíos / mensajes ---------- */

.empty-state { text-align: center; padding: 32px 16px; color: var(--slate); }
.error-banner {
    background: var(--brick-soft);
    color: var(--brick);
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 0.88rem;
    font-weight: 500;
}

/* ---------- Accesibilidad ---------- */

:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
