/* Styles personnalisés pour le dashboard ma-db-exos */
.dashboard-entete {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

/* Liens désactivés dans le menu (pendant la construction des étapes) */
nav .disabled {
    opacity: 0.4;
    pointer-events: none;
    cursor: not-allowed;
}

/* Alerte erreur (repo introuvable) */
.alerte-erreur {
    border-left: 4px solid var(--pico-color-red-500, #c62828);
    background-color: var(--pico-color-red-100, #ffebee);
}

/* Footer plus discret */
footer {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid var(--pico-muted-border-color);
    text-align: center;
}

/* Hgroup pour les chiffres clés sur l'accueil */
.grid hgroup {
    text-align: center;
}

.grid hgroup h2 {
    font-size: 2.5rem;
    margin-bottom: 0.25rem;
}

.grid hgroup p {
    color: var(--pico-muted-color);
}

/* ======================================================================== */
/* Page liste des exercices                                                  */
/* ======================================================================== */

.page-liste {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 900px) {
    .page-liste {
        grid-template-columns: 1fr;
    }
}

/* Panneau de filtres latéral */
.panneau-filtres {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    padding: 1rem;
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    font-size: 0.875rem;
}

.panneau-filtres h3 {
    margin: 0;
    font-size: 1.1rem;
    font-family: var(--serif);
    font-weight: 500;
    color: var(--ink);
}

.panneau-filtres details {
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--line);
    padding-bottom: 0.5rem;
}

.panneau-filtres details:last-of-type {
    border-bottom: none;
}

.panneau-filtres summary {
    cursor: pointer;
    font-weight: 500;
    color: var(--ink-2);
    padding: 0.25rem 0;
}

.panneau-filtres label {
    display: block;
    padding: 0.15rem 0;
    cursor: pointer;
    font-size: 0.85rem;
}

.panneau-filtres input[type="checkbox"] {
    margin-right: 0.4em;
    vertical-align: middle;
}

.panneau-filtres input[type="search"] {
    width: 100%;
    padding: 0.4rem;
    margin-top: 0.25rem;
}

.panneau-filtres button[type="submit"] {
    width: 100%;
    margin-top: 1rem;
}

.filtre-entete {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.5rem;
}

.lien-reset {
    font-size: 0.8rem;
}

/* Bouton "Appliquer" qui reste visible en haut du panneau quand on scrolle */
.bouton-appliquer-sticky {
    position: sticky;
    top: 0;
    background-color: var(--surface);
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
    z-index: 10;
    border-bottom: 1px solid var(--line);
}

.bouton-appliquer-sticky button {
    width: 100%;
    margin: 0;
}

.notions-groupe {
    margin-bottom: 0.5rem;
    padding-left: 0.5rem;
    border-left: 2px solid var(--line);
}

.notions-titre {
    font-size: 0.75rem;
    color: var(--muted);
    font-family: var(--mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    display: block;
    margin-bottom: 0.25rem;
}

/* Zone principale de la liste */
.zone-liste {
    min-width: 0; /* évite le débordement horizontal */
}

.liste-entete {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.liste-entete h2 {
    margin: 0;
}

.liste-entete h2 small {
    font-weight: normal;
    color: var(--pico-muted-color, #666);
    font-size: 0.7em;
}

.form-tri {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin: 0;
}

.form-tri select {
    padding: 0.25rem 0.5rem;
    margin: 0;
    width: auto;
}

.form-tri label {
    margin: 0;
}

/* Table des exos */
.liste-exos {
    width: 100%;
    font-size: 0.875rem;
    border-collapse: collapse;
}

.liste-exos th {
    text-align: left;
    padding: 0.5rem;
    background-color: var(--pico-card-background-color, #f0f0f0);
    border-bottom: 2px solid var(--pico-muted-border-color, #ccc);
}

/* En-têtes cliquables pour le tri */
.entete-tri {
    color: inherit;
    text-decoration: none;
    display: inline-block;
    width: 100%;
    cursor: pointer;
}

.entete-tri:hover {
    color: var(--pico-primary, #1565c0);
}

.entete-tri-actif {
    color: var(--pico-primary, #1565c0);
    font-weight: bold;
}

.liste-exos td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--pico-muted-border-color, #eee);
    vertical-align: top;
}

.liste-exos tr:hover td {
    background-color: var(--pico-muted-color, rgba(0,0,0,0.03));
}

/* Badges pour les chapitres */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    margin: 0.1rem 0.2rem 0.1rem 0;
    border-radius: 4px;
    font-size: 0.75rem;
    background-color: var(--pico-muted-border-color, #e0e0e0);
    color: var(--pico-color, #333);
}

.badge-chap {
    background-color: #e3f2fd;
    color: #1565c0;
}

/* Puces de correction */
.puce-corr {
    display: inline-block;
    width: 1.4em;
    height: 1.4em;
    line-height: 1.4em;
    text-align: center;
    border-radius: 50%;
    font-weight: bold;
}

.puce-corr-ok {
    background-color: #c8e6c9;
    color: #2e7d32;
}

.puce-corr-ko {
    background-color: #ffcdd2;
    color: #c62828;
}

/* Pagination */
.pagination {
    margin-top: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    color: var(--pico-muted-color, #666);
    font-size: 0.875rem;
}

.pagination .disabled {
    opacity: 0.4;
}

.pagination a {
    margin: 0 0.5rem;
}

/* ======================================================================== */
/* Page détail d'un exercice                                                 */
/* ======================================================================== */

.detail-entete {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1rem;
}

.detail-entete h1 {
    margin: 0;
}

.lien-retour {
    font-size: 0.9rem;
}

.alerte-retagger {
    border-left: 4px solid #ff9800;
    background-color: #fff8e1;
    padding: 1rem;
}

.detail-grille {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) 3fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 1300px) {
    .detail-grille {
        grid-template-columns: 1fr;
    }
}

/* La page détail bénéficie d'une largeur étendue pour mieux profiter
   des panneaux côte à côte de l'énoncé/correction.
   IMPORTANT : Pico applique max-width: 1200px sur <body>, ce qui borne
   tout y compris le main. Il faut donc neutraliser cette limite. */
body.body-large,
body.body-studio {
    max-width: none !important;
    width: auto !important;
}

main.container.page-large,
body main.container.page-large,
main.container.page-studio,
body main.container.page-studio {
    max-width: none !important;
    width: auto !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    margin-left: 0.5rem !important;
    margin-right: 0.5rem !important;
}

/* Sur les très grands écrans, on limite quand même pour la lisibilité */
@media (min-width: 2200px) {
    body.body-large {
        max-width: 2000px !important;
    }
}

.detail-meta {
    min-width: 0;
}

.detail-contenu {
    min-width: 0;
}

.detail-meta h3,
.detail-contenu h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.detail-meta h3:first-child,
.detail-contenu h3:first-child {
    margin-top: 0;
}

/* Grille à 2 colonnes pour les selects côte à côte */
.grid-2col {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem 1rem;
}

/* En écran très large, on remet sur 2 colonnes si on a la place */
@media (min-width: 1600px) {
    .grid-2col {
        grid-template-columns: 1fr 1fr;
    }
}

/* Grille de tags (cases à cocher) */
.tag-grille {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.4rem;
    margin: 0.5rem 0;
}

.tag-checkbox {
    display: flex;
    align-items: center;
    padding: 0.3rem 0.5rem;
    background-color: #f7f7f7;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.tag-checkbox input {
    margin-right: 0.5em;
}

.tag-checkbox:has(input:checked) {
    background-color: #e3f2fd;
    color: #1565c0;
}

/* Hint (texte explicatif gris) */
.hint {
    color: var(--pico-muted-color, #888);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* Actions rapides séparées */
.actions-rapides {
    margin-top: 2rem;
    padding: 1rem;
    background-color: #fafafa;
    border: 1px solid var(--pico-muted-border-color, #ddd);
    border-radius: 8px;
}

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

/* (.latex-affichage et .preview-rendu sont définis plus bas dans la section
   "Panneaux côte à côte" — c'est là qu'il faut les modifier) */

.latex-correction {
    background-color: #f1f8e9;
    border-color: #c5e1a5;
}

/* Table des sources */
.sources-table {
    width: 100%;
    font-size: 0.85rem;
}

.sources-table th,
.sources-table td {
    padding: 0.4rem;
    text-align: left;
    border-bottom: 1px solid var(--pico-muted-border-color, #eee);
}

.sources-table code {
    font-size: 0.75rem;
}

/* Badges de correction */
.badge-corr-ok {
    background-color: #c8e6c9;
    color: #2e7d32;
}

.badge-corr-ko {
    background-color: #ffcdd2;
    color: #c62828;
}

/* Indicateur "déjà donné cette année scolaire" */
.puce-deja-donne {
    background: oklch(97% 0.04 65);
    color: oklch(40% 0.13 55);
    border-color: oklch(80% 0.10 65);
    cursor: help;
}

/* Variante compacte (icône seule) pour la sidebar panier */
.badge-deja-donne {
    display: inline-block;
    font-size: 11px;
    color: oklch(40% 0.13 55);
    cursor: help;
    line-height: 1;
}

/* Messages flash */
.flash {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border-radius: 4px;
}

.flash-success {
    background-color: #e8f5e9;
    border-left: 4px solid #2e7d32;
    color: #1b5e20;
}

.flash-error {
    background-color: #ffebee;
    border-left: 4px solid #c62828;
    color: #b71c1c;
}

/* ======================================================================== */
/* Bouton "Ajouter au panier" (dans la liste)                                */
/* ======================================================================== */

.bouton-ajouter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    margin: 0;
    border-radius: 50%;
    font-size: 1.1rem;
    font-weight: bold;
    line-height: 1;
    background-color: #1976d2;
    color: white;
    border: none;
    cursor: pointer;
}

.bouton-ajouter:hover {
    background-color: #1565c0;
}

/* Badge nombre d'items du panier dans le menu */
.panier-badge {
    display: inline-block;
    background-color: #1976d2;
    color: white;
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
    font-size: 0.75rem;
    font-weight: bold;
    margin-left: 0.25rem;
}

/* ======================================================================== */
/* Page panier                                                               */
/* ======================================================================== */

.panier-entete {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.panier-entete h1 {
    margin: 0;
}

.panier-grille {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 1100px) {
    .panier-grille {
        grid-template-columns: 1fr;
    }
}

.panier-stats {
    padding: 0.75rem 1rem;
    background-color: #e3f2fd;
    border-left: 4px solid #1976d2;
    border-radius: 4px;
}

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

.panier-item {
    display: grid;
    grid-template-columns: 30px 30px 1fr auto auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
    background-color: white;
    border: 1px solid var(--pico-muted-border-color, #ddd);
    border-radius: 6px;
    cursor: default;
}

.panier-item.en-deplacement {
    opacity: 0.4;
}

.panier-item.cible-survol {
    border-color: #1976d2;
    border-style: dashed;
    background-color: #e3f2fd;
}

.panier-item-poignee {
    cursor: grab;
    color: #999;
    font-size: 1rem;
    user-select: none;
}

.panier-item-poignee:active {
    cursor: grabbing;
}

.panier-item-numero {
    font-weight: bold;
    color: #666;
    text-align: center;
}

.panier-item-infos {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem;
}

.panier-item-bareme .bareme-form {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin: 0;
}

.panier-item-bareme input[type="number"] {
    width: 4em;
    padding: 0.2rem 0.4rem;
    margin: 0;
    font-size: 0.85rem;
}

.bareme-submit {
    padding: 0.2rem 0.5rem;
    margin: 0;
    font-size: 0.85rem;
    line-height: 1;
}

.panier-bouton-retirer {
    padding: 0.2rem 0.5rem;
    margin: 0;
    font-size: 0.9rem;
    line-height: 1;
    background-color: #fff;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.panier-bouton-retirer:hover {
    background-color: #ffebee;
    border-color: #c62828;
}

.panier-generation {
    position: sticky;
    top: 1rem;
    padding: 1rem;
    background-color: #fafafa;
    border: 1px solid var(--pico-muted-border-color, #ddd);
    border-radius: 8px;
}

.panier-generation h3 {
    margin-top: 0;
}

.panier-generation label {
    display: block;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.panier-generation input[type="text"],
.panier-generation input[type="number"] {
    width: 100%;
    margin: 0.25rem 0 0;
}

.panier-generation fieldset {
    border: 1px solid var(--pico-muted-border-color, #ddd);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.panier-generation fieldset legend {
    padding: 0 0.5rem;
    font-weight: bold;
    font-size: 0.9rem;
}

.panier-generation fieldset label {
    margin-bottom: 0.25rem;
}

.boutons-generation {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.boutons-generation button {
    width: 100%;
    margin: 0;
}

/* ======================================================================== */
/* Tableau de bord                                                           */
/* ======================================================================== */

/* Chiffres clés - grille de cartes */
.cles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.cle-box {
    text-align: center;
    padding: 1.25rem;
    background-color: #f5f5f5;
    border-radius: 8px;
    border: 1px solid var(--pico-muted-border-color, #ddd);
}

.cle-box-ok {
    background-color: #e8f5e9;
    border-color: #a5d6a7;
}

.cle-box-attention {
    background-color: #fff3e0;
    border-color: #ffcc80;
}

.cle-nombre {
    font-size: 2.5rem;
    font-weight: bold;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.cle-libelle {
    font-size: 0.85rem;
    color: var(--pico-muted-color, #666);
}

/* Liens rapides */
.liens-rapides {
    list-style: none;
    padding: 0;
}

.liens-rapides li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--pico-muted-border-color, #eee);
}

.liens-rapides li:last-child {
    border-bottom: none;
}

/* Barres horizontales pour répartition par chapitre */
.repartition-barres {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin: 1rem 0;
}

.barre-ligne {
    display: grid;
    grid-template-columns: 240px 1fr 40px;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
}

.barre-libelle {
    text-align: right;
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.barre-libelle:hover {
    color: #1976d2;
    text-decoration: underline;
}

.barre-piste {
    background-color: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
    height: 1.5rem;
}

.barre-remplissage {
    height: 100%;
    background: linear-gradient(to right, #42a5f5, #1976d2);
    transition: width 0.5s ease;
}

.barre-valeur {
    font-weight: bold;
    text-align: left;
}

@media (max-width: 700px) {
    .barre-ligne {
        grid-template-columns: 1fr 40px;
    }
    .barre-libelle {
        grid-column: 1 / -1;
        text-align: left;
    }
    .barre-piste {
        grid-column: 1;
    }
    .barre-valeur {
        grid-column: 2;
    }
}

/* Disposition en deux colonnes pour stats secondaires */
.deux-colonnes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin: 1.5rem 0;
}

@media (max-width: 800px) {
    .deux-colonnes {
        grid-template-columns: 1fr;
    }
}

/* Tableau de stats simple */
.stat-table {
    width: 100%;
    font-size: 0.9rem;
}

.stat-table td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--pico-muted-border-color, #eee);
}

.stat-table .stat-nb {
    text-align: right;
    font-weight: bold;
    width: 5em;
}

/* Liste du référentiel */
.liste-referentiel {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.5rem;
}

.liste-referentiel li {
    padding: 0.5rem;
    background-color: #f5f5f5;
    border-radius: 4px;
    text-align: center;
}

/* ======================================================================== */
/* Panneaux côte à côte (énoncé / correction) avec preview KaTeX            */
/* ======================================================================== */

.panneaux-enonce,
.panneaux-correction {
    margin-bottom: 2rem;
}

.panneaux-entete {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.panneaux-entete h3 {
    margin: 0;
}

.panneaux-controles {
    display: flex;
    gap: 0.25rem;
}

.bouton-volet {
    padding: 0.2rem 0.6rem;
    margin: 0;
    font-size: 0.8rem;
    background-color: #f5f5f5;
    color: #555;
    border: 1px solid #ddd;
    cursor: pointer;
    border-radius: 4px;
}

.bouton-volet:hover {
    background-color: #e0e0e0;
}

.bouton-volet.volet-actif {
    background-color: #1976d2;
    color: white;
    border-color: #1565c0;
}

.volet-icone {
    font-size: 0.7rem;
}

/* Disposition deux colonnes des panneaux */
.panneaux-corps {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: stretch;  /* pour que les deux panneaux aient la même hauteur */
}

@media (max-width: 1000px) {
    .panneaux-corps {
        grid-template-columns: 1fr;
    }
}

.panneau {
    overflow: hidden;
    transition: opacity 0.2s ease, max-height 0.3s ease;
    display: flex;
    flex-direction: column;
}

/* Panneau replié = caché complètement (l'autre prend toute la largeur) */
.panneau.panneau-replie {
    display: none;
}

/* Quand un panneau est replié, l'autre prend toute la largeur */
.panneaux-corps:has(.panneau-replie) {
    grid-template-columns: 1fr;
}

/* Affichage du LaTeX brut : hauteur fixe pour aligner avec la preview */
.latex-affichage {
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    padding: 1rem;
    border-radius: 4px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
    overflow-x: auto;
    height: 600px;            /* hauteur fixe (pas max-height) */
    overflow-y: auto;
    margin: 0;                /* retire la marge par défaut des <pre> */
    box-sizing: border-box;
}

/* Style du panneau preview : même hauteur fixe pour alignement */
.preview-rendu {
    padding: 1rem;
    background-color: #fafafa;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.95rem;
    line-height: 1.6;
    height: 600px;            /* hauteur fixe identique au LaTeX brut */
    overflow-y: auto;
    box-sizing: border-box;
}

.preview-rendu p {
    margin: 0.5rem 0;
}

.preview-rendu ul,
.preview-rendu ol {
    padding-left: 1.5rem;
}

.preview-rendu li {
    margin: 0.3rem 0;
}

.preview-correction {
    background-color: #f1f8e9;
    border-color: #c5e1a5;
}

/* Placeholder pour environnements non rendus (figures, tableaux complexes...) */
.latex-placeholder {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    margin: 0.3rem 0;
    background-color: #fff3e0;
    border: 1px dashed #ff9800;
    border-radius: 4px;
    color: #e65100;
    font-style: italic;
    font-size: 0.85rem;
}

/* Surcharge pour KaTeX : éviter qu'il déborde dans les panneaux étroits */
.preview-rendu .katex {
    font-size: 1em;
}

.preview-rendu .katex-display {
    margin: 0.6rem 0;
    overflow-x: auto;
    overflow-y: hidden;
}
