/* ==========================================================
   FM3A - Style principal
   Mobile-first, volontairement léger (pas de framework CSS),
   grands contrastes pour lisibilité en extérieur / plein soleil.
   ========================================================== */

:root {
    --couleur-fond-app: #f3f4f6;
    --couleur-texte: #111827;
    --couleur-carte: #ffffff;
    --couleur-bordure: #d1d5db;
    --couleur-succes: #16a34a;
    --couleur-erreur: #dc2626;
    --rayon: 10px;
    --espace: 12px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--couleur-fond-app);
    color: var(--couleur-texte);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 17px;
    line-height: 1.4;
}

a { color: inherit; }

.conteneur {
    max-width: 480px;
    margin: 0 auto;
    padding: var(--espace);
}

/* ---------- Login PIN ---------- */

.ecran-login {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
}

.ecran-login h1 {
    font-size: 22px;
    margin-bottom: 24px;
}

.pin-affichage {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
}

.pin-case {
    width: 44px;
    height: 54px;
    border: 2px solid var(--couleur-bordure);
    border-radius: var(--rayon);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    background: var(--couleur-carte);
}

.pin-case.remplie { border-color: #2563eb; }

.pavé-numerique {
    display: grid;
    grid-template-columns: repeat(3, 72px);
    gap: 14px;
}

.pavé-numerique button {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: none;
    background: var(--couleur-carte);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    font-size: 26px;
    font-weight: 600;
    color: var(--couleur-texte);
}

.pavé-numerique button:active { background: #e5e7eb; }

.pavé-numerique .touche-vide { visibility: hidden; }

.message-erreur {
    color: var(--couleur-erreur);
    font-weight: 600;
    margin-top: 16px;
    min-height: 22px;
}

/* ---------- Accueil : grille 2x4 des modules ---------- */

.entete {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--espace) 0;
}

.entete h1 { font-size: 20px; margin: 0; }

.lien-deconnexion {
    font-size: 14px;
    text-decoration: none;
    color: #6b7280;
}

.grille-modules {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--espace);
    margin-top: 8px;
}

.panel-module {
    aspect-ratio: 1 / 0.85;
    border-radius: var(--rayon);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    font-weight: 700;
    font-size: 16px;
    text-align: center;
    padding: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.panel-module .icone { font-size: 30px; }

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

.carte {
    background: var(--couleur-carte);
    border-radius: var(--rayon);
    padding: var(--espace);
    margin-bottom: var(--espace);
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.champ { margin-bottom: 14px; }

.champ label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 15px;
}

.champ input[type=text],
.champ input[type=number],
.champ input[type=tel],
.champ input[type=url],
.champ select,
.champ textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--couleur-bordure);
    border-radius: 8px;
    font-size: 16px;
    background: #fff;
    color: var(--couleur-texte);
}

.champ input:focus,
.champ select:focus,
.champ textarea:focus {
    outline: none;
    border-color: #2563eb;
}

.bouton {
    display: inline-block;
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 17px;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
}

.bouton-primaire { background: #2563eb; color: #fff; }
.bouton-danger { background: var(--couleur-erreur); color: #fff; }
.bouton-secondaire { background: #e5e7eb; color: var(--couleur-texte); }

.barre-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

/* ---------- Liste des membres ---------- */

.barre-recherche {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--couleur-bordure);
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: var(--espace);
}

.ligne-membre {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--couleur-bordure);
}

.ligne-membre:last-child { border-bottom: none; }

.ligne-membre .nom-complet { font-weight: 700; }
.ligne-membre .sous-info { font-size: 13px; color: #6b7280; }

.badge-sexe {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    margin-left: 6px;
}
.badge-sexe.M { background: #dbeafe; color: #1d4ed8; }
.badge-sexe.F { background: #fce7f3; color: #be185d; }

.bouton-flottant {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: #2563eb;
    color: #fff;
    font-size: 30px;
    border: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---------- Champs NPAPA (numérotation auto) ---------- */

.npapa-conteneur {
    border: 2px solid var(--couleur-bordure);
    border-radius: 8px;
    background: #fff;
}

.npapa-ligne {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
}

.npapa-ligne:last-child { border-bottom: none; }

.npapa-numero {
    font-weight: 700;
    color: #6b7280;
    min-width: 22px;
    padding-top: 2px;
}

.npapa-texte {
    flex: 1;
    border: none;
    resize: none;
    font-size: 16px;
    font-family: inherit;
    padding: 2px 0;
}
.npapa-texte:focus { outline: none; }

.npapa-case {
    width: 20px;
    height: 20px;
    margin-top: 4px;
    flex-shrink: 0;
}

.npapa-ligne.resolu .npapa-texte {
    text-decoration: line-through;
    color: #9ca3af;
}

/* ---------- Liste de présence (cases à cocher membres) — grille compacte ---------- */

.liste-presence {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    border: 2px solid var(--couleur-bordure);
    border-radius: 8px;
    background: #fff;
    max-height: 340px;
    overflow-y: auto;
}

.ligne-presence {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px;
    border-bottom: 1px solid #eee;
}
.ligne-presence:nth-child(odd) { border-right: 1px solid #eee; }

.ligne-presence label {
    font-weight: 600;
    font-size: 14px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ligne-presence input[type=checkbox] {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

/* ---------- Répartition de montants (membre + montant) ---------- */

.liste-repartition {
    border: 2px solid var(--couleur-bordure);
    border-radius: 8px;
    background: #fff;
    max-height: 340px;
    overflow-y: auto;
}

.ligne-repartition {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
}
.ligne-repartition:last-child { border-bottom: none; }

.ligne-repartition label { font-weight: 600; font-size: 14px; flex: 1; }

.ligne-repartition input[type=number] {
    width: 110px;
    padding: 8px;
    border: 2px solid var(--couleur-bordure);
    border-radius: 6px;
    font-size: 15px;
    text-align: right;
}

.ligne-libre-repartition {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
}
.ligne-libre-repartition input[type=text] {
    flex: 1;
    padding: 8px;
    border: 2px solid var(--couleur-bordure);
    border-radius: 6px;
    font-size: 14px;
}
.ligne-libre-repartition input[type=number] {
    width: 110px;
    padding: 8px;
    border: 2px solid var(--couleur-bordure);
    border-radius: 6px;
    font-size: 15px;
    text-align: right;
}
.ligne-libre-repartition button {
    background: none;
    border: none;
    color: var(--couleur-erreur);
    font-size: 20px;
    line-height: 1;
    padding: 4px 8px;
    cursor: pointer;
}

.bouton-ajouter-ligne {
    width: 100%;
    padding: 10px;
    background: #f3f4f6;
    border: 2px dashed var(--couleur-bordure);
    border-radius: 8px;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    margin-top: 8px;
}

.total-repartition {
    display: flex;
    justify-content: space-between;
    padding: 12px;
    border-radius: 8px;
    font-weight: 700;
    margin-top: 10px;
}
.total-repartition.ok { background: #dcfce7; color: #166534; }
.total-repartition.ko { background: #fee2e2; color: #991b1b; }

/* ---------- Liste POM (case à cocher + montant par membre) ---------- */

.liste-pom {
    border: 2px solid var(--couleur-bordure);
    border-radius: 8px;
    background: #fff;
    max-height: 380px;
    overflow-y: auto;
}

.ligne-pom {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
}
.ligne-pom:last-child { border-bottom: none; }

.ligne-pom label {
    font-weight: 600;
    font-size: 14px;
    flex: 1;
}

.ligne-pom input[type=checkbox] {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.ligne-pom input[type=number] {
    width: 100px;
    padding: 8px;
    border: 2px solid var(--couleur-bordure);
    border-radius: 6px;
    font-size: 15px;
    text-align: right;
}
.ligne-pom input[type=number]:disabled {
    background: #f3f4f6;
    color: #9ca3af;
}

/* ---------- Liste TAFITA (participant + emprunteur) ---------- */

.liste-tafita {
    border: 2px solid var(--couleur-bordure);
    border-radius: 8px;
    background: #fff;
    max-height: 380px;
    overflow-y: auto;
}

.entete-tafita {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 12px;
    background: #f3f4f6;
    font-size: 12px;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    position: sticky;
    top: 0;
}
.entete-tafita span:first-child { flex: 1; text-align: left; }
.entete-tafita span { width: 72px; text-align: center; }

.ligne-tafita {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
}
.ligne-tafita:last-child { border-bottom: none; }

.ligne-tafita label.nom-membre {
    flex: 1;
    font-weight: 600;
    font-size: 14px;
}

.ligne-tafita .case-tafita {
    width: 72px;
    display: flex;
    justify-content: center;
}
.ligne-tafita .case-tafita:last-child {
    border-left: 1px solid #eee;
}
.ligne-tafita .case-tafita input[type=checkbox] {
    width: 22px;
    height: 22px;
}

.compteur-presence {
    font-size: 13px;
    color: #6b7280;
    margin-top: 6px;
}

.encart-info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    color: #1e40af;
    margin-bottom: 14px;
}

.selecteur-association {
    text-align: center;
    padding: 30px 10px;
}
.selecteur-association select {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    border: 2px solid var(--couleur-bordure);
    border-radius: 8px;
    margin: 16px 0;
}

/* ---------- Utilitaires ---------- */

.texte-centre { text-align: center; }
.marge-haut { margin-top: var(--espace); }
.cache { display: none !important; }

@media (min-width: 700px) {
    .conteneur { max-width: 640px; }
}
