/*
 * Feuille de style de l'application « Étude ».
 * Smartphone d'abord ; unités relatives uniquement (rem, em, %), aucune
 * largeur fixe en pixels (CLAUDE.md règle 8).
 */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 100%;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
    color: #1f2328;
    background: #f6f7f9;
}

a {
    color: #0b5cad;
}

.site-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    padding: 0.75rem 1rem;
    background: #0b5cad;
    color: #fff;
}

.site-header a {
    color: #fff;
}

.brand {
    font-weight: 700;
    font-size: 1.25rem;
    text-decoration: none;
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
}

.content {
    width: 100%;
    max-width: 48rem;
    margin: 0 auto;
    padding: 1rem;
}

h1 {
    font-size: 1.5rem;
    margin: 0.5rem 0 1rem;
}

h2 {
    font-size: 1.2rem;
}

.muted {
    color: #59636e;
    font-size: 0.9em;
}

/* Messages */
.alert,
.notice {
    padding: 0.75rem 1rem;
    margin: 0 0 1rem;
    border-radius: 0.375rem;
    border-left: 0.3rem solid;
}

.alert {
    background: #fdecea;
    border-color: #c62828;
    color: #7f1d1d;
}

.notice {
    background: #e8f5e9;
    border-color: #2e7d32;
    color: #1b4d20;
}

/* Étude d'une période clôturée : page en lecture seule (ROADMAP phase 5). */
.closed-period-banner {
    padding: 0.75rem 1rem;
    margin: 0 0 1rem;
    border-radius: 0.375rem;
    border-left: 0.3rem solid #4a5568;
    background: #edf0f4;
    color: #1f2933;
}

.closed-period-banner a {
    display: inline-block;
    margin-top: 0.25rem;
}

.study-details {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.25rem 1rem;
    margin: 0 0 1rem;
}

.study-details dt {
    font-weight: 600;
}

.study-details dd {
    margin: 0;
}

/* Boutons : grandes zones de toucher */
.button {
    display: inline-block;
    min-height: 2.75rem;
    padding: 0.6rem 1rem;
    border: 0.0625rem solid #b8c0cc;
    border-radius: 0.375rem;
    background: #fff;
    color: #1f2328;
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

.button-primary {
    background: #0b5cad;
    border-color: #0b5cad;
    color: #fff;
}

.button-danger {
    border-color: #c62828;
    color: #c62828;
}

/* Formulaires */
.form > div,
.form .field,
.fieldset > div {
    margin-bottom: 1rem;
}

.form label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.form input[type="text"],
.form input[type="email"],
.form input[type="password"],
.form input[type="date"],
.form select {
    width: 100%;
    min-height: 2.75rem;
    padding: 0.5rem 0.75rem;
    border: 0.0625rem solid #b8c0cc;
    border-radius: 0.375rem;
    font: inherit;
    background: #fff;
}

.form input[type="checkbox"] {
    width: 1.5rem;
    height: 1.5rem;
    vertical-align: middle;
}

.form input[type="checkbox"] + label,
.form label:has(+ input[type="checkbox"]) {
    display: inline;
}

.form ul {
    margin: 0.25rem 0;
    padding-left: 1.25rem;
    color: #c62828;
}

.form .help-text,
.form [id$="_help"] {
    color: #59636e;
    font-size: 0.875em;
}

.fieldset {
    border: 0.0625rem solid #d0d7de;
    border-radius: 0.375rem;
    padding: 0.75rem 1rem;
    margin: 0 0 1rem;
}

/* Listes en cartes, lisibles sur téléphone */
.cards,
.menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.menu li {
    margin-bottom: 0.5rem;
}

.card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    background: #fff;
    border: 0.0625rem solid #d0d7de;
    border-radius: 0.5rem;
}

.card-inactive {
    opacity: 0.7;
    background: #f0f1f3;
}

.card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.inline-form {
    display: inline;
    margin: 0;
}

.badge {
    display: inline-block;
    padding: 0 0.5em;
    margin-left: 0.25em;
    border-radius: 1em;
    background: #e7eef8;
    font-size: 0.85em;
    white-space: nowrap;
}

.badge-muted {
    background: #e2e4e8;
}

.amount {
    white-space: nowrap;
}

@media (min-width: 40em) {
    .card {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

/* Rapport d'import : totaux et lignes rejetées, lisibles sur téléphone */
.import-report {
    margin-bottom: 1.5rem;
}

.totals {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0 0 1rem;
}

.totals > div {
    flex: 1 1 8em;
    padding: 0.5rem 0.75rem;
    background: #fff;
    border: 0.0625rem solid #d0d7de;
    border-radius: 0.5rem;
}

.totals dt {
    font-size: 0.875em;
    color: #59636e;
}

.totals dd {
    margin: 0;
    font-size: 1.25em;
    font-weight: 600;
}

.report-list {
    margin: 0 0 1rem;
    padding-left: 1.25rem;
}

.report-list li {
    margin-bottom: 0.375rem;
    overflow-wrap: anywhere;
}

.form input[type="file"] {
    width: 100%;
    min-height: 2.75rem;
    font: inherit;
}

/* ------------------------------------------------------------------ */
/* Phase 3 : études, présences (écran 2), pré-inscription (écran 3).   */
/* Pensé pour le pouce : grandes zones, rien à moins de 2,75 rem.      */
/* ------------------------------------------------------------------ */

.visually-hidden {
    position: absolute;
    width: 0.0625rem;
    height: 0.0625rem;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.button-large {
    display: block;
    width: 100%;
    min-height: 3.5rem;
    padding: 0.9rem 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
}

.button-small {
    min-height: 2.75rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.95rem;
}

.menu-main li {
    margin-bottom: 0.75rem;
}

.study-header h1 {
    margin-bottom: 0.25rem;
    overflow-wrap: anywhere;
}

.study-summary,
.study-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.75rem;
    margin: 0 0 0.5rem;
}

.study-links a {
    display: inline-block;
    padding: 0.5rem 0;
}

.counter strong {
    font-size: 1.2em;
}

.content section {
    margin-top: 1.25rem;
}

.content section h2 {
    margin: 0 0 0.5rem;
}

.empty {
    margin: 0.25rem 0 0.75rem;
}

/* Liste d'enfants */
.child-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.child-item {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0.375rem;
    margin-bottom: 0.5rem;
}

.toggle-form,
.child-static {
    flex: 1 1 12rem;
    min-width: 0;
    margin: 0;
}

/* Le nom entier est la zone de toucher : au moins 3,25 rem de haut. */
.child-toggle,
.child-static {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    min-height: 3.25rem;
    padding: 0.5rem 0.875rem;
    border: 0.125rem solid #b8c0cc;
    border-radius: 0.5rem;
    background: #fff;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.child-static {
    cursor: default;
    border-style: dashed;
}

.child-toggle:focus-visible {
    outline: 0.1875rem solid #0b5cad;
    outline-offset: 0.125rem;
}

.child-toggle[disabled] {
    opacity: 0.6;
}

.child-name {
    font-size: 1.1rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.child-meta {
    color: #59636e;
    font-size: 0.875rem;
}

.state-label:not(:empty),
.billable-label:not(:empty) {
    display: inline-block;
    margin-left: 0.375em;
    padding: 0 0.5em;
    border-radius: 1em;
    background: #e2e4e8;
    color: #1f2328;
}

/* Attendu, pas encore arrivé : mis en évidence. */
.state-expected .child-toggle,
.state-expected .child-static {
    border-color: #b7791f;
    background: #fff8e1;
}

.state-expected .state-label {
    background: #f6d68a;
}

/* Présent : vert, coche visible. */
.state-present .child-toggle,
.state-present .child-static {
    border-color: #2e7d32;
    background: #e8f5e9;
}

.state-present .child-name::before {
    content: "\2713\00a0";
    color: #2e7d32;
}

.state-present .state-label {
    background: #a5d6a7;
}

.not-billable .billable-label {
    background: #ffd6d6;
}

/* Contrôle secondaire, replié : on ne le touche pas par accident. */
.more {
    flex: 0 0 auto;
    align-self: center;
}

.more > summary {
    display: flex;
    align-items: center;
    min-height: 2.75rem;
    padding: 0 0.75rem;
    border: 0.0625rem solid #d0d7de;
    border-radius: 0.375rem;
    background: #f6f7f9;
    color: #59636e;
    font-size: 0.875rem;
    cursor: pointer;
    list-style: none;
}

.more > summary::-webkit-details-marker {
    display: none;
}

.more[open] {
    flex-basis: 100%;
}

.more[open] > summary {
    margin-bottom: 0.375rem;
}

.elsewhere-link {
    flex-basis: 100%;
    font-size: 0.9rem;
}

.elsewhere > details > summary,
.announced > details > summary,
.past-studies > summary {
    min-height: 2.75rem;
    padding: 0.5rem 0;
    font-weight: 600;
    cursor: pointer;
}

/* Recherche */
.search-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.search-form input[type="search"] {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 2.75rem;
    padding: 0.5rem 0.75rem;
    border: 0.0625rem solid #b8c0cc;
    border-radius: 0.375rem;
    font: inherit;
    font-size: 1rem;
}

/* Formulaire d'étude */
.choice-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
}

.choice {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    min-height: 2.75rem;
}

.choice input[type="radio"] {
    width: 1.5rem;
    height: 1.5rem;
}

.form .choice label {
    display: inline;
    margin: 0;
    font-weight: 400;
}

.form select[multiple] {
    min-height: 8rem;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.danger-zone {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 0.0625rem solid #d0d7de;
}

.live-alert[hidden] {
    display: none;
}

/* Phase 4 : sous le nom, rangée de boutons assez grands pour le pouce
   (portée de l'annonce sur l'écran 3, résolution d'un attendu non arrivé). */
.scope-actions,
.resolution-actions {
    display: flex;
    flex-basis: 100%;
    gap: 0.375rem;
}

.scope-actions form,
.resolution-actions form {
    flex: 1 1 0;
    min-width: 0;
}

.scope-actions .button,
.resolution-actions .button {
    width: 100%;
    min-height: 2.75rem;
    white-space: normal;
}

.unresolved-study h2 a {
    color: inherit;
}

/* ------------------------------------------------------------------ */
/* Phase 5 : périodes, clôture (écran 7), récapitulatif (écran 11),    */
/* présences par enfant (écran 13).                                    */
/* ------------------------------------------------------------------ */

.provisional {
    padding: 0.75rem 1rem;
    margin: 0 0 1rem;
    border-radius: 0.375rem;
    border-left: 0.3rem solid #b26a00;
    background: #fff4e0;
    color: #5c3700;
}

.warning {
    padding: 0.5rem 1rem;
    margin: 0 0 1rem;
    border-radius: 0.375rem;
    border-left: 0.3rem solid #b26a00;
    background: #fffaf0;
}

.warning h2 {
    margin: 0.25rem 0;
    font-size: 1.05rem;
}

.warning ul {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    margin: 0 0 1rem;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.report-table th,
.report-table td {
    padding: 0.5em 0.6em;
    border-bottom: 0.0625rem solid #d0d7de;
    text-align: left;
    vertical-align: top;
}

.report-table .number {
    text-align: right;
    white-space: nowrap;
}

.report-table tfoot th,
.report-table tfoot td {
    font-weight: 600;
    border-top: 0.125rem solid #59636e;
}

/* ------------------------------------------------------------------ */
/* Phase 6 : paiements (écran 4, smartphone d'abord), suivi (écran 9). */
/* ------------------------------------------------------------------ */

.payment-list {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
}

.payment-list li {
    margin-bottom: 0.5rem;
}

/* Une ligne par enfant : nom, classe, dû, et le bouton « Payé » bien visible. */
.payment-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.75rem;
    min-height: 3rem;
    padding: 0.5rem 0.5rem 0.5rem 1rem;
    background: #fff;
    border: 0.0625rem solid #d0d7de;
    border-radius: 0.5rem;
}

.payment-item .child-name {
    flex: 1 1 auto;
}

.payment-amount {
    font-weight: 600;
    margin-left: auto;
}

.payment-item .inline-form {
    margin: 0;
}

/* Cible de toucher généreuse : un seul geste pour encaisser. */
.payment-item .button-pay {
    min-height: 2.75rem;
    min-width: 5.5rem;
}


/* Journal (administration) */
.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin: 1rem 0;
}

.pagination a,
.pagination span {
    display: inline-block;
    min-width: 2.75em;
    padding: 0.5em 0.75em;
    text-align: center;
    border-radius: 0.375em;
}

.pagination a {
    border: 0.0625rem solid #c9d1d9;
    background: #fff;
}

.pagination [aria-current="page"] {
    font-weight: 700;
    background: #0b5cad;
    color: #fff;
}

.journal td[data-col="date"] {
    white-space: nowrap;
}
