/* ===================================================================
   Liste de courses familiale — feuille de style mobile-first
   =================================================================== */

:root {
    --accent: #16A34A;
    --accent-dark: #15803D;
    --danger: #DC2626;
    --bg: #F3F4F6;
    --surface: #FFFFFF;
    --text: #111827;
    --text-muted: #6B7280;
    --border: #E5E7EB;
    --radius: 14px;
    --topbar-h: 56px;
    --tap: 48px; /* cible tactile minimale */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: contain;
}

h1, h2, p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
ul { list-style: none; margin: 0; padding: 0; }

h1:focus { outline: none; }

/* ---------- Avatar ---------- */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    flex: 0 0 auto;
    user-select: none;
}

.avatar--lg {
    width: 84px;
    height: 84px;
    font-size: 1.9rem;
}

/* ---------- Barre supérieure ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: calc(var(--topbar-h) + var(--safe-top));
    padding: var(--safe-top) 14px 0;
    background: var(--accent);
    color: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.topbar__brand {
    font-weight: 700;
    font-size: 1.15rem;
}

.topbar__profile {
    border: 2px solid rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    padding: 0;
    background: none;
    line-height: 0;
}

/* ---------- Menu (profil + actions) ---------- */
.menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
}

.menu {
    position: absolute;
    z-index: 40;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    min-width: 220px;
}

.topbar .menu {
    top: calc(var(--topbar-h) + var(--safe-top) - 4px);
    right: 12px;
}

.menu__header {
    padding: 12px 16px;
    font-weight: 700;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.menu__form { margin: 0; }

.menu__item {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: none;
    padding: 14px 16px;
    font-size: 1rem;
    color: var(--text);
}

.menu__item:active { background: var(--bg); }
.menu__item:disabled { color: #C2C7CF; }
.menu__item--danger { color: var(--danger); }

/* ---------- Contenu ---------- */
.content {
    max-width: 640px;
    margin: 0 auto;
    padding: 12px 12px calc(96px + var(--safe-bottom));
}

/* ---------- En-tête de liste : onglets + actions ---------- */
.list-header {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.segmented {
    flex: 1;
    display: flex;
    background: #E5E7EB;
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
}

.segmented__btn {
    flex: 1;
    border: none;
    background: none;
    border-radius: 9px;
    padding: 0 8px;
    height: 40px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.segmented__btn.is-active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.pill {
    background: var(--accent);
    color: #fff;
    border-radius: 999px;
    font-size: 0.72rem;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.segmented__btn:not(.is-active) .pill { background: #9CA3AF; }

/* ---------- Boutons icônes ---------- */
.iconbtn {
    width: var(--tap);
    height: var(--tap);
    border: none;
    background: none;
    border-radius: 10px;
    font-size: 1.2rem;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.iconbtn:active { background: var(--bg); }
.iconbtn--del { color: #9CA3AF; }
.iconbtn--actions { background: #E5E7EB; color: var(--text); font-size: 1.5rem; }

.list-header .menu--actions {
    top: calc(100% + 6px);
    right: 0;
}

/* ---------- Articles ---------- */
.items { display: flex; flex-direction: column; gap: 8px; }

.item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 8px 8px 8px 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    min-height: 60px;
}

.item--checked { background: #ECFDF3; }

.item__name {
    flex: 1;
    font-size: 1.05rem;
    word-break: break-word;
    /* « juste coché », jamais barré : on ne met PAS de line-through */
}

/* Checkbox tactile personnalisée */
.check {
    position: relative;
    width: var(--tap);
    height: var(--tap);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.check input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; }

.check__box {
    width: 28px;
    height: 28px;
    border: 2px solid #CBD5E1;
    border-radius: 8px;
    background: #fff;
    transition: background-color .12s, border-color .12s;
}

.check input:checked + .check__box {
    background: var(--accent);
    border-color: var(--accent);
}

.check input:checked + .check__box::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 47%;
    width: 7px;
    height: 13px;
    border: solid #fff;
    border-width: 0 3px 3px 0;
    transform: translate(-50%, -55%) rotate(45deg);
}

/* Bouton +1 « ça m'intéresse aussi » */
.plusone {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1.5px solid var(--border);
    background: #fff;
    color: var(--text-muted);
    border-radius: 999px;
    height: 38px;
    padding: 0 10px;
    font-weight: 700;
    font-size: 0.85rem;
    flex: 0 0 auto;
    white-space: nowrap;
}

.plusone__count {
    background: var(--accent);
    color: #fff;
    border-radius: 999px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 0.72rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.plusone.is-mine { background: var(--accent); border-color: var(--accent); color: #fff; }
.plusone.is-mine .plusone__count { background: #fff; color: var(--accent); }
.plusone:active { transform: scale(0.94); }

/* Compactage des contrôles dans une ligne (place sur petits écrans) */
.item { gap: 6px; }
.item .iconbtn { width: 40px; font-size: 1.1rem; }
.item .avatar { width: 28px; height: 28px; font-size: 0.72rem; }
.item__name { min-width: 0; }

/* ---------- Barre d'ajout collante ---------- */
.addbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
    display: flex;
    gap: 8px;
    padding: 10px 12px calc(10px + var(--safe-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
    max-width: 640px;
    margin: 0 auto;
}

.addbar__input {
    flex: 1;
    height: var(--tap);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0 14px;
    font-size: 1rem;
    background: var(--bg);
}

.addbar__input:focus {
    outline: none;
    border-color: var(--accent);
    background: #fff;
}

.addbar__btn {
    width: var(--tap);
    height: var(--tap);
    border: none;
    border-radius: 12px;
    background: var(--accent);
    color: #fff;
    font-size: 1.8rem;
    line-height: 1;
    flex: 0 0 auto;
}

.addbar__btn:disabled { background: #9CA3AF; }
.addbar__btn:active:not(:disabled) { background: var(--accent-dark); }

/* ---------- États vides / chargement ---------- */
.state {
    text-align: center;
    color: var(--text-muted);
    padding: 48px 16px;
}

.state__icon { font-size: 3rem; }
.state__hint { font-size: 0.9rem; margin-top: 4px; }

/* ---------- Boutons génériques ---------- */
.btn {
    border: none;
    border-radius: 12px;
    height: var(--tap);
    padding: 0 20px;
    font-size: 1rem;
    font-weight: 600;
}

.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:active { background: var(--accent-dark); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--ghost { background: var(--bg); color: var(--text); }

/* ---------- Porte d'entrée (login) ---------- */
.gate {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(160deg, var(--accent), var(--accent-dark));
}

.gate__card {
    background: var(--surface);
    border-radius: 20px;
    padding: 32px 24px;
    width: 100%;
    max-width: 360px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.gate__logo { font-size: 3rem; }
.gate__title { font-size: 1.4rem; margin-top: 8px; }
.gate__sub { color: var(--text-muted); margin: 6px 0 20px; }
.gate__form { display: flex; flex-direction: column; gap: 12px; }

.gate__input {
    height: 52px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0 16px;
    font-size: 1.3rem;
    text-align: center;
    letter-spacing: 0.3em;
}

.gate__input:focus { outline: none; border-color: var(--accent); }
.gate__btn { width: 100%; }
.gate__error { color: var(--danger); margin-top: 14px; font-weight: 600; }

/* Bouton « Installer l'app » (PWA) — n'apparaît que si le navigateur le propose */
.install-btn {
    width: 100%;
    margin-top: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.install-btn:active { background: var(--border); }
.install-btn__icon { font-size: 1.2rem; line-height: 1; }

.install-hint {
    margin-top: 18px;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.45;
}

/* ---------- Sélection de profil (Netflix) ---------- */
.profiles {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px calc(32px + var(--safe-bottom));
    background: #111827;
    color: #fff;
}

.profiles__title { font-size: 1.6rem; margin-bottom: 32px; text-align: center; }

.profiles__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 20px;
    width: 100%;
    max-width: 480px;
}

.profile {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #fff;
    padding: 8px;
    border-radius: 14px;
}

.profile:active { background: rgba(255, 255, 255, 0.08); }
.profile .avatar--lg { transition: transform .12s; }
.profile:active .avatar--lg { transform: scale(0.94); }
.profile__name { font-size: 1rem; font-weight: 600; }

/* ---------- Modale de confirmation ---------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal {
    background: var(--surface);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 360px;
}

.modal__title { font-size: 1.2rem; }
.modal__msg { color: var(--text-muted); margin: 12px 0 24px; }
.modal__actions { display: flex; gap: 10px; }
.modal__actions .btn { flex: 1; }

/* ---------- UI d'erreur Blazor (vit dans App.razor) ---------- */
#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}

.blazor-error-boundary::after { content: "Une erreur est survenue."; }
