/* app-vacances — feuille de style (CSS vanilla) */

:root {
    /* Palette « carnet de vacances » */
    --mer: #0a9396;          /* turquoise mer (couleur primaire / accent) */
    --mer-fonce: #077a7d;
    --nuit: #053b50;         /* bleu nuit (header, tuiles, texte fort) */
    --soleil: #ffb703;       /* jaune soleil */
    --corail: #fb6f50;       /* corail (dépenses, alertes douces) */

    /* Compat : d'anciens styles utilisent --bleu / --bleu-fonce.
       On les fait pointer sur la mer pour une bascule sans tout réécrire. */
    --bleu: var(--mer);
    --bleu-fonce: var(--mer-fonce);

    --sable: #fdf6ec;        /* fond crème chaud */
    --vert: #2e9e6b;
    --rouge: #d64545;
    --texte: #053b50;
    --muted: #6b7d88;
    --bord: #e7ddcb;
    --ombre: 0 4px 14px rgba(5, 59, 80, .08);
    --radius: 16px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--texte);
    background: var(--sable);
    line-height: 1.5;
}

.container { width: min(960px, 92%); margin: 0 auto; }

/* -- En-tête / navigation -- */
.site-header {
    background: var(--nuit);
    color: #fff;
    box-shadow: var(--ombre);
}
.main-nav a.is-active { color: #fff; border-bottom: 2px solid var(--soleil); }
.admin-header { background: #34404f; }
.header-inner {
    display: flex; align-items: center; justify-content: space-between;
    padding: .8rem 0; gap: 1rem;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem;
    display: inline-flex; align-items: center; gap: .5rem; min-width: 0; }
.brand-emoji { font-size: 1.3rem; flex: 0 0 auto; }
.brand-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main-nav { display: flex; gap: 1.2rem; align-items: center; }
.main-nav a, .nav-logout { color: #eaf2ff; text-decoration: none; font-weight: 500; }
.main-nav a:hover { color: #fff; text-decoration: underline; }
.main-nav a.is-active { color: #fff; border-bottom: 2px solid #fff; }
.nav-logout { opacity: .85; }
.linkish { background: none; border: 0; color: inherit; cursor: pointer; font: inherit; }
.inline-form { display: inline; }
.lead-emoji { margin-inline-end: .2em; }

/* Bouton burger (caché en desktop) */
.nav-toggle { display: none; flex: 0 0 auto; background: none; border: 0; cursor: pointer;
    padding: .4rem; width: 44px; height: 44px; }
.nav-toggle span { display: block; width: 24px; height: 2px; background: #fff; margin: 5px auto;
    border-radius: 2px; transition: transform .2s, opacity .2s; }
.nav-toggle.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.is-open span:nth-child(2) { opacity: 0; }
.nav-toggle.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* -- Pieds -- */
.site-footer { text-align: center; color: var(--muted); padding: 2rem 0; }

/* -- Titres -- */
.page-title { margin: 1.5rem 0 1rem; }

/* -- Hero : bloc mer + soleil (direction « carnet de vacances ») -- */
.hero {
    margin: 1.3rem 0;
    border-radius: 20px;
    padding: 2rem 1.9rem;
    color: #fff;
    background: var(--mer);
    position: relative; overflow: hidden;
    box-shadow: 0 10px 28px rgba(10, 147, 150, .22);
}
.hero::before {
    content: ""; position: absolute; width: 150px; height: 150px; border-radius: 50%;
    background: var(--soleil); top: -46px; right: -34px; opacity: .92; pointer-events: none;
}
.hero-body { position: relative; z-index: 1; }
.hero h1 { margin: 0 0 .5rem; font-size: clamp(1.7rem, 4vw, 2.5rem); font-weight: 800;
    letter-spacing: -.02em; text-wrap: balance; }
.hero-dates, .hero-lieu { margin: .2rem 0; color: rgba(255,255,255,.95); font-weight: 600; }
.hero-ico { margin-right: .3rem; }
.hero-lieu a { color: #fff; text-decoration: underline; text-underline-offset: 2px; }

/* -- Cartes / stats colorées -- */
.cards { display: flex; gap: 1rem; flex-wrap: wrap; margin: 1rem 0; }
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--ombre); padding: 1.3rem 1.5rem; }
.stat { display: flex; flex-direction: column; min-width: 180px; flex: 1; color: #fff; border: 0; }
.stat:nth-child(1) { background: var(--corail); }
.stat:nth-child(2) { background: var(--soleil); color: var(--nuit); }
.stat-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 800; opacity: .92; }
.stat-value { font-size: 2.1rem; font-weight: 800; letter-spacing: -.02em; margin-top: .1rem; }
.stat-sub { font-size: .85rem; opacity: .92; margin-top: .1rem; }
.progress { background: rgba(255,255,255,.4); height: 9px; border-radius: 6px; margin-top: .7rem; overflow: hidden; }
.progress-bar { height: 100%; background: #fff; border-radius: 6px; }

/* -- Accès rapides (tuiles bleu nuit) -- */
.quick-access { display: flex; gap: 1rem; flex-wrap: wrap; margin: 1.2rem 0 2rem; }
.quick-tile {
    flex: 1; min-width: 200px; text-align: center; text-decoration: none;
    background: var(--nuit); color: #fff; padding: 1.2rem; border-radius: var(--radius);
    box-shadow: var(--ombre); font-weight: 700;
    transition: transform .15s ease, box-shadow .15s ease;
}
.quick-tile:hover { transform: translateY(-3px); box-shadow: 0 12px 26px rgba(5,59,80,.25); }
@media (prefers-reduced-motion: reduce) { .quick-tile { transition: none; } }

/* -- Panneaux -- */
.panel { background: #fff; border-radius: var(--radius); box-shadow: var(--ombre);
    padding: 1.3rem 1.5rem; margin: 1rem 0; }
.panel h2 { margin-top: 0; }

/* -- Listes -- */
.list { list-style: none; padding: 0; margin: 0; }
.list-item { display: flex; gap: 1rem; align-items: center; justify-content: space-between;
    padding: .6rem 0; border-bottom: 1px solid var(--bord); }
.list-item:last-child { border-bottom: 0; }
.list-item .amount { font-weight: 700; }
.contact-coords { display: flex; gap: 1.2rem; flex-wrap: wrap; justify-content: flex-end; }
.contact-coords a { color: var(--bleu); text-decoration: none; }
.contact-coords a:hover { text-decoration: underline; }
.badge-cible { display: inline-block; background: #fff1e8; color: var(--corail);
    font-size: .78rem; font-weight: 700; padding: .12rem .55rem; border-radius: 999px; }

/* -- Tableaux -- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--bord); }
.table th { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
.table .num { text-align: right; }
.table tr.is-me { background: #eef5ff; }
.pos { color: var(--vert); font-weight: 700; }
.neg { color: var(--rouge); font-weight: 700; }
.bilan-mini { display: block; font-size: .7rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.badge-vous { display: inline-block; background: var(--bleu); color: #fff; font-size: .65rem;
    font-weight: 700; text-transform: uppercase; padding: .08rem .4rem; border-radius: 999px; vertical-align: middle; }

/* -- Encart bilan perso (onglet Soldes) -- */
.bilan-perso { border-radius: var(--radius); padding: 1.2rem 1.4rem; margin: 1rem 0;
    box-shadow: var(--ombre); border-left: 6px solid var(--muted); background: #fff; }
.bilan-perso.is-pos { border-left-color: var(--vert); background: #eefaf3; }
.bilan-perso.is-neg { border-left-color: var(--corail); background: #fff1ec; }
.bilan-perso.is-zero { border-left-color: var(--bleu); background: #eef5ff; }
.bilan-perso-titre { font-size: 1.3rem; font-weight: 700; }
.bilan-perso-lignes { list-style: none; padding: 0; margin: .6rem 0 0; }
.bilan-perso-lignes li { padding: .35rem 0; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }

/* -- Objectif de contribution au logement (prévisionnel, distinct du réel) -- */
.objectif { background: #fff; border-radius: var(--radius); box-shadow: var(--ombre);
    border-left: 6px solid var(--soleil); padding: 1.2rem 1.4rem; margin: 1rem 0; }
.objectif-head { display: flex; gap: .8rem; align-items: flex-start; }
.objectif-emoji { font-size: 1.6rem; line-height: 1; flex: 0 0 auto; }
.objectif-titre { font-size: 1.15rem; font-weight: 700; }
.objectif-sub { color: var(--muted); font-size: .85rem; margin-top: .15rem; }
.objectif-perso { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; align-items: baseline;
    margin: .9rem 0 .2rem; padding: .7rem .9rem; border-radius: 10px; background: var(--sable); }
.objectif-perso.is-progress { background: #fff6e6; }
.objectif-perso.is-ok { background: #eefaf3; }
.objectif-verdict { font-weight: 600; }
.objectif-perso.is-progress .objectif-verdict { color: var(--mer-fonce); }
.objectif-perso.is-ok .objectif-verdict { color: var(--vert); }
.objectif-pct { font-weight: 700; color: var(--mer-fonce); }
.objectif-pct.is-done { color: var(--vert); }
.objectif-table { margin-top: .8rem; margin-bottom: 0; }

/* -- Page d'aide -- */
.aide-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin: 1rem 0; }
.aide-card { background: #fff; border-radius: var(--radius); box-shadow: var(--ombre);
    padding: 1.2rem 1.4rem; position: relative; }
.aide-card-wide { grid-column: 1 / -1; }
.aide-num { width: 30px; height: 30px; border-radius: 50%; background: var(--bleu); color: #fff;
    font-weight: 700; display: flex; align-items: center; justify-content: center; margin-bottom: .6rem; }
.aide-card h2 { margin: 0 0 .4rem; font-size: 1.1rem; }
.aide-card p { margin: .3rem 0; color: #46535f; }
.aide-tip { background: var(--sable); border-radius: 8px; padding: .5rem .8rem; font-size: .9rem; }
.aide-faq { background: #fff; border-radius: var(--radius); box-shadow: var(--ombre);
    padding: 1.2rem 1.5rem; margin: 1.4rem 0; }
.aide-faq h2 { margin-top: 0; }
.aide-faq details { border-bottom: 1px solid var(--bord); padding: .6rem 0; }
.aide-faq details:last-child { border-bottom: 0; }
.aide-faq summary { cursor: pointer; font-weight: 600; color: var(--bleu-fonce); }
.aide-faq details p { margin: .5rem 0 0; color: #46535f; }
/* Détail des calculs (formules dans la FAQ) */
.methode h4 { margin: 1rem 0 .3rem; font-size: 1rem; color: var(--texte); }
.methode .formule { font-family: ui-monospace, "SF Mono", Menlo, monospace; background: var(--nuit);
    color: #fff; padding: .55rem .8rem; border-radius: 8px; font-weight: 600; margin: .4rem 0;
    overflow-x: auto; white-space: nowrap; }
@media (max-width: 640px) {
    .aide-grid { grid-template-columns: 1fr; }
}

/* -- Planning des repas -- */
.planning td { vertical-align: middle; }
.planning-jour { font-weight: 700; color: var(--bleu-fonce); white-space: nowrap; }
.repas-pris { display: inline-block; background: #eef5ff; color: var(--bleu-fonce);
    font-weight: 600; padding: .15rem .6rem; border-radius: 999px; }
.repas-moi { background: var(--bleu); color: #fff; }
.btn-libre { background: #fff; border: 1px dashed var(--bleu); color: var(--bleu);
    border-radius: 8px; padding: .35rem .8rem; font: inherit; font-size: .85rem; cursor: pointer; }
.btn-libre:hover { background: #eef5ff; }
.btn-link-repas { background: none; border: 0; color: var(--muted); cursor: pointer;
    font-size: .85rem; padding: 0 .3rem; }
.btn-link-repas:hover { color: var(--rouge); }

/* -- Onglets -- */
.tab-buttons { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tab-btn { background: #fff; border: 1px solid var(--bord); border-radius: 999px;
    padding: .45rem 1.1rem; cursor: pointer; font: inherit; color: var(--muted); }
.tab-btn.is-active { background: var(--bleu); border-color: var(--bleu); color: #fff; }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* -- Formulaires -- */
.form label { display: block; margin: .6rem 0; font-size: .9rem; color: var(--muted); }
.form input, .form select, .form textarea {
    display: block; width: 100%; margin-top: .25rem; padding: .55rem .7rem;
    border: 1px solid var(--bord); border-radius: 9px; font: inherit; color: var(--texte);
    background: #fff;
}
.form-row { display: flex; gap: 1rem; }
.form-row label { flex: 1; }
.form-inline { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.form-inline label { margin: 0; }
.form-inline .btn { margin-bottom: 0; }

/* -- Boutons -- */
.btn { display: inline-block; border: 0; border-radius: 9px; padding: .6rem 1.2rem;
    font: inherit; font-weight: 600; cursor: pointer; }
.btn-primary { background: var(--bleu); color: #fff; }
.btn-primary:hover { background: var(--bleu-fonce); }
.btn-danger { background: var(--rouge); color: #fff; }
.btn-sm { padding: .35rem .7rem; font-size: .85rem; }

/* -- Alertes -- */
.alert { padding: .7rem 1rem; border-radius: 9px; margin: .8rem 0; }
.alert-error { background: #fdecec; color: var(--rouge); }
.alert-info { background: #e9f6ef; color: var(--vert); }

/* -- Flash (confirmation après action) -- */
.flash { background: #e9f6ef; color: #1c6b46; border: 1px solid #bfe6d0;
    padding: .75rem 1.1rem; border-radius: 10px; margin: 1rem 0; font-weight: 600;
    box-shadow: var(--ombre); animation: flash-in .25s ease-out; }
.flash.flash-out { opacity: 0; transition: opacity .4s ease; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .flash { animation: none; } .flash.flash-out { transition: none; } }

/* -- Focus clavier visible (accessibilité) -- */
:focus-visible { outline: 3px solid var(--bleu); outline-offset: 2px; border-radius: 4px; }
.btn:focus-visible { outline-offset: 3px; }

/* -- État vide (invite à agir) -- */
.empty { text-align: center; color: var(--muted); padding: 1.6rem 1rem; }
.empty-emoji { font-size: 2rem; display: block; margin-bottom: .4rem; }

/* -- Divers -- */
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.prewrap { white-space: pre-wrap; }
.copyable { background: #f0f3f8; padding: .15rem .5rem; border-radius: 6px; cursor: pointer;
    font-family: ui-monospace, monospace; position: relative; display: inline-block;
    max-width: 100%; overflow-wrap: anywhere; }
.copyable:hover { background: #e2e8f2; }
.copyable::after { content: "📋"; font-size: .8em; margin-left: .35em; opacity: .5; }
.copyable.copied { background: #d8f3e3; color: var(--vert); }
.copyable.copied::after { content: "Copié ✓"; opacity: 1; font-family: inherit; }

/* -- Connexion / admin login -- */
.login-body { display: flex; min-height: 100vh; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--bleu), var(--bleu-fonce)); }
.login-card { background: #fff; border-radius: 18px; box-shadow: 0 10px 40px rgba(0,0,0,.25);
    padding: 2rem; width: min(420px, 92%); }
.login-title { margin: 0 0 .2rem; }
.login-subtitle { color: var(--muted); margin: 0 0 1rem; }
.login-card .form > .btn { display: block; width: fit-content; margin: 1rem auto 0; }

/* -- Admin familles -- */
.famille-row { padding-bottom: .4rem; }
.famille-actions { margin-top: .3rem; }
.famille-sep { border: 0; border-top: 1px solid var(--bord); margin: .6rem 0 1rem; }

/* ======================= RESPONSIVE (mobile) ======================= */
@media (max-width: 720px) {
    /* Formulaires empilés */
    .form-row, .form-inline { flex-direction: column; align-items: stretch; }
    .form-inline .btn { width: 100%; }

    /* --- Menu burger --- */
    .nav-toggle { display: block; }
    .main-nav {
        display: none;
        position: absolute; top: 100%; left: 0; right: 0; z-index: 20;
        flex-direction: column; align-items: stretch; gap: 0;
        background: var(--bleu-fonce);
        box-shadow: 0 8px 20px rgba(0,0,0,.2);
    }
    .main-nav.is-open { display: flex; }
    .main-nav a, .main-nav .nav-logout {
        padding: .9rem 1.2rem; border-bottom: 1px solid rgba(255,255,255,.12);
    }
    .main-nav a.is-active { border-bottom: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.08); }
    .site-header .container { position: relative; }

    /* L'admin n'a pas de bouton burger : sa nav ne doit donc PAS se replier
       (sinon « Voir le site » et « Déconnexion » deviennent inatteignables). */
    .admin-header .main-nav {
        display: flex; position: static; flex-direction: row; align-items: center;
        gap: .4rem; background: none; box-shadow: none;
    }
    .admin-header .main-nav a, .admin-header .main-nav .nav-logout {
        padding: .3rem .5rem; border-bottom: 0;
    }

    /* --- Tableaux → cartes empilées --- */
    /* Chaque ligne devient une carte ; chaque cellule affiche son intitulé. */
    .table-cards thead { display: none; }
    .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
    .table-cards tr {
        background: #fff; border: 1px solid var(--bord); border-radius: 10px;
        padding: .4rem .2rem; margin-bottom: .7rem; box-shadow: var(--ombre);
    }
    .table-cards td {
        display: flex; justify-content: space-between; align-items: center; gap: 1rem;
        text-align: right; padding: .45rem .8rem; border: 0;
        border-bottom: 1px solid var(--bord);
    }
    .table-cards td:last-child { border-bottom: 0; }
    .table-cards td::before {
        content: attr(data-label); font-weight: 600; color: var(--muted);
        font-size: .78rem; text-transform: uppercase; letter-spacing: .03em;
        text-align: left; flex: 0 0 auto;
    }
    /* La cellule "action" (suppression) collée à droite */
    .table-cards td.cell-action { justify-content: flex-end; }
    .table-cards td.cell-action::before { content: none; }
    /* Contrôles (badge + boutons) alignés à droite, sous l'intitulé de cellule */
    .table-cards td .cell-controls { justify-content: flex-end; }

    /* Onglets : on laisse revenir à la ligne pour que TOUS les onglets restent
       visibles (le scroll horizontal masquait « Codes & accès » / « Soldes »). */
    .tab-buttons { flex-wrap: wrap; }
    .tab-btn { white-space: nowrap; padding: .45rem .8rem; }

    /* IBAN longs : on les laisse passer à la ligne dans les listes */
    .list-item { flex-wrap: wrap; }
    /* Liste des familles : nom à gauche, effectif à droite sur la MÊME ligne
       (le nom se resserre si besoin) plutôt que l'effectif orphelin en dessous. */
    .list-families .list-item { flex-wrap: nowrap; }
    .list-families .list-item > :first-child { min-width: 0; }
    .list-families .list-item > :last-child { flex: 0 0 auto; white-space: nowrap; }
    /* …mais le détail de droite reste calé à droite même une fois passé
       à la ligne (sinon il « retombe » à gauche, désaligné). */
    .list-item > :last-child { margin-left: auto; text-align: right; }

    /* Planning : cellules compactes et bouton « Je m'en occupe » en bloc
       pleine largeur (tap target net) plutôt que cassé en trois lignes. */
    .planning th, .planning td { padding: .5rem .3rem; }
    .planning-jour { font-size: .9rem; }
    .planning .btn-libre { display: block; width: 100%; padding: .4rem .3rem;
        font-size: .8rem; line-height: 1.2; }
    /* Créneau pris : puce + croix de retrait centrées et compactes */
    .planning td .repas-pris { display: inline-block; }
    .planning td .btn-link-repas { padding: 0; }
}

/* --- Relevé du compte commun --- */
.releve-tete { display: flex; flex-wrap: wrap; gap: 1.5rem; justify-content: space-around; }
.releve-chiffre { display: flex; flex-direction: column; align-items: center; }
.releve-label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.releve-montant { font-size: 1.5rem; font-weight: 700; color: var(--nuit); }
.releve-montant.neg { color: var(--corail); }
.mvt-in .num.pos { color: var(--vert); }
.mvt-out .num.neg { color: var(--corail); }

/* --- Badges de statut de sortie --- */
.statut { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.statut-a-effectuer { background: #fff3e0; color: #b26a00; }
.statut-confirmee { background: #e6f4ea; color: #1e7a46; }

/* Groupe de contrôles dans une cellule (badge + boutons d'action).
   flex-wrap + min-width:0 → les boutons passent à la ligne au lieu de
   déborder de la carte sur mobile (cf. cellule « Statut » du relevé). */
.cell-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; min-width: 0; }

/* --- Jauge de budget prévisionnel --- */
.jauge { margin: .6rem 0; }
.jauge-barre { height: 12px; border-radius: 999px; background: #e7ddcb; overflow: hidden; }
.jauge-barre > span { display: block; height: 100%; background: var(--mer); border-radius: 999px; }
.jauge-legende { margin-top: .35rem; font-size: .9rem; color: var(--nuit); }

/* --- Alerte « virements à effectuer » --- */
.nav-badge, .tab-badge {
    display: inline-block; min-width: 1.3em; padding: 0 .35em;
    border-radius: 999px; background: var(--corail); color: #fff;
    font-size: .72rem; font-weight: 700; line-height: 1.4; text-align: center;
    vertical-align: middle;
}
.alerte-virements {
    display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
    margin: 0 0 1rem; padding: .7rem 1rem;
    background: #fff3e0; border: 1px solid var(--corail); border-left: 4px solid var(--corail);
    border-radius: 12px; color: var(--nuit); font-weight: 600; text-decoration: none;
}
.alerte-virements:hover { background: #ffe9d1; }
.alerte-virements .alerte-fleche { margin-left: auto; color: var(--corail); font-weight: 700; white-space: nowrap; }
.virements-a-faire { border: 2px solid var(--corail); }
