/* Agenda familial : styles de base, pensés pour le téléphone d'abord. */

:root {
    --fond: #F3F4F6;
    --carte: #FFFFFF;
    --texte: #111827;
    --texte-doux: #6B7280;
    --bordure: #D1D5DB;
    --principal: #2563EB;
    --erreur: #B91C1C;
    --rayon: 14px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --fond: #0F172A;
        --carte: #1E293B;
        --texte: #F1F5F9;
        --texte-doux: #94A3B8;
        --bordure: #334155;
        --principal: #3B82F6;
        --erreur: #FCA5A5;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--fond);
    color: var(--texte);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.app {
    min-height: 100dvh;
    max-width: 440px;
    margin: 0 auto;
    padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 20px;
}

h1 { margin: 0; font-size: 1.5rem; line-height: 1.25; text-align: center; }
p { margin: 0; color: var(--texte-doux); }

.carte {
    background: var(--carte);
    border-radius: var(--rayon);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.centre { align-items: center; text-align: center; }
.centre .bouton { align-self: stretch; }

.champ { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; color: var(--texte-doux); }

input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--bordure);
    border-radius: 10px;
    background: var(--fond);
    color: var(--texte);
    font: inherit;
}

input:focus-visible, button:focus-visible { outline: 3px solid var(--principal); outline-offset: 2px; }

.pin { max-width: 200px; text-align: center; font-size: 1.6rem; letter-spacing: 0.4em; }

.bouton {
    padding: 14px;
    border: 0;
    border-radius: 10px;
    background: var(--principal);
    color: #FFFFFF;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.lien {
    padding: 10px;
    border: 0;
    background: none;
    color: var(--principal);
    font: inherit;
    cursor: pointer;
}

.erreur { min-height: 1.5em; color: var(--erreur); font-size: 0.9rem; text-align: center; }

.profils { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; }

.profil {
    padding: 18px 8px;
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    background: var(--carte);
    color: var(--texte);
    font: inherit;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.pastille {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    font-weight: 700;
}

.pastille-grande { width: 64px; height: 64px; font-size: 1.6rem; }

/* ----- Étape 2 : vue jour et formulaire d'événement ----- */

[hidden] { display: none !important; }

.app.plein {
    height: 100dvh;
    max-width: 640px;
    padding: 0;
    gap: 0;
    justify-content: flex-start;
    position: relative;
}

.entete {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 8px;
    background: var(--carte);
    border-bottom: 1px solid var(--bordure);
}

.entete-date { flex: 1; display: flex; flex-direction: column; align-items: center; line-height: 1.3; }
.entete-date strong::first-letter { text-transform: uppercase; }
.aujourdhui { color: var(--principal); font-size: 0.85rem; font-weight: 600; }

.icone {
    min-width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: none;
    color: var(--texte);
    font: inherit;
    font-size: 1.6rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.petit { font-size: 0.85rem; padding: 0; }
.danger { color: var(--erreur); }


.zone-grille { flex: 1; overflow-y: auto; }
.grille { position: relative; display: flex; }
.gouttiere { position: relative; flex: 0 0 48px; }
.colonne { position: relative; flex: 1; min-width: 0; border-left: 1px solid var(--bordure); }

.creneau {
    position: absolute;
    left: 0;
    right: 0;
    padding: 0;
    border: 0;
    border-top: 1px solid var(--bordure);
    background: none;
    cursor: pointer;
}

.heure { position: absolute; right: 6px; margin-top: 2px; color: var(--texte-doux); font-size: 0.75rem; }

.evt {
    position: absolute;
    overflow: hidden;
    padding: 3px 8px;
    border: 1.5px solid var(--c);
    border-radius: 8px;
    font: inherit;
    font-size: 0.85rem;
    line-height: 1.3;
    text-align: left;
    display: flex;
    flex-direction: column;
    cursor: pointer;
}

.evt strong, .evt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.evt span { font-size: 0.75rem; opacity: 0.9; }
.evt-mien { background: var(--c); color: #FFFFFF; }
.evt-autre { background: color-mix(in srgb, var(--c) 16%, var(--carte)); color: var(--texte); }

.maintenant { position: absolute; left: 0; right: 0; height: 2px; background: #DC2626; pointer-events: none; }

.plus {
    position: absolute;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    width: 56px;
    height: 56px;
    border: 0;
    border-radius: 50%;
    background: var(--principal);
    color: #FFFFFF;
    font-size: 2rem;
    line-height: 1;
    box-shadow: 0 4px 12px rgb(0 0 0 / 0.25);
    cursor: pointer;
}

textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--bordure);
    border-radius: 10px;
    background: var(--fond);
    color: var(--texte);
    font: inherit;
    resize: vertical;
}

input[type="checkbox"] { width: 20px; height: 20px; padding: 0; accent-color: var(--principal); }
.ligne { display: flex; align-items: center; gap: 10px; }
.duo { display: flex; gap: 8px; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 6px; }
.puces { display: flex; flex-wrap: wrap; gap: 8px; }

.puce {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 8px;
    border: 1px solid var(--bordure);
    border-radius: 999px;
    color: var(--texte);
    cursor: pointer;
}

.puce .pastille { width: 26px; height: 26px; font-size: 0.8rem; }

/* ----- Étape 3 : vues semaine et mois, sélecteur de vue, filtre par profil ----- */

.barre { display: flex; flex-direction: column; gap: 8px; padding: 8px; background: var(--carte); border-bottom: 1px solid var(--bordure); }

.selecteur { display: flex; padding: 3px; border-radius: 10px; background: var(--fond); }

.selecteur-choix {
    flex: 1;
    padding: 7px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--texte-doux);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.selecteur-choix[aria-pressed="true"] { background: var(--carte); color: var(--texte); box-shadow: 0 1px 3px rgb(0 0 0 / 0.15); }

.filtre { display: flex; gap: 6px; overflow-x: auto; }
.filtre:empty { display: none; }
.puce-filtre { flex: none; padding: 4px 10px 4px 5px; background: none; font: inherit; font-size: 0.85rem; }
.puce-filtre[aria-pressed="false"] { opacity: 0.45; text-decoration: line-through; }

/* Au-dessus de la grille : jours de la semaine et événements "journée entière" */
.haut-grille { display: flex; background: var(--carte); border-bottom: 1px solid var(--bordure); }
.colonne-haut { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; padding: 4px 2px; }
.haut-grille .evt { position: static; }

.jour-semaine {
    padding: 2px 0;
    border: 0;
    background: none;
    color: var(--texte-doux);
    font: inherit;
    font-size: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.jour-semaine strong { width: 28px; height: 28px; border-radius: 50%; color: var(--texte); font-size: 0.95rem; line-height: 28px; }
.jour-actuel strong { background: var(--principal); color: #FFFFFF; }

/* Vue semaine : cartes réduites au titre */
.compact .evt { padding: 2px 3px; border-radius: 5px; font-size: 0.7rem; }
.compact .evt strong { white-space: normal; overflow-wrap: anywhere; }

/* Vue mois */
.mois { flex: 1; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-rows: auto repeat(6, minmax(0, 1fr)); overflow: hidden; }
.mois-entete { padding: 4px 0; color: var(--texte-doux); font-size: 0.75rem; text-align: center; }

.mois-jour {
    min-width: 0;
    padding: 3px 2px;
    border: 0;
    border-top: 1px solid var(--bordure);
    border-left: 1px solid var(--bordure);
    background: none;
    color: var(--texte);
    font: inherit;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    overflow: hidden;
    cursor: pointer;
}

.mois-jour strong { align-self: center; width: 24px; height: 24px; border-radius: 50%; font-size: 0.8rem; line-height: 24px; }
.hors-mois { color: var(--texte-doux); opacity: 0.55; }

.mois-evt {
    padding: 0 3px;
    border: 1px solid var(--c);
    border-radius: 4px;
    font-size: 0.65rem;
    line-height: 1.4;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
}

.mois-plus { color: var(--texte-doux); font-size: 0.65rem; }

/* Les événements passent au-dessus du trait de l'heure actuelle ; pas de bandeau vide en vue jour. */
.colonne .evt { z-index: 1; }
.haut-grille:not(.compact):not(:has(.evt)) { display: none; }

/* ----- Étape 4 : catégories et recherche ----- */

.app.haut { justify-content: flex-start; }

.barre-ligne { display: flex; align-items: center; gap: 8px; }
.barre-ligne .selecteur { flex: 1; }

.bouton-secondaire {
    padding: 9px 12px;
    border: 1px solid var(--bordure);
    border-radius: 10px;
    background: var(--carte);
    color: var(--principal);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--bordure);
    border-radius: 10px;
    background: var(--fond);
    color: var(--texte);
    font: inherit;
}

select:focus-visible { outline: 3px solid var(--principal); outline-offset: 2px; }

.entete-simple { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.entete-simple h1 { text-align: left; }

h2 { margin: 12px 0 0; color: var(--texte-doux); font-size: 0.9rem; font-weight: 600; }

.app.haut > input[type="search"] { background: var(--carte); }

.puce-choix { min-height: 40px; }
.puce-choix[aria-pressed="false"] { opacity: 1; text-decoration: none; }
.puce-choix[aria-pressed="true"] { border-color: var(--principal); background: var(--principal); color: #FFFFFF; }
.puce-icone { padding: 4px 10px; font-size: 1.3rem; }

.resultats { display: flex; flex-direction: column; gap: 8px; }

.resultat {
    padding: 12px;
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    background: var(--carte);
    color: var(--texte);
    font: inherit;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.resultat-date { flex: 0 0 118px; display: flex; flex-direction: column; font-size: 0.85rem; }
.resultat-date span, .resultat-texte span { color: var(--texte-doux); font-size: 0.85rem; }
.resultat-texte { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.resultat-action { color: var(--principal); font-size: 0.9rem; font-weight: 600; }

/* ----- Étape 5 : hors ligne et installation ----- */

.bandeau-hors-ligne { padding: 8px 12px; background: #FEF3C7; color: #78350F; font-size: 0.85rem; text-align: center; }
ol { margin: 0; padding-left: 1.4em; color: var(--texte-doux); }

/* Modifications hors ligne : événements en attente d'envoi, bilan au retour du réseau */
.evt-attente { border-style: dashed; border-color: #92400E; opacity: 0.85; }
.bandeau-synchro { padding: 8px 12px; background: #DCFCE7; color: #14532D; font-size: 0.85rem; text-align: center; }


/* Aperçu du jour dans le formulaire d'événement */
.apercu { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 10px; background: var(--fond); }
.apercu h2 { margin: 0; }
.apercu h2::first-letter { text-transform: uppercase; }
.apercu ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.apercu-ligne { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.apercu-ligne .pastille { flex: none; width: 22px; height: 22px; font-size: 0.7rem; }
.apercu-heure { flex: none; width: 96px; color: var(--texte-doux); }
.apercu-texte { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.apercu-texte strong, .apercu-texte span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apercu-texte span { color: var(--texte-doux); font-size: 0.8rem; }
.apercu-conflit { margin: 0 -6px; padding: 4px 6px; border-radius: 8px; background: #FEF3C7; color: #78350F; }
.apercu-conflit .apercu-heure, .apercu-conflit .apercu-texte span { color: #92400E; }
.apercu-alerte { flex: none; font-size: 0.75rem; font-weight: 700; }
.apercu-resume { color: #B45309; font-size: 0.85rem; font-weight: 600; }
.apercu-vide { font-size: 0.85rem; }

/* ----- Étape 6 : répétition ----- */
.actions { display: flex; flex-direction: column; gap: 8px; }
.bouton-clair { border: 1px solid var(--principal); background: var(--carte); color: var(--principal); }
.info-serie { padding: 8px 12px; border-radius: 10px; background: var(--fond); font-size: 0.9rem; }

/* ----- Étape 7 : notifications ----- */
.carte .petit { color: var(--texte-doux); }

.champ .ligne { color: var(--texte); font-size: 1rem; }
.ligne input[type="checkbox"] { flex: none; }
.ligne input[type="time"] { width: auto; }
.carte .petit:empty { display: none; }

/* ----- Ma famille et partages ----- */
.pastille-choix { width: 40px; height: 40px; padding: 0; border: 3px solid transparent; border-radius: 50%; cursor: pointer; }
.pastille-choix[aria-pressed="true"] { border-color: var(--texte); box-shadow: inset 0 0 0 2px var(--carte); }
.bloc-partage { padding-top: 12px; border-top: 1px solid var(--bordure); }
.bloc-partage h2 { margin: 0; color: var(--texte); font-size: 1rem; }
.bloc-partage .bouton-secondaire { align-self: flex-start; }


/* ----- Accueil ----- */
.entete-accueil { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.entete-accueil h1 { text-align: left; }
.carte-accueil { gap: 12px; }
.carte-accueil h1 { font-size: 1.2rem; text-align: left; }
.carte-accueil h2 { margin: 4px 0 0; }
.lignes-evt { display: flex; flex-direction: column; gap: 6px; }
.ligne-evt {
    padding: 10px;
    border: 1px solid var(--bordure);
    border-radius: 10px;
    background: var(--carte);
    color: var(--texte);
    font: inherit;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}
.ligne-evt .pastille { flex: none; width: 30px; height: 30px; font-size: 0.85rem; }
.ligne-evt-heure { flex: none; width: 66px; font-weight: 600; }
.en-cours { color: #B45309; }
.ligne-evt-texte { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ligne-evt-texte strong, .ligne-evt-texte span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne-evt-texte span { color: var(--texte-doux); font-size: 0.85rem; }
.actions-accueil { display: flex; flex-direction: column; gap: 8px; }
.carte-accueil .selecteur-choix { font-size: 0.8rem; }

/* ----- Listes ----- */
.ajout-article { display: flex; gap: 8px; }
.ajout-article input { flex: 1; background: var(--carte); }
.ajout-article .bouton { padding: 12px 16px; }
.articles ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.articles li { display: flex; gap: 6px; }
.articles h2 { margin: 16px 0 6px; }
.articles .bouton-secondaire { margin-top: 12px; }
.article {
    flex: 1;
    min-height: 52px;
    padding: 10px 12px;
    border: 1px solid var(--bordure);
    border-radius: 12px;
    background: var(--carte);
    color: var(--texte);
    font: inherit;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}
.article-case {
    flex: none;
    width: 26px;
    height: 26px;
    border: 2px solid var(--bordure);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}
.article-texte { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.article-nom { overflow-wrap: anywhere; }
.article-qui { color: var(--texte-doux); font-size: 0.8rem; }
.article-quantite { flex: none; font-weight: 700; }
.article-pris { opacity: 0.6; }
.article-pris .article-nom { text-decoration: line-through; }
.article-pris .article-case { border-color: #10B981; background: #10B981; color: #FFFFFF; }
.article-plus {
    flex: none;
    width: 44px;
    border: 1px solid var(--bordure);
    border-radius: 12px;
    background: var(--carte);
    color: var(--texte);
    font: inherit;
    font-size: 1.3rem;
    cursor: pointer;
}

/* ----- Notes et pense-bête ----- */
.pense-bete {
    padding: 12px;
    border: 1px solid #FCD34D;
    border-radius: 10px;
    background: #FEF9C3;
    color: #422006;
    font: inherit;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
}
.pense-bete-texte {
    white-space: pre-line;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    font-size: 0.9rem;
}
.carte-accueil .barre-ligne .bouton-secondaire { flex: 1; }
.note-ligne { display: flex; gap: 6px; }
.note-ligne .resultat { flex: 1; min-width: 0; }
.note-epinglee .resultat { border-color: #FCD34D; background: #FEF9C3; color: #422006; }
.punaise {
    flex: none;
    width: 52px;
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    background: var(--carte);
    font-size: 1.2rem;
    cursor: pointer;
    filter: grayscale(1);
    opacity: 0.5;
}
.punaise[aria-pressed="true"] { filter: none; opacity: 1; border-color: #FCD34D; }


/* ----- Vacances scolaires ----- */
.bandeau-vacances { padding: 6px 12px; background: #DCFCE7; color: #14532D; font-size: 0.85rem; display: flex; flex-direction: column; gap: 2px; text-align: center; }
.jour-vacances { background: #DCFCE7; border-radius: 8px; }
.mois-vacances { background: #F0FDF4; }
.vacances-accueil { margin-top: 4px; color: #15803D; font-size: 0.9rem; font-weight: 600; }