/*
 * ahmZakat26 — feuille de style unique, servie localement (aucune ressource externe : CSP stricte).
 * Charte : noir et blanc uniquement, sans couleur. Les états se distinguent par le gris, le trait, la hachure
 * et toujours par un texte (jamais par la seule couleur). Identité : le mot « Zakat », sans logo.
 */

:root {
    --ink: #000000;          /* texte, traits forts, boutons */
    --paper: #ffffff;        /* fond */
    --grey-1: #f3f3f3;       /* fonds discrets (survol, champs désactivés) */
    --grey-2: #e2e2e2;       /* fonds marqués (refusé, réservé) */
    --line: #c8c8c8;         /* séparateurs fins */
    --muted: #595959;        /* texte secondaire (contraste 7:1 sur blanc) */
    --hatch: repeating-linear-gradient(135deg, #ffffff 0 5px, #d6d6d6 5px 7px);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-title: Georgia, "Times New Roman", serif;
    color-scheme: light;
}

* { box-sizing: border-box; }

body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--font); }

a { color: var(--ink); text-underline-offset: .15em; }
a:hover { text-decoration-thickness: 2px; }
h1 { font-family: var(--font-title); font-weight: 400; font-size: 1.9rem; line-height: 1.2; margin: 0 0 1.25rem; }
h2 { font-size: .8rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; margin: 1.5rem 0 .6rem; }
.muted, .help { color: var(--muted); }
.help { font-size: .875rem; margin: -.25rem 0 .75rem; }
.mono, .codes { font-family: ui-monospace, Menlo, Consolas, monospace; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--grey-1); padding: 0 .25rem; }

/* Identité : logo d'AHM (ancienne version), « Zakat », logo du Comité des Imams de l'Isère — tout en noir */
.wordmark { font-family: var(--font-title); font-size: 1.9rem; font-weight: 700; letter-spacing: .02em; line-height: 1; color: var(--ink); }
.wordmark-large { font-size: 2.6rem; }
.logos { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.logos img { display: block; height: auto; }
.logos-title { text-decoration: none; text-align: center; flex: 1; }
.logo-cii { display: flex; align-items: center; gap: .6rem; }
.logo-cii-name { font-size: .78rem; font-weight: 700; letter-spacing: .06em; line-height: 1.25; text-transform: uppercase; text-align: left; }
/* En-tête des pages : bande au-dessus du menu */
.logos-bar { padding: .6rem 16px; border-bottom: 1px solid var(--ink); }
.logos-bar .logo-ahm { width: 150px; }
.logos-bar .logo-cii img { height: 54px; width: auto; }
/* Connexion et erreurs : les deux logos de part et d'autre, « Zakat » en dessous */
.logos-card { flex-wrap: wrap; }
.logos-card .logo-ahm { width: 140px; }
.logos-card .logo-cii img { height: 70px; width: auto; }
.logos-card .logos-title { order: 3; flex-basis: 100%; padding-top: .9rem; margin-top: .3rem; border-top: 1px solid var(--ink); }
/* Impressions : version compacte */
.logos-print .logo-ahm { width: 120px; }
.logos-print .logo-cii img { height: 40px; width: auto; }
.logos-print .wordmark { font-size: 1.4rem; }
@media (max-width: 640px) {
    .logos-bar .logo-ahm { width: 104px; }
    .logos-bar .logo-cii img { height: 40px; }
    .logos-bar .logo-cii-name { display: none; }
    .logos-bar .wordmark { font-size: 1.5rem; }
}

/* Pages invitées (connexion, invitation, erreurs) */
.guest { display: grid; place-items: center; min-height: 100vh; padding: 16px; background: var(--paper); }
.guest-card { width: 100%; max-width: 420px; border: 2px solid var(--ink); padding: 2rem 1.5rem; background: var(--paper); }
.guest-header { margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--ink); }
.guest-card h1 { font-size: 1.5rem; }

/* Application */
.topbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem;
    background: var(--paper); border-bottom: 2px solid var(--ink); padding: .75rem 16px;
}
.menu { display: flex; flex-wrap: wrap; gap: .15rem; flex: 1; }
.menu a { padding: .35rem .65rem; text-decoration: none; color: var(--ink); border: 1px solid transparent; }
.menu a:hover { border-color: var(--ink); }
.menu a.active { background: var(--ink); color: var(--paper); }
.logout { display: flex; align-items: center; gap: .75rem; margin-left: auto; }
.who { color: var(--muted); font-size: .875rem; }
.page { max-width: 1100px; margin: 0 auto; padding: 1.75rem 16px 3rem; }
.panel { background: var(--paper); border: 1px solid var(--ink); padding: 1.25rem; margin-bottom: 1rem; }
.panel > h2:first-child, .panel > section > h2:first-child { margin-top: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; }
.panel .actions:last-child, form .actions:last-child { margin-bottom: 0; }

/* Formulaires */
.form { display: flex; flex-direction: column; max-width: 480px; }
.form-inline { max-width: 260px; }
.form label { font-weight: 600; margin-bottom: .25rem; }
.form input, .form select { margin-bottom: .75rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="tel"],
input[type="date"], input[type="time"], input[type="number"], select, textarea {
    font: inherit; color: var(--ink); background: var(--paper);
    border: 1px solid var(--ink); border-radius: 0; padding: .5rem .65rem; width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; box-shadow: 0 0 0 1px var(--ink); }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 600; margin-bottom: .75rem; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--ink); width: 1.05rem; height: 1.05rem; }
textarea { resize: vertical; }

/* Boutons : noir plein, contour, ou contour doublé pour les actions destructives */
.button {
    display: inline-block; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
    background: var(--ink); color: var(--paper); border: 1px solid var(--ink); border-radius: 0; padding: .5rem 1rem;
}
.button:hover { background: var(--paper); color: var(--ink); }
.button-ghost { background: var(--paper); color: var(--ink); }
.button-ghost:hover { background: var(--ink); color: var(--paper); }
.button-danger { background: var(--paper); color: var(--ink); border: 3px double var(--ink); }
.button-danger:hover { background: var(--ink); color: var(--paper); }
.button-small { padding: .25rem .6rem; font-size: .85rem; }
.button-muted { background: var(--grey-2); color: var(--ink); border-color: var(--grey-2); }
.button-muted:hover { background: var(--paper); border-color: var(--ink); }
button:disabled { opacity: .5; cursor: progress; }

/* Messages */
.alert { padding: .75rem 1rem; margin: 0 0 1rem; border: 1px solid var(--ink); }
.alert p { margin: 0; }
.alert-success { border-left: 6px solid var(--ink); }
.alert-error { background: var(--ink); color: var(--paper); }
.alert-error a { color: var(--paper); }
.alert-warning { background: var(--grey-1); border-style: dashed; }
.ok { font-weight: 700; }
.ko { font-weight: 700; text-decoration: underline; text-decoration-style: double; }
.details { margin-top: 1rem; }
.details summary { cursor: pointer; font-weight: 600; }
.danger-zone { border-style: dashed; }
.pre { white-space: pre-line; }

/* Étiquettes */
.tag { display: inline-block; font-size: .78rem; font-weight: 600; padding: .05rem .5rem; border: 1px solid var(--ink); }
.tag-on { background: var(--ink); color: var(--paper); }
.tag-off { text-decoration: line-through; }
.tag-wait { background: var(--grey-2); border-style: dashed; }

/* Double authentification */
.otp { font-size: 1.6rem; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }
.qr { display: inline-block; background: var(--paper); padding: 12px; border: 1px solid var(--ink); }
.qr svg { display: block; width: 200px; height: 200px; }
.codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .4rem; padding: 0; list-style: none; }
.codes li { border: 1px solid var(--ink); padding: .4rem .6rem; }

/* Tableaux */
.table-wrap { position: relative; overflow-x: auto; background: var(--paper); border: 1px solid var(--ink); } /* position : les textes masqués (lecteurs d'écran) restent dans le cadre défilant */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table thead th { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; border-bottom: 2px solid var(--ink); }
.table tbody tr:last-child td, .table tbody tr:last-child th { border-bottom: 0; }
.table tfoot th, .table tfoot td { border-top: 2px solid var(--ink); border-bottom: 0; }
tr[data-href] { cursor: pointer; }
tr[data-href]:hover td { background-color: var(--grey-1); }
.table-beneficiaries td a { color: inherit; font-weight: 600; text-decoration: none; }
.row-actions { white-space: nowrap; }
td.row-actions > * { display: inline-flex; vertical-align: middle; margin: 0 .3rem 0 0; }
.input-small { width: 5.5rem; padding: .3rem .4rem; }

/* Liste : refusé = fond gris + trait noir à gauche ; doublon = texte grisé et barré (comme l'ancienne liste, sans couleur) */
.row-refused td, .swatch.row-refused { background: var(--grey-2); }
.row-refused td:first-child { box-shadow: inset 4px 0 0 var(--ink); }
.row-duplicate td, .swatch.row-duplicate { color: var(--muted); }
.row-duplicate td:nth-child(2), .row-duplicate td:nth-child(3) { text-decoration: line-through; }
.swatch.row-duplicate { background: var(--hatch); }
.legend { color: var(--muted); font-size: .875rem; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.swatch { display: inline-block; width: 14px; height: 14px; border: 1px solid var(--ink); margin-left: .5rem; vertical-align: middle; }

/* Liste et filtres */
.filters-main { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.filters-main input[type="search"] { flex: 1 1 220px; width: auto; }
.filters-main select, .filters-main input[type="number"] { width: auto; }
.filters-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-top: .75rem; }
.filters-grid fieldset, .groups { border: 1px solid var(--line); padding: .5rem .75rem; margin: 0; }
.filters-grid legend, .groups legend { font-weight: 700; padding: 0 .25rem; }
.filters-grid .check, .groups .check { font-weight: 400; margin: .25rem 0; }
.sizes { display: grid; grid-template-columns: repeat(3, 1fr); }
.list-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; }
.list-head h2 { margin: .75rem 0; }
.list-head .actions { margin-bottom: 0; }

/* Agenda : états des cases en noir et blanc (le nom de l'état est toujours écrit dans la case) */
.agenda-grid td.cell { min-width: 11rem; vertical-align: top; white-space: normal; border-left: 1px solid var(--line); }
.agenda-grid tbody th { width: 4.5rem; vertical-align: top; }
.agenda-grid th form { margin-top: .25rem; }
.cell-state { display: block; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.cell-person { display: block; margin: .15rem 0; }
.cell-actions { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .25rem; }
.cell-undefined, .swatch.cell-undefined { background: var(--paper); color: var(--muted); }
.cell-closed, .swatch.cell-closed { background: var(--hatch); color: var(--muted); }
.cell-open, .swatch.cell-open { background: var(--paper); }
.cell-booked, .swatch.cell-booked { background: var(--grey-2); }
.cell-attended, .swatch.cell-attended { background: var(--ink); color: var(--paper); }
.cell-attended a { color: var(--paper); }
.cell-attended .button-ghost { border-color: var(--paper); }
.cell-absent, .swatch.cell-absent { background: var(--paper); box-shadow: inset 0 0 0 2px var(--ink); }
.cell-absent .cell-person { text-decoration: line-through; }

/* Impression de la liste : case d'émargement assez large pour signer */
.print-table td.signature { min-width: 12rem; height: 2.4rem; color: var(--muted); font-size: .8rem; vertical-align: top; }

/* Formulaire de dossier et fiche */
.beneficiary-form fieldset.panel { margin: 0 0 1rem; }
.beneficiary-form legend { font-weight: 700; font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; padding: 0 .35rem; }
.beneficiary-form label { display: block; font-weight: 600; margin: .5rem 0 .25rem; }
.beneficiary-form .check { display: flex; font-weight: 400; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1rem; }
.grid + .grid { margin-top: .5rem; }
.span-2 { grid-column: span 2; }
@media (max-width: 520px) { .span-2 { grid-column: auto; } }
.repeater-row { border-bottom: 1px dashed var(--line); padding-bottom: .5rem; margin-bottom: .5rem; }
.row-remove { display: flex; align-items: flex-end; padding-bottom: .5rem; }
.rav { font-size: 1.05rem; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.25rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.two-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }

/* Synthèse : tuiles chiffrées et graphiques (SVG côté serveur, barres noires) */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; margin-bottom: 1rem; border: 1px solid var(--ink); }
.kpi { display: flex; flex-direction: column; gap: .15rem; padding: 1rem 1.25rem; color: var(--ink); text-decoration: none; border-right: 1px solid var(--ink); }
.kpi:last-child { border-right: 0; }
a.kpi:hover { background: var(--ink); color: var(--paper); }
a.kpi:hover .kpi-label, a.kpi:hover .kpi-hint { color: var(--paper); }
.kpi-label { color: var(--muted); font-size: .75rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.kpi-value { font-family: var(--font-title); font-size: 2.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-hint { color: var(--muted); font-size: .85rem; }
.chart { margin: 0; }
.chart-svg { width: 100%; height: auto; display: block; font: 15px var(--font); }
.chart-bar { fill: var(--ink); }
.chart-hit { fill: transparent; }
.chart-row:hover .chart-hit { fill: var(--grey-1); }
.chart-label { fill: var(--muted); }
.chart-value { fill: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-axis { stroke: var(--ink); stroke-width: 1; }

/* Interactions (public/js) */
.field-error { font-size: .875rem; font-weight: 700; margin: -.4rem 0 .6rem; }
.field-error::before { content: "✕ "; }
fieldset > .field-error { margin: .4rem 0 0; }
[aria-invalid="true"] { border-width: 2px !important; border-style: dashed !important; }
.field-warning { background: var(--grey-1); border: 1px dashed var(--ink); padding: .4rem .6rem; font-size: .875rem; margin: .25rem 0 0; }
.field-warning a { font-weight: 700; }
.age { display: inline-block; color: var(--muted); font-size: .85rem; margin: -.4rem 0 .5rem; }
.rules { list-style: none; padding: 0; margin: -.25rem 0 .75rem; font-size: .875rem; color: var(--muted); }
.rules li::before { content: "○ "; }
.rules li.rule-ok { color: var(--ink); }
.rules li.rule-ok::before { content: "● "; }
[aria-busy="true"] { opacity: .6; cursor: progress; }

/* Comptes et organisations : une fiche par ligne */
.user-list { list-style: none; margin: 0 0 1rem; padding: 0; border: 1px solid var(--ink); }
.user-card { padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
.user-card:last-child { border-bottom: 0; }
.user-card-main { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }
.user-name { min-width: 10rem; }
.user-actions { display: flex; gap: .5rem; margin-left: auto; }
.user-card-details { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1rem; margin: .4rem 0 0; color: var(--muted); font-size: .875rem; }
.user-email { overflow-wrap: anywhere; color: var(--ink); }
.account-action { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }
.account-action + .account-action { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.account-action form { margin: 0; flex: 0 0 auto; }
.account-action .help { flex: 1 1 260px; margin: 0; }
.inline-form { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: 0; }
.inline-form select, .inline-form input[type="text"] { width: auto; padding: .3rem .5rem; }
.inline-form .check { margin: 0; }

/* Impression */
.print-page { padding: 16px; max-width: 1100px; margin: 0 auto; }
.print-head { padding-bottom: .5rem; margin-bottom: 1rem; border-bottom: 2px solid var(--ink); }
@media print {
    .no-print, .topbar { display: none !important; }
    body { font-size: 11pt; }
    .panel, .table-wrap { border: 0; padding: 0; }
    .table th, .table td { padding: .25rem .4rem; }
    .cell-actions, .agenda-grid th form { display: none !important; }
    a { text-decoration: none; }
}
