/* =========================================================
   DASHBOARD & MODULE ACTIVITÉS
   Palette : var(--c-primary) (primaire), #f5f7fb (fond), #222 (texte)
========================================================= */

/* ---- En-tête ---- */
.dashboard-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding-bottom: 16px;
    margin-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
}
.dashboard-hero h1 {
    margin: 0;
    font-size: 24px;
}
.dashboard-hero-sub {
    margin: 4px 0 0;
    color: var(--c-neutral);
    font-size: 14px;
}
.dashboard-section-title {
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--c-ghost-text);
    margin: 28px 0 12px;
}

/* ---- Bannières ---- */
.dashboard-banner {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin: 16px 0;
    font-size: 14px;
}
.dashboard-banner-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

/* ---- KPI ---- */
.kpi-grid {
    display: grid;
    /* Toutes les cartes sur une seule ligne, largeur égale quel que soit le nombre. */
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 16px;
}
.stat-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-lg);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: center;
}
/* Un indicateur qui mène quelque part le montre : même relief au survol que les
   cartes « À traiter ». Les autres restent des cartes inertes, sans faux affordant. */
.stat-card--link {
    color: inherit;
    text-decoration: none;
    transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.stat-card--link:hover {
    transform: translateY(-2px);
    border-color: #c7d2fe;
    box-shadow: 0 4px 14px rgba(31, 60, 136, .15);
}
.stat-value {
    font-size: 30px;
    font-weight: 800;
    color: var(--c-primary);
    line-height: 1;
}
.stat-label {
    font-size: 13px;
    color: var(--c-neutral);
}

/* ---- Cartes "à faire / à traiter" ---- */
.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}
.action-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 18px;
    border-radius: var(--radius-lg);
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    color: #1e3a8a;
    text-decoration: none;
    transition: transform .12s ease, box-shadow .12s ease;
}
.action-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(31, 60, 136, .15);
}
.action-card-alert {
    background: #fef2f2;
    border-color: #fecaca;
    color: var(--c-danger);
}
.action-card-count {
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
}
.action-card-label {
    font-size: 14px;
}

/* ---- Cartes entités (enfants / activités) ---- */
.entity-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}
.entity-card {
    display: block;
    padding: 18px;
    border-radius: var(--radius-lg);
    background: #fff;
    border: 1px solid #e2e8f0;
    text-decoration: none;
    color: #222;
    transition: transform .12s ease, box-shadow .12s ease;
}
.entity-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, .1);
}
.entity-card h3 {
    margin: 8px 0 4px;
    font-size: 16px;
}
.entity-card-meta {
    margin: 0;
    font-size: 13px;
    color: var(--c-neutral);
}
.entity-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--c-primary);
    color: #fff;
    font-weight: 700;
    font-size: 16px;
}
/* Distinction discrète garçons / filles (accent sobre, pas de surcharge). */
.entity-card--boy  { border-top: 3px solid #3b82f6; }
.entity-card--girl { border-top: 3px solid #d6608f; }
.entity-card--boy  .entity-avatar { background: #2563eb; }
.entity-card--girl .entity-avatar { background: #be5a86; }
/* Photo de l'enfant dans le rond (remplace les initiales). */
.entity-avatar-photo { object-fit: cover; padding: 0; background: none !important; }
.entity-card-tag {
    display: inline-block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #1e3a8a;
    background: #eef2ff;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
}
.entity-card-children {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ---- Lanceur de modules ---- */
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
}
/* Pilotage : trois colonnes côte à côte, de même hauteur, + respiration dessous. */
.pilotage-cols {
    display: grid;
    /* auto-fit : les blocs restants se répartissent la largeur quand une méga-carte
       est masquée (faute de droits) au lieu de laisser une colonne vide. */
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
    align-items: stretch;
    margin-bottom: 40px;
}
.pilotage-block {
    border: 1px solid var(--c-ghost-border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-bottom: 18px;
}
/* Dans la grille, les blocs d'une même ligne s'étirent à la hauteur du plus grand. */
.pilotage-cols .pilotage-block {
    margin-bottom: 0;
    height: 100%;
}
.pilotage-title {
    margin: 0 0 12px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid rgba(0, 0, 0, .12);
    padding-bottom: 8px;
}
/* Teintes de fond contrastées par type de bloc + accent de titre assorti. */
.pilotage-block--daily  { background: #dbe7fb; border-color: #93b4f0; }
.pilotage-block--daily  .pilotage-title { color: #1e3a8a; }
.pilotage-block--config { background: #fde9cf; border-color: #f3c07a; }
.pilotage-block--config .pilotage-title { color: #9a3412; }
.pilotage-block--super  { background: #d8f3e3; border-color: #8bd6ab; }
.pilotage-block--super  .pilotage-title { color: #065f46; }
/* Cartes en blanc pour ressortir sur le fond teinté du bloc. */
.pilotage-block .module-card {
    background: #fff;
    border-color: rgba(0, 0, 0, .08);
}
@media (max-width: 900px) {
    .pilotage-cols { grid-template-columns: 1fr; }
}
.module-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 18px 12px;
    border-radius: var(--radius-lg);
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    text-decoration: none;
    color: var(--c-primary);
    font-weight: 600;
    font-size: 14px;
    text-align: center;
    transition: background .12s ease, transform .12s ease;
}
.module-card:hover {
    background: #eef2ff;
    transform: translateY(-2px);
}
/* Format uniforme des cartes du tableau de bord (Effectifs / À traiter / Pilotage) :
   même hauteur, contenu centré verticalement, padding homogène. */
.stat-card, .action-card, .module-card {
    min-height: 104px;
    padding: 18px 14px;
    box-sizing: border-box;
    justify-content: center;
}
.module-icon {
    font-size: 26px;
}

/* ---- Listes ---- */
.dashboard-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.dashboard-list li {
    padding: 10px 0;
    border-bottom: 1px solid #eef2f7;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.dashboard-list a {
    color: var(--c-primary);
    text-decoration: none;
    font-weight: 600;
}
.dashboard-list-meta {
    color: var(--c-neutral);
    font-size: 13px;
    flex-basis: 100%; /* toujours sur sa propre ligne, quel que soit le badge */
}
.dashboard-split {
    align-items: start;
}

/* ---- Barres effectifs ---- */
.dash-bars {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
/* Effectifs par groupe en 2 colonnes par côté. */
.dash-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; }
.dash-col-title { margin: 0 0 10px; font-size: 14px; }
.dash-bar-row--unit { font-style: italic; color: var(--c-ghost-text); }
.dash-bar-row {
    display: grid;
    grid-template-columns: 120px 1fr 40px;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}
.dash-bar-label {
    color: var(--c-ghost-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dash-bar-track {
    background: #eef2f7;
    border-radius: var(--radius-pill);
    height: 12px;
    overflow: hidden;
}
.dash-bar-fill {
    display: block;
    height: 100%;
    background: var(--c-primary);
    border-radius: var(--radius-pill);
}
.dash-bar-value {
    text-align: right;
    font-weight: 700;
    color: var(--c-primary);
}

/* Groupe dépliable → effectifs par unité */
.dash-group-toggle {
    width: 100%;
    background: none;
    border: 0;
    padding: 4px 0;
    cursor: pointer;
    font: inherit;
}
.dash-caret {
    display: inline-block;
    transition: transform 0.15s;
    color: #94a3b8;
    font-size: 11px;
}
.dash-group-toggle[aria-expanded="true"] .dash-caret {
    transform: rotate(90deg);
}
.dash-units {
    margin: 2px 0 6px 12px;
    padding-left: 12px;
    border-left: 2px solid #eef2f7;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
/* L'attribut hidden doit l'emporter sur display:flex (repli par défaut). */
.dash-units[hidden] {
    display: none;
}
.dash-unit-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--c-ghost-text);
}
.dash-unit-row .dash-unit-value {
    font-weight: 700;
    color: var(--c-primary);
}

/* =========================================================
   BADGES DE STATUT (activités & inscriptions)
========================================================= */
.activity-status,
.activity-reg-status {
    display: inline-block;
    font-size: 12px;
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    font-weight: 600;
    white-space: nowrap;
}
.activity-status-draft       { background: var(--c-ghost-hover-bg); color: var(--c-ghost-text); }
.activity-status-published   { background: #dcfce7; color: #166534; }
.activity-status-closed      { background: #fef3c7; color: #92400e; }
.activity-status-archived    { background: #e2e8f0; color: var(--c-ghost-text); }
/* Statuts propres aux campagnes (mêmes pastilles, cycle de vie voisin). */
.activity-status-open        { background: #dcfce7; color: #166534; }
.activity-status-scheduled   { background: #eef2ff; color: #3730a3; }

.activity-reg-invited     { background: #eef2ff; color: #3730a3; }
.activity-reg-registered  { background: #dcfce7; color: #166534; }
.activity-reg-waitlisted  { background: #fef3c7; color: #92400e; }
.activity-reg-cancelled   { background: var(--c-danger-bg); color: var(--c-danger); }

.activity-lifecycle {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}
.communication-warning-inline {
    color: var(--c-danger);
    font-size: 12px;
    font-weight: 600;
}

/* ---- Accusés de réception « Information reçue » ---- */
.receipt-badge {
    display: inline-block;
    font-size: 12px;
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    font-weight: 600;
    white-space: nowrap;
}
.receipt-ok      { background: #dcfce7; color: #166534; }
.receipt-pending { background: #fef3c7; color: #92400e; }
.receipt-na      { background: var(--c-ghost-hover-bg); color: #94a3b8; }

/* ---- Attestation fiche sanitaire ---- */
.health-attest {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin: 12px 0;
    font-size: 14px;
    border: 1px solid transparent;
}
.health-attest-ok       { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.health-attest-warn     { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.health-attest-expired  { background: var(--c-danger-bg); color: var(--c-danger); border-color: #fecaca; }
.health-attest-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 0;
}
.health-attest-certify {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
    margin: 0;
}
.health-attest-certify input { width: auto; }

/* ---- Onglets (mappage gabarits) ---- */
.pdf-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    border-bottom: 2px solid #e2e8f0;
    margin: 12px 0 16px;
}
.pdf-tab {
    padding: 9px 16px;
    cursor: pointer;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: var(--radius-md) 10px 0 0;
    background: var(--c-ghost-hover-bg);
    color: var(--c-ghost-text);
    font-weight: 600;
    font-size: 14px;
}
.pdf-tab:hover { background: #e8eef6; }
.pdf-tab.is-active {
    background: #fff;
    color: var(--c-primary);
    border-color: #e2e8f0;
    box-shadow: inset 0 -3px 0 var(--c-primary);
}
.pdf-panel { display: none; }
.pdf-panel.is-active { display: block; }

.template-upload {
    background: #f8fafc;
    border: 1px dashed var(--c-ghost-border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}
/* ---- Tableau invitations activité ---- */
.activity-invite-table select {
    width: auto;
    min-width: 150px;
    max-width: 100%;
}
.activity-invite-table td,
.activity-invite-table th {
    white-space: normal;
}
.activity-invite-table .col-check { width: 34px; text-align: center; }

/* ---- Gestion des participants : barre d'actions de masse ---- */
.activity-mass-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    margin: 8px 0 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-lg);
}
.activity-mass-sep { flex: 1 1 auto; }

/* Boutons d'action en pictos par ligne (alignés sur la liste des familles) */
.activity-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

/* Description riche d'activité (rendu HTML) */
.activity-description { margin: 8px 0; }
.activity-description ul,
.activity-description ol { margin: 6px 0 6px 20px; }

/* Éditeur de mail d'invitation */
.activity-invite-editor {
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    margin: 12px 0 18px;
}
.activity-invite-editor h3 { margin-top: 0; color: var(--c-primary); }

/* Ligne hors périmètre d'action (visible mais non modifiable) */
.activity-invite-table tr.row-readonly { background: #fafafa; color: #94a3b8; }

.template-upload input[type="file"] {
    width: auto;
    border: 1px solid var(--c-ghost-border);
    border-radius: var(--radius-md);
    padding: 8px;
    background: #fff;
}

/* ---- Page d'aide ---- */
.help-intro { color: var(--c-ghost-text); }
.help-toc {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin: 16px 0 24px;
}
.help-toc ul {
    columns: 2;
    margin: 8px 0 0;
    padding-left: 18px;
}
.help-toc a { color: var(--c-primary); text-decoration: none; }
.help-toc a:hover { text-decoration: underline; }
.help-section {
    border-top: 1px solid #eef2f7;
    padding: 18px 0;
    scroll-margin-top: 16px;
}
.help-section h2 { color: var(--c-primary); font-size: 18px; margin: 0 0 10px; }
.help-section ul { margin: 8px 0; }
.help-section li { margin: 4px 0; }
.help-note { color: var(--c-neutral); font-size: 13px; font-style: italic; }
/* Section visée par un picto d'aide contextuelle : elle doit se distinguer tout
   de suite du reste de la page, sinon on atterrit au milieu d'un mur de texte
   sans savoir où commence la réponse. */
.help-section:target {
    background: #fffbeb;
    border-left: 4px solid #f59e0b;
    padding-left: 14px;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.help-section h3 { font-size: 15px; margin: 14px 0 4px; }
@media (max-width: 700px) { .help-toc ul { columns: 1; } }

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .kpi-grid {
        grid-auto-flow: row;
        grid-template-columns: repeat(2, 1fr);
    }
    .dash-bar-row {
        grid-template-columns: 90px 1fr 34px;
    }
}

/* Effectifs par groupe : un bloc par groupe (en-tête cliquable vers la fiche) et
   ses unités en badges côte à côte, chacun menant à la fiche de l'unité. Remplace
   l'ancien tableau à deux colonnes : sur deux unités par groupe, la comparaison se
   lit d'un coup d'œil et l'effectif reste lisible. */
.effectifs-side { min-width: 0; }
.effectifs-side-head { margin: 0 0 8px; }
.effectifs-group { margin-bottom: 12px; }
.effectifs-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 10px;
    background: var(--c-ghost-hover-bg);
    border-radius: var(--radius-sm);
    color: var(--c-primary);
    font-weight: 700;
    text-decoration: none;
}
.effectifs-group-head:hover { background: #e2e8f0; }
.effectifs-group-total { color: #334155; font-variant-numeric: tabular-nums; }
.effectifs-units { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 0 10px; }
.effectifs-units--district { margin-left: 0; }
.unit-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 0;
    min-width: 120px;
    padding: 7px 12px;
    border: 1px solid var(--c-ghost-border);
    border-radius: var(--radius-pill);
    background: #fff;
    color: #334155;
    text-decoration: none;
    font-size: .92rem;
}
.unit-badge:hover { border-color: var(--c-primary); background: #eef2ff; color: var(--c-primary); }
.unit-badge-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unit-badge-count {
    margin-left: auto;
    min-width: 24px;
    padding: 1px 7px;
    border-radius: var(--radius-pill);
    background: var(--c-primary);
    color: #fff;
    font-weight: 700;
    font-size: .82rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.unit-badge--district { border-style: dashed; }

/* Couleurs des BRANCHES sur les badges d'unité : jaune louveteaux/jeannettes,
   vert éclaireurs/guides, rouge routiers/guides aînées. Fond très clair pour
   rester lisible et ne pas concurrencer les liens ; la bordure porte la teinte. */
.unit-badge.branch-louveteaux { background: #fefce8; border-color: #eab308; }
.unit-badge.branch-louveteaux:hover { background: #fef9c3; color: #854d0e; }
.unit-badge.branch-eclaireurs { background: #f0fdf4; border-color: #22c55e; }
.unit-badge.branch-eclaireurs:hover { background: #dcfce7; color: #166534; }
.unit-badge.branch-routiers { background: #fef2f2; border-color: #ef4444; }
.unit-badge.branch-routiers:hover { background: var(--c-danger-bg); color: #991b1b; }

/* Effectif : bleu côté garçons (couleur générale du portail), fuchsia côté filles. */
.unit-badge--girls .unit-badge-count { background: #c026d3; }
