/* BabyTrack — feuille de style unique, mobile-first, pensée pour un usage nocturne. */

:root {
    --bg: #0f1116;
    --bg-elevated: #191c24;
    --bg-input: #12141a;
    --border: #2a2f3a;
    --text: #e8eaf0;
    --text-muted: #9aa3b5;
    --accent: #5b9dff;
    --accent-strong: #3d84f2;
    --danger: #ff6b6b;
    --success: #4ecb8b;
    --radius: 14px;
    --tap: 56px;
    --gap: 12px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #f4f5f8;
        --bg-elevated: #ffffff;
        --bg-input: #ffffff;
        --border: #d9dde5;
        --text: #171a21;
        --text-muted: #5c6474;
        --accent: #2b6fd8;
        --accent-strong: #1f5cba;
    }
}

* { box-sizing: border-box; }

html {
    /* Empêche iOS d'agrandir le texte en paysage. */
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 17px;
    line-height: 1.45;
    /* Place pour la tabbar fixe. */
    padding-bottom: calc(72px + var(--safe-bottom));
    overscroll-behavior-y: contain;
}

.page {
    max-width: 720px;
    margin: 0 auto;
    padding: max(16px, env(safe-area-inset-top)) 16px 16px;
}

/* ---------- En-tête ---------- */

.header { margin: 8px 0 20px; }
.header__title { margin: 0; font-size: 1.6rem; letter-spacing: -0.02em; }
.header__subtitle { margin: 4px 0 0; color: var(--text-muted); font-size: 0.95rem; }

/* ---------- Messages ---------- */

.flash {
    margin: 0 0 16px;
    padding: 12px 14px;
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--success) 18%, var(--bg-elevated));
    border: 1px solid color-mix(in srgb, var(--success) 35%, transparent);
    font-size: 0.95rem;
}

.flash--error,
.flash--danger {
    background: color-mix(in srgb, var(--danger) 18%, var(--bg-elevated));
    border-color: color-mix(in srgb, var(--danger) 40%, transparent);
}

.empty {
    color: var(--text-muted);
    text-align: center;
    padding: 32px 0;
}

/* ---------- Grille de saisie rapide ---------- */

.grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--gap);
    margin-bottom: 20px;
}

@media (min-width: 520px) {
    .grid { grid-template-columns: repeat(3, 1fr); }
}

.grid form { display: contents; }

.tile {
    width: 100%;
    min-height: 96px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elevated);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    /* Pas de surbrillance grise au tap sur iOS. */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: transform 0.08s ease, border-color 0.15s ease;
}

.tile:active {
    transform: scale(0.97);
    border-color: var(--accent);
}

.tile__emoji { font-size: 1.9rem; line-height: 1; }
.tile__label { font-size: 0.92rem; text-align: center; }

/* ---------- Cartes ---------- */

.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
}

.card--running { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }

.card__title {
    margin: 0 0 10px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.running {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--gap);
    padding: 8px 0;
    border-top: 1px solid var(--border);
}

.running:first-of-type { border-top: 0; }
.running__info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.running__label { font-weight: 600; }
.running__meta { color: var(--text-muted); font-size: 0.88rem; }
.chrono { font-variant-numeric: tabular-nums; }

/* ---------- Listes ---------- */

.list { list-style: none; margin: 0; padding: 0; }

.list__item {
    display: flex;
    align-items: center;
    gap: var(--gap);
    border-top: 1px solid var(--border);
}

.list__item:first-child { border-top: 0; }

.list__link {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 0;
    min-height: var(--tap);
    justify-content: center;
    color: inherit;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.list--compact .list__link { min-height: 44px; padding: 8px 0; }
.list__title { font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.list__person { font-weight: 400; color: var(--text-muted); font-size: 0.88rem; }
.list__meta { color: var(--text-muted); font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.list__note {
    color: var(--text-muted);
    font-size: 0.88rem;
    font-style: italic;
    overflow-wrap: anywhere;
}

.dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--person-color, var(--text-muted));
    flex: none;
}

.link { color: var(--accent); text-decoration: none; font-size: 0.9rem; }

/* ---------- Synthèse ---------- */

.summary { margin-bottom: 16px; }
.summary__main { margin: 0; }
.summary__people {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ---------- Formulaires ---------- */

.form { display: flex; flex-direction: column; gap: 18px; margin-bottom: 20px; }
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field-row { display: flex; gap: var(--gap); flex-wrap: wrap; }
.field-row .field { flex: 1 1 160px; }

/* Libellé de champ : uniquement le label direct du bloc, pas ceux des pastilles. */
.field__label,
.field > label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

input[type='password'],
input[type='text'],
input[type='datetime-local'],
input[type='date'],
input[type='time'],
textarea,
select {
    width: 100%;
    min-height: var(--tap);
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text);
    /* 16px minimum : en dessous, iOS zoome au focus. */
    font-size: 16px;
    font-family: inherit;
}

textarea { min-height: 72px; resize: vertical; }

input:focus-visible,
textarea:focus-visible,
.tile:focus-visible,
.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Cases à cocher / radios rendues en pastilles tactiles.
   Symfony rend `<input><label>` en frères, d'où le sélecteur `input:checked + label`. */

.choices,
.choices > div { display: flex; flex-wrap: wrap; gap: 8px; }

.choices label,
.choice {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-elevated);
    color: var(--text);
    font-size: 0.95rem;
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.choices input[type='radio'],
.choices input[type='checkbox'] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.choices input:checked + label,
.choice:has(input:checked) {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 22%, var(--bg-elevated));
    font-weight: 600;
}

.choice--person { padding: 0; border: 0; background: none; }
.choice--person .choice__body {
    display: inline-flex;
    align-items: center;
    min-height: var(--tap);
    padding: 10px 20px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-elevated);
    font-size: 1.05rem;
}
.choice--person:has(input:checked) .choice__body {
    border-color: var(--person-color, var(--accent));
    background: color-mix(in srgb, var(--person-color, var(--accent)) 25%, var(--bg-elevated));
    font-weight: 600;
}

/* Messages de validation. */
.form ul { margin: 0; padding-left: 18px; color: var(--danger); font-size: 0.9rem; }

/* ---------- Boutons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--tap);
    padding: 12px 22px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: var(--bg-elevated);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:active { background: var(--accent-strong); }
.btn--ghost { border-color: var(--border); }
.btn--danger { background: color-mix(in srgb, var(--danger) 20%, var(--bg-elevated)); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn--stop { background: var(--accent); color: #fff; }
.btn--small { min-height: 40px; padding: 8px 16px; font-size: 0.9rem; }

.actions { display: flex; flex-wrap: wrap; gap: var(--gap); align-items: center; }

/* ---------- Filtres ---------- */

.filters {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px 16px;
    margin-bottom: 16px;
}

.filters__summary {
    min-height: var(--tap);
    display: flex;
    align-items: center;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.form--filters { margin: 8px 0 16px; }

/* ---------- Barre de navigation ---------- */

.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding-bottom: var(--safe-bottom);
    z-index: 10;
}

.tabbar__item {
    flex: 1;
    min-height: var(--tap);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 8px 4px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.78rem;
    -webkit-tap-highlight-color: transparent;
}

.tabbar__item span { font-size: 1.15rem; line-height: 1; }
.tabbar__item.is-active { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
    .btn:active, .tile:active { transform: none; }
}
