/* ==========================================================
   COULEURS ET BASE
   ========================================================== */

:root {
    --violet: #8b00ff;
    --violet-clair: #a855f7;
    --violet-glow: #6b00cc;

    --noir-opale: #0a0a0f;
    --noir-carte: #12121a;
    --noir-bord: #1e1e2e;

    --texte: #e8e8f0;
    --texte-gris: #8888aa;

    --rouge-alerte: #ff6b81;
    --vert-validation: #64d98b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    min-height: 100vh;

    display: flex;
    flex-direction: column;

    background-color: var(--noir-opale);
    color: var(--texte);

    font-family: "Segoe UI", Arial, sans-serif;
}


/* ==========================================================
   EN-TÊTE
   ========================================================== */

header {
    padding: 20px 40px;

    background: var(--noir-carte);
    border-bottom: 2px solid var(--violet);

    text-align: center;

    box-shadow: 0 0 20px rgba(139, 0, 255, 0.3);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;

    gap: 15px;
    margin-bottom: 8px;
}

.robot {
    color: var(--violet-clair);

    font-size: 2em;

    text-shadow: 0 0 10px var(--violet);
}

.nom {
    color: var(--violet-clair);

    font-size: 2.2em;
    font-weight: bold;
    letter-spacing: 3px;

    text-shadow: 0 0 15px var(--violet);
}

.slogan {
    color: var(--texte-gris);

    font-size: 0.95em;
    letter-spacing: 1px;
}


/* ==========================================================
   CONTENU PRINCIPAL
   ========================================================== */

main {
    flex: 1;

    width: 100%;
    max-width: 900px;

    margin: 40px auto;
    padding: 0 20px;
}


/* ==========================================================
   INDICATEUR DU MODE ACTUEL
   ========================================================== */

.indicateur-mode {
    display: inline-flex;
    align-items: center;

    gap: 7px;
    margin-bottom: 14px;
    padding: 8px 13px;

    background: rgba(139, 0, 255, 0.1);
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 20px;

    color: var(--texte-gris);

    font-size: 0.88em;
}

.indicateur-mode span {
    color: var(--violet-clair);
    font-weight: bold;
}


/* ==========================================================
   BOUTONS DE MODE
   ========================================================== */

.modes {
    display: flex;
    flex-wrap: wrap;

    gap: 12px;
    margin-bottom: 30px;
}

.btn-mode {
    flex: 1;
    min-width: 120px;

    padding: 14px 10px;

    background: var(--noir-carte);
    border: 1px solid var(--noir-bord);
    border-radius: 10px;

    color: var(--texte-gris);

    cursor: pointer;

    font-size: 1em;
    font-weight: bold;
    text-align: center;

    transition:
        border-color 0.3s ease,
        color 0.3s ease,
        box-shadow 0.3s ease,
        background-color 0.3s ease,
        transform 0.3s ease;
}

.btn-mode:hover {
    border-color: var(--violet);
    color: var(--violet-clair);

    box-shadow: 0 0 15px rgba(139, 0, 255, 0.4);

    transform: translateY(-2px);
}

.btn-mode.actif {
    background: var(--violet-glow);
    border-color: var(--violet);

    color: white;

    box-shadow: 0 0 20px rgba(139, 0, 255, 0.6);
}


/* ==========================================================
   SÉLECTION DU NIVEAU DU QUIZ
   ========================================================== */

.zone-niveaux {
    margin-top: -10px;
    margin-bottom: 24px;
    padding: 20px;

    background:
        linear-gradient(
            135deg,
            rgba(139, 0, 255, 0.08),
            rgba(18, 18, 26, 0.95)
        );

    border: 1px solid rgba(168, 85, 247, 0.32);
    border-radius: 12px;

    box-shadow: 0 0 18px rgba(139, 0, 255, 0.12);
}

.entete-niveaux {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 15px;
    margin-bottom: 15px;
}

.titre-niveaux {
    color: var(--violet-clair);

    font-size: 0.95em;
    font-weight: bold;
}

.niveau-selectionne {
    color: var(--texte-gris);

    font-size: 0.82em;
}

.niveau-selectionne strong {
    color: var(--violet-clair);
}

.boutons-niveaux {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));

    gap: 10px;
}

.btn-niveau {
    padding: 12px 10px;

    background: var(--noir-opale);
    border: 1px solid var(--noir-bord);
    border-radius: 9px;

    color: var(--texte-gris);

    cursor: pointer;

    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 0.9em;
    font-weight: bold;

    transition:
        background-color 0.25s ease,
        border-color 0.25s ease,
        color 0.25s ease,
        box-shadow 0.25s ease,
        transform 0.25s ease;
}

.btn-niveau:hover {
    border-color: rgba(168, 85, 247, 0.65);
    color: var(--violet-clair);

    transform: translateY(-1px);
}

.btn-niveau.actif {
    background: rgba(139, 0, 255, 0.24);
    border-color: var(--violet);

    color: white;

    box-shadow:
        inset 0 0 12px rgba(139, 0, 255, 0.18),
        0 0 13px rgba(139, 0, 255, 0.24);
}

.description-niveau {
    margin-top: 13px;
    margin-bottom: 0;

    color: var(--texte-gris);

    font-size: 0.82em;
    line-height: 1.5;
    text-align: center;
}


/* ==========================================================
   ZONE DE SAISIE
   ========================================================== */

.zone-saisie {
    margin-bottom: 20px;
    padding: 25px;

    background: var(--noir-carte);
    border: 1px solid var(--noir-bord);
    border-radius: 12px;
}

.zone-saisie label {
    display: block;

    margin-bottom: 10px;

    color: var(--violet-clair);

    font-size: 1em;
    font-weight: bold;
}

.zone-saisie textarea {
    width: 100%;
    min-height: 120px;

    padding: 14px;

    resize: vertical;

    background: var(--noir-opale);
    border: 1px solid var(--noir-bord);
    border-radius: 8px;

    color: var(--texte);

    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 1em;
    line-height: 1.5;

    transition:
        border-color 0.3s ease,
        box-shadow 0.3s ease;
}

.zone-saisie textarea:focus {
    outline: none;

    border-color: var(--violet);

    box-shadow: 0 0 10px rgba(139, 0, 255, 0.3);
}

.zone-saisie textarea::placeholder {
    color: #686883;
}


/* ==========================================================
   INFORMATIONS ET COMPTEUR
   ========================================================== */

.informations-saisie {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 15px;
    margin-top: 10px;

    color: var(--texte-gris);

    font-size: 0.8em;
}

#compteur-caracteres {
    flex-shrink: 0;

    font-variant-numeric: tabular-nums;

    transition: color 0.2s ease;
}

#compteur-caracteres.presque-plein {
    color: var(--rouge-alerte);
    font-weight: bold;
}


/* ==========================================================
   BOUTONS D’ACTION
   ========================================================== */

.actions {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(180px, 1fr);

    gap: 12px;
}

.btn-envoyer,
.btn-nouvelle-question {
    width: 100%;

    padding: 16px;

    border-radius: 10px;

    cursor: pointer;

    font-size: 1em;
    font-weight: bold;
    letter-spacing: 0.5px;

    transition:
        background-color 0.3s ease,
        border-color 0.3s ease,
        color 0.3s ease,
        box-shadow 0.3s ease,
        transform 0.3s ease,
        opacity 0.3s ease;
}

.btn-envoyer {
    background: var(--violet);
    border: 1px solid var(--violet);

    color: white;

    box-shadow: 0 0 20px rgba(139, 0, 255, 0.5);
}

.btn-envoyer:hover:not(:disabled) {
    background: var(--violet-clair);
    border-color: var(--violet-clair);

    box-shadow: 0 0 30px rgba(139, 0, 255, 0.8);

    transform: translateY(-2px);
}

.btn-nouvelle-question {
    background: var(--noir-carte);
    border: 1px solid var(--noir-bord);

    color: var(--texte-gris);
}

.btn-nouvelle-question:hover:not(:disabled) {
    border-color: var(--violet);
    color: var(--violet-clair);

    box-shadow: 0 0 15px rgba(139, 0, 255, 0.25);

    transform: translateY(-2px);
}

.btn-envoyer:disabled,
.btn-nouvelle-question:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
}


/* ==========================================================
   CHARGEMENT
   ========================================================== */

.chargement {
    display: none;

    padding: 20px;

    color: var(--violet-clair);

    font-style: italic;
    text-align: center;
}


/* ==========================================================
   ZONE DE RÉPONSE
   ========================================================== */

.zone-reponse {
    max-height: 500px;
    overflow-y: auto;

    margin-top: 25px;
    padding: 25px;

    background: var(--noir-carte);
    border: 1px solid var(--violet);
    border-radius: 12px;

    line-height: 1.7;
    overflow-wrap: anywhere;

    box-shadow: 0 0 20px rgba(139, 0, 255, 0.2);
}

.zone-reponse .entete-reponse {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 14px;

    border-bottom: 1px solid var(--noir-bord);

    color: var(--violet-clair);

    font-size: 1em;
    font-weight: bold;
}

.actions-reponse {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;

    gap: 8px;
}


/* ==========================================================
   BOUTONS DE LA RÉPONSE
   ========================================================== */

.btn-copier,
.btn-corrections {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 36px;

    padding: 8px 12px;

    border-radius: 8px;

    cursor: pointer;

    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 0.78em;
    font-weight: bold;

    transition:
        background-color 0.25s ease,
        border-color 0.25s ease,
        color 0.25s ease,
        box-shadow 0.25s ease,
        transform 0.25s ease;
}

.btn-copier {
    min-width: 155px;

    background: rgba(139, 0, 255, 0.12);
    border: 1px solid rgba(168, 85, 247, 0.45);

    color: var(--violet-clair);
}

.btn-copier:hover {
    background: rgba(139, 0, 255, 0.25);
    border-color: var(--violet);

    box-shadow: 0 0 12px rgba(139, 0, 255, 0.3);

    transform: translateY(-1px);
}

.btn-corrections {
    min-width: 190px;

    background: rgba(100, 217, 139, 0.08);
    border: 1px solid rgba(100, 217, 139, 0.38);

    color: var(--vert-validation);
}

.btn-corrections:hover {
    background: rgba(100, 217, 139, 0.16);
    border-color: var(--vert-validation);

    box-shadow: 0 0 12px rgba(100, 217, 139, 0.2);

    transform: translateY(-1px);
}


/* ==========================================================
   CONTENU FORMATÉ DE LA RÉPONSE
   ========================================================== */

#reponse {
    color: var(--texte);

    font-size: 1em;
    line-height: 1.75;
}

#reponse > :first-child {
    margin-top: 0;
}

#reponse > :last-child {
    margin-bottom: 0;
}

#reponse h1,
#reponse h2,
#reponse h3,
#reponse h4 {
    color: var(--violet-clair);

    line-height: 1.3;
}

#reponse h1 {
    margin: 28px 0 15px;

    font-size: 1.55em;
}

#reponse h2 {
    margin: 28px 0 14px;
    padding-bottom: 7px;

    border-bottom: 1px solid rgba(168, 85, 247, 0.25);

    font-size: 1.3em;
}

#reponse h3 {
    margin: 24px 0 11px;

    font-size: 1.12em;
}

#reponse h4 {
    margin: 20px 0 10px;

    font-size: 1em;
}

#reponse p {
    margin: 0 0 14px;
}

#reponse strong {
    color: white;
    font-weight: 700;
}

#reponse em {
    color: #d7c4e8;
}

#reponse ul,
#reponse ol {
    margin: 8px 0 18px;
    padding-left: 28px;
}

#reponse li {
    margin-bottom: 8px;
    padding-left: 4px;
}

#reponse li::marker {
    color: var(--violet-clair);
    font-weight: bold;
}

#reponse blockquote {
    margin: 18px 0;
    padding: 12px 16px;

    background: rgba(139, 0, 255, 0.08);
    border-left: 4px solid var(--violet);

    color: #d7c4e8;
}

#reponse code {
    padding: 2px 6px;

    background: #08080d;
    border: 1px solid var(--noir-bord);
    border-radius: 5px;

    color: #d7b7ff;

    font-family: Consolas, "Courier New", monospace;
    font-size: 0.92em;
}

#reponse pre {
    overflow-x: auto;

    margin: 16px 0;
    padding: 16px;

    background: #08080d;
    border: 1px solid var(--noir-bord);
    border-radius: 8px;
}

#reponse pre code {
    padding: 0;

    background: transparent;
    border: none;

    color: var(--texte);
}

#reponse a {
    color: #c084fc;
    text-decoration: underline;
    text-underline-offset: 3px;
}

#reponse hr {
    height: 1px;

    margin: 24px 0;

    background: var(--noir-bord);
    border: none;
}

#reponse table {
    width: 100%;

    margin: 18px 0;

    border-collapse: collapse;

    font-size: 0.95em;
}

#reponse th,
#reponse td {
    padding: 10px 12px;

    border: 1px solid var(--noir-bord);

    text-align: left;
    vertical-align: top;
}

#reponse th {
    background: rgba(139, 0, 255, 0.16);

    color: var(--violet-clair);
    font-weight: bold;
}

#reponse tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.015);
}


/* ==========================================================
   CORRECTIONS DU QUIZ
   ========================================================== */

.correction-quiz {
    color: #cfd8d2;

    transition:
        opacity 0.2s ease,
        visibility 0.2s ease;
}

.correction-quiz strong {
    color: var(--vert-validation) !important;
}

.zone-reponse.corrections-masquees .correction-quiz {
    display: none;
}


/* ==========================================================
   BARRE DE DÉFILEMENT
   ========================================================== */

.zone-reponse {
    scrollbar-color: var(--violet-clair) var(--noir-carte);
    scrollbar-width: thin;
}

.zone-reponse::-webkit-scrollbar {
    width: 10px;
}

.zone-reponse::-webkit-scrollbar-track {
    background: var(--noir-carte);
}

.zone-reponse::-webkit-scrollbar-thumb {
    background: var(--violet-glow);
    border: 2px solid var(--noir-carte);
    border-radius: 10px;
}

.zone-reponse::-webkit-scrollbar-thumb:hover {
    background: var(--violet-clair);
}


/* ==========================================================
   PIED DE PAGE
   ========================================================== */

footer {
    padding: 15px;

    background: var(--noir-carte);
    border-top: 1px solid var(--noir-bord);

    color: var(--texte-gris);

    font-size: 0.85em;
    text-align: center;
}


/* ==========================================================
   AFFICHAGE SUR PETITS ÉCRANS
   ========================================================== */

@media (max-width: 650px) {
    header {
        padding: 18px 20px;
    }

    .nom {
        font-size: 1.8em;
    }

    .slogan {
        font-size: 0.85em;
    }

    main {
        margin: 25px auto;
        padding: 0 15px;
    }

    .modes {
        flex-direction: column;
    }

    .btn-mode {
        width: 100%;
    }

    .entete-niveaux {
        align-items: flex-start;
        flex-direction: column;

        gap: 6px;
    }

    .boutons-niveaux {
        grid-template-columns: 1fr;
    }

    .zone-saisie {
        padding: 18px;
    }

    .informations-saisie {
        align-items: flex-end;
        flex-direction: column;

        gap: 6px;
    }

    .actions {
        grid-template-columns: 1fr;
    }

    .zone-reponse {
        padding: 20px;
    }

    .zone-reponse .entete-reponse {
        align-items: flex-start;
        flex-direction: column;
    }

    .actions-reponse {
        width: 100%;
        justify-content: stretch;
    }

    .btn-copier,
    .btn-corrections {
        width: 100%;
    }

    #reponse h2 {
        font-size: 1.2em;
    }

    #reponse table {
        font-size: 0.85em;
    }

    #reponse th,
    #reponse td {
        padding: 8px;
    }
}