/* ============================================================================
   D1b : Édition AJAX des méta-données + facettes dans la page détail
   ============================================================================ */

/* ─── Indicateur de modifs non sauvegardées sur le formulaire ─── */

.form-meta-edition h3 {
    display: flex;
    align-items: center;
    gap: 6px;
}

.meta-indicateur-modif {
    color: var(--warn);
    font-size: 14px;
    min-width: 12px;
    display: inline-block;
}

/* ─── Champ titre avec bouton de regénération ─── */

.champ-avec-bouton {
    display: flex;
    gap: 6px;
    align-items: stretch;
}

.champ-avec-bouton input[type="text"] {
    flex: 1;
}

.btn-regenerer-titre {
    flex-shrink: 0;
    padding: 0 10px;
    font-size: 16px;
    line-height: 1;
    min-width: 36px;
}

.btn-regenerer-titre:hover:not(:disabled) {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
}

/* ─── Grille de facettes (pour les tags pédagogiques) ─── */

.facettes-grille {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 4px;
    margin-top: var(--space-2);
}

.facettes-grille .facette {
    margin: 0;
}

/* ─── Bouton "Enregistrer" + indicateur statut ─── */

.form-meta-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-top: var(--space-4);
    padding-top: var(--space-3);
    border-top: 1px solid var(--line);
}

.form-meta-actions button[type="submit"] {
    flex-shrink: 0;
}

.form-meta-actions button[type="submit"].accent {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.form-meta-actions button[type="submit"].accent:hover:not(:disabled) {
    background: oklch(42% 0.13 240);
}

.meta-indicateur-statut {
    font-size: 13px;
    color: var(--muted);
    font-family: var(--mono);
}

.meta-indicateur-statut.succes {
    color: oklch(40% 0.11 150);
}

.meta-indicateur-statut.erreur {
    color: var(--danger);
}

/* ─── Modale de confirmation ─── */

.modale-confirmation-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 18, 14, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2500;
    padding: var(--space-4);
}

.modale-confirmation {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    max-width: 500px;
    width: 100%;
    box-shadow: var(--shadow-strong);
    max-height: 80vh;
    overflow-y: auto;
}

.modale-confirmation h3 {
    margin-top: 0;
    margin-bottom: var(--space-3);
    font-family: var(--serif);
    color: var(--ink);
}

.modale-confirmation p {
    color: var(--ink-2);
    line-height: 1.5;
}

.modale-liste-items {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-4);
    margin: var(--space-3) 0;
    list-style: none;
}

.modale-liste-items li {
    padding: 4px 0;
    color: var(--ink-2);
    font-size: 14px;
}

.modale-liste-items li::before {
    content: "•";
    color: var(--accent);
    margin-right: 8px;
    font-weight: bold;
}

.modale-confirmation-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    margin-top: var(--space-4);
}

.modale-confirmation-actions button {
    padding: 8px 16px;
}

.modale-confirmation-actions .btn-confirmer.accent {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.modale-confirmation-actions .btn-confirmer.accent:hover {
    background: oklch(42% 0.13 240);
}

/* ─── Toast d'information (notification flottante en bas à gauche) ─── */

.toast {
    position: fixed;
    bottom: var(--space-6);
    left: var(--space-6);
    max-width: 400px;
    padding: var(--space-3) var(--space-4);
    background: var(--ink);
    color: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-strong);
    font-size: 13px;
    line-height: 1.5;
    z-index: 3000;
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.toast.visible {
    opacity: 1;
    transform: translateX(0);
}

.toast-info {
    background: var(--ink);
}

.toast-succes {
    background: oklch(40% 0.11 150);
}

.toast-erreur {
    background: var(--danger);
}

.toast-warn {
    background: oklch(45% 0.13 65);
}

/* ─── Modale de création d'exercice (D1c) ─── */

.modale-creation label {
    display: block;
    margin-bottom: var(--space-3);
}

.modale-creation .obligatoire {
    color: var(--danger);
    font-weight: bold;
}

.modale-creation .hint-inline {
    font-size: 12px;
    color: var(--muted);
    font-weight: normal;
}

.modale-creation .grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
}

.modale-creation select,
.modale-creation input[type="text"] {
    width: 100%;
    margin-top: 4px;
}

.creation-erreur {
    color: var(--danger);
    font-size: 13px;
    margin-top: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: oklch(95% 0.03 25);
    border-radius: var(--radius-sm);
    border: 1px solid oklch(80% 0.08 25);
}

/* ─── Bouton "Créer un exercice" (dashboard + liste) ─── */

.btn-creer-exercice {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    font-size: 14px;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    border: 1px solid transparent;
}

.btn-creer-exercice:hover {
    background: oklch(42% 0.13 240);
}

.btn-creer-exercice .icone-plus {
    font-size: 18px;
    font-weight: bold;
    line-height: 1;
}

/* ─── Champ notes : largeur pleine, resize vertical uniquement ─── */

.form-meta-edition textarea[name="notes"] {
    width: 100%;
    min-height: 80px;
    resize: vertical;
    box-sizing: border-box;
    font-family: var(--sans);
    font-size: 14px;
}

/* ─── Bouton "Supprimer" sur la page détail (haut à droite) ────────────────── */
.btn-supprimer-exo {
    background: transparent;
    color: #c0392b;
    border: 1px solid #c0392b;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-family: var(--sans, sans-serif);
    transition: background 0.15s, color 0.15s;
}
.btn-supprimer-exo:hover {
    background: #c0392b;
    color: white;
}	
.titre-avec-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.titre-avec-actions h1 {
    margin: 0;
}

 
/* ─── Bannière "exercice supprimé" sur la page détail ──────────────────────── */
.banniere-supprime {
    background: #fdecea;
    border: 1px solid #c0392b;
    color: #722;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.banniere-supprime .infos {
    flex: 1;
    min-width: 200px;
}
.banniere-supprime .infos strong {
    display: block;
    font-size: 15px;
    margin-bottom: 2px;
}
.banniere-supprime .infos .date {
    font-size: 13px;
    opacity: 0.8;
}
.banniere-supprime .actions {
    display: flex;
    gap: 8px;
}
.banniere-supprime button {
    padding: 6px 14px;
    border-radius: 4px;
    border: 1px solid;
    cursor: pointer;
    font-size: 13px;
    font-family: var(--sans, sans-serif);
    transition: background 0.15s, color 0.15s;
}
 
.btn-restaurer-exo {
    background: white;
    color: #2c7a3e;
    border-color: #2c7a3e;
}
.btn-restaurer-exo:hover {
    background: #2c7a3e;
    color: white;
}
 
.btn-purger-exo {
    background: white;
    color: #c0392b;
    border-color: #c0392b;
}
.btn-purger-exo:hover {
    background: #c0392b;
    color: white;
}
 
/* ─── Bandeau "Corbeille" sur la liste (filtre supprimes actif) ──────────────── */
.bandeau-corbeille {
    background: #fef5e7;
    border: 1px solid #d68910;
    color: #7e5109;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.bandeau-corbeille .titre {
    font-size: 15px;
}
.bandeau-corbeille .titre strong {
    font-size: 16px;
    margin-right: 6px;
}
#btn-purger-tous-supprimes {
    background: #c0392b;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    font-family: var(--sans, sans-serif);
}
#btn-purger-tous-supprimes:hover {
    background: #922b21;
}
#btn-purger-tous-supprimes:disabled {
    background: #bbb;
    cursor: not-allowed;
}
 
/* ─── Carte d'exo supprimée (mode corbeille) : effet visuel ──────────────────── */
.carte-exo.supprime,
tr.exo-supprime {
    opacity: 0.7;
    background: #fafafa;
}
.carte-exo.supprime .carte-exo-titre,
tr.exo-supprime .titre-exo {
    text-decoration: line-through;
    text-decoration-color: #c0392b;
    text-decoration-thickness: 2px;
}

/* ─── Sentinel de scroll infini ──────────────────────────────────────────── */
.sentinel-scroll {
    text-align: center;
    padding: 28px 16px;
    color: #888;
    font-size: 13px;
    font-style: italic;
    min-height: 40px;
    margin-top: 8px;
}
 
.sentinel-scroll::before {
    content: "";
}
 
.sentinel-scroll.chargement::before {
    content: "Chargement…";
    color: #555;
}
 
.sentinel-scroll.fin::before {
    content: "— Tous les exercices sont affichés —";
    color: #aaa;
}
 
.sentinel-scroll.erreur::before {
    content: "Erreur de chargement. Faites défiler pour réessayer.";
    color: #c0392b;
}
 
@keyframes sentinel-pulse {
    0%, 100% { opacity: 0.4; }
    50%      { opacity: 1; }
}
.sentinel-scroll.chargement {
    animation: sentinel-pulse 1.2s ease-in-out infinite;
}
 
 
/* ─── Bouton retour en haut ──────────────────────────────────────────────── */
#btn-retour-haut {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(60, 60, 60, 0.65);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    padding: 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}
 
#btn-retour-haut.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
 
#btn-retour-haut:hover {
    background: rgba(40, 40, 40, 0.9);
}
 
#btn-retour-haut:focus {
    outline: 2px solid rgba(100, 150, 255, 0.6);
    outline-offset: 2px;
}


/* ============================================================================
   D5 : Intégration Overleaf
   ============================================================================ */

/* ─── Bouton « Envoyer vers Overleaf » ─── */

.btn-envoyer-overleaf {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    background: #219653;
    color: white;
    border: 1px solid #219653;
    padding: 8px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-family: var(--sans, sans-serif);
    transition: background 0.15s, border-color 0.15s;
    margin-top: 8px;
}

.btn-envoyer-overleaf:hover {
    background: #1a7a43;
    border-color: #1a7a43;
}

.btn-envoyer-overleaf::before {
    content: "\2B06";
    font-size: 12px;
}

/* ─── Modale Overleaf ─── */

.modale-overleaf {
    max-width: 520px;
}

.modale-overleaf label {
    display: block;
    margin-bottom: 14px;
}

.modale-overleaf select,
.modale-overleaf input[type="text"] {
    width: 100%;
    margin-top: 4px;
    display: block;
    box-sizing: border-box;
}

.overleaf-chargement {
    color: var(--muted, #888);
    font-size: 14px;
    padding: 20px 0;
    text-align: center;
}

.ol-spinner {
    display: inline-block;
    animation: ol-spin 1.2s linear infinite;
    margin-right: 4px;
}

@keyframes ol-spin {
    to { transform: rotate(360deg); }
}

.overleaf-erreur {
    color: var(--danger, #c0392b);
    font-size: 13px;
    margin-top: 8px;
    padding: 8px 12px;
    background: #fdf0ef;
    border-radius: 4px;
    border: 1px solid #e8b4b0;
}

.overleaf-succes {
    text-align: center;
    padding: 16px 0;
}

.ol-msg-succes {
    color: oklch(40% 0.11 150);
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
}

.ol-lien-projet {
    display: inline-block;
    background: #219653;
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
    transition: background 0.15s;
}

.ol-lien-projet:hover {
    background: #1a7a43;
    color: white;
    text-decoration: none;
}
