/* ----------  Colour System  ---------- */
:root {
    /* Greys */
    --bg-black: #000000;
    --bg-primary: #171717;  /* page background */
    --bg-secondary: #191919;/* cards / panels */
    --bg-tertiary: #1e1e1e; /* buttons / inputs */
    --bg-hover: #232323;    /* hover state */
    --border: #282828;

    /* Text */
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #7a7a7a;

    /* Accents */
    --accent-blue: #5daeff; /* links */
    --accent-green: #28a745;/* success */
    --accent-red:  #dc3545; /* error */
}

/* ----------  Base Layout  ---------- */
html,body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: var(--bg-primary) linear-gradient(135deg, #191919, #0f0f0f) no-repeat fixed center;
    color: var(--text-secondary);
    font-family: 'Fira Code', monospace;
}

body {
    display: flex;
    flex-direction: column;
}

/* ----------  Containers  ---------- */
#container {
    display: flex;
    flex: 1;
    width: 100%;
    min-height: 0;
    overflow: hidden;
    border-bottom: 2px solid var(--border);
}

#left-container {
    display: flex;
    flex-direction: column;
    width: 60%;
    overflow: hidden;
}

/* ----------  Tabs  ---------- */
.tab-bar {
    display: flex;
    gap: 10px;
    padding: 10px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.tab-link {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}
.tab-link:hover,
.tab-link.active {
    background: var(--bg-hover);
}

.tab-content {
    display: none;
    flex: 1;
    overflow: hidden;
}
.tab-content.active {
    display: flex;
    flex-direction: column;
}

/* Editors */
#editor-area-python,
#editor-area-html,
#editor-area-css,
#editor-area-js {
    width: 100%;
    height: 100%;
    flex: 1;
}

/* ----------  Side‑panel  ---------- */
#side-panel {
    width: 40%;
    background: var(--bg-secondary);
    border-left: 2px solid var(--border);
    padding: 10px;
    overflow-y: auto;
    position: relative;
    box-sizing: border-box;
}

.side-tabs {
    display: flex;
    margin-bottom: 30px;
}

.side-tab-link {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    cursor: pointer;
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    transition: background 0.2s;
    border-radius: 0;
}
.side-tab-link:hover,
.side-tab-link.active {
    background: var(--bg-hover);
}

.side-tab-full .side-tab-link {
    width: 100%;
}
.side-tab-content {
    display: none;
}

/* ----------  Buttons  ---------- */
button,
.side-btn {
    width: 100%;
    height: 32px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}
button:hover,
.side-btn:hover {
    background: var(--bg-hover);
}
button:disabled,
.side-btn:disabled {
    background: #1a1a1a;
    border-color: var(--border);
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.6;
}

/* ----------  Dropdowns / Inputs  ---------- */
.dropdown-group {
    display: flex;
    align-items: center;   /* contenu centré verticalement */
    gap: 10px;             /* espace entre colonnes        */
    margin-bottom: 10px;
}

/* Colonne libellé : largeur fixe et jamais de retour à la ligne */
.dropdown-group > label {
    flex: 0 0 260px;       /* largeur suffisante ; ajustez si besoin */
    white-space: nowrap !important;   /* force une seule ligne        */
}

/* Colonne sélecteur : prend tout le reste */
.select-wrapper {
    position: relative;
    flex: 1 1 0;           /* s’étend/retrécit librement           */
    min-width: 0;          /* empêche toute largeur mini implicite */
}

/* Select inchangé (garde votre style existant) */
.select-wrapper select {
    width: 100%;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 32px 6px 10px;
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}
.select-wrapper select:focus {
    outline: none;
    box-shadow: none;
}

.select-wrapper .custom-arrow {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    pointer-events: none;
    font-size: 12px;
    color: var(--text-secondary);
}

.input-field,
.dropdown {
    width: 100%;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 10px;
    font-size: 16px;
    box-sizing: border-box;
}

/* ----------  Text & Content Styles  ---------- */
#exercise-title {
    color: var(--text-primary);
    text-align: center;
    font-weight: bold;
    font-size: 20pt;
    margin-top: 0;
}

#exercise-content {
    line-height: 1.5;
    font-size: 15px;
    margin: 10px;
}

#exercise-content h1,
#exercise-content h2,
#exercise-content h3,
#exercise-content h4,
#exercise-content h5,
#exercise-content h6 {
    color: var(--text-primary);
    margin: 20px 0 10px;
    font-weight: bold;
}

#exercise-content a {
    color: var(--accent-blue);
    text-decoration: none;
}
#exercise-content a:hover {
    text-decoration: underline;
}

#exercise-content code {
    background: var(--bg-tertiary);
    color: #c5c5c5;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 14px;
}

/* Lists with vertical bar for first‑level ordered lists */
#exercise-content ol:not(ol ol) > li {
    position: relative;
    padding-left: 10px;
    margin: 20px 0 5px;
}
#exercise-content ol:not(ol ol) > li::before {
    content: "";
    position: absolute;
    left: -25px;
    top: 25px;
    bottom: 5px;
    width: 1px;
    background-color: var(--text-secondary);
}

#exercise-content ul,
#exercise-content ol {
    margin: 10px 0 10px 30px;
    padding: 0;
}
#exercise-content li {
    margin: 5px 0;
}

#exercise-content pre {
    background: #2a2a2a;
    border: 1px solid var(--border);
    border-radius: 4px;
    margin: 10px 0;
    overflow-x: auto;
}
#exercise-content pre code {
    display: block;
    padding: 10px;
    color: #eaeaea;
    font-size: 14px;
}

/* ----------  Output Console  ---------- */
#bottom {
    padding: 10px;
}

#output {
    background: #0e0e0e;
    color: #0f0;
    padding: 10px;
    margin: 10px 0 0 0;
    height: 200px;
    overflow: auto;
    white-space: pre;
    font-family: "Fira Code", monospace;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.error-highlight {
    background-color: rgba(220, 53, 69, 0.25);
}

/* ----------  Misc  ---------- */
hr {
    margin: 30px 10px;
    border-color: var(--border);
}

#button-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.resizer {
    background: var(--border);
    z-index: 100;
}

.resizer.vertical {
    width: 5px;
    cursor: col-resize;
}

.resizer.horizontal {
    height: 5px;
    width: 100%;
    cursor: row-resize;
}

#button-row {
    flex: 0 0 auto;
}

#output {
    flex: 1 1 auto;
    height: auto;
}

/* ---------- Overlay de chargement ---------- */
#loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    color: #fff;
    font-size: 1.5rem;
    font-weight: bold;
    font-family: sans-serif;
}

#loading-overlay.hidden {
    display: none;
}

/* ---- Badges & liste d’exercices ---- */
.tags {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;               /* espacement vertical entre les exercices */
}

/* ---------- BADGE ---------- */
.tag {
    /* aspect visuel */
    background-color: #444;
    color: #fff;
    border-radius: 8px;
    padding: 2px 4px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: transform 0.2s ease, filter 0.2s ease;

    /* comportement “inline” */
    display: inline-block;  /* reste dans le flux du texte            */
    width: 110px;           /* même largeur pour tous les badges      */
    white-space: nowrap;    /* ne passe jamais à la ligne             */
    text-align: center;     /* mot centré dans le badge               */
    vertical-align: top;    /* reste aligné en haut du texte          */
    margin-right: 8px;      /* petit espace après le badge            */
}

.tag:hover {
    transform: scale(1.03);
    filter: brightness(1.1);
    cursor: default;
}

/* ---- Couleurs spécifiques ---- */
.tag-correct        { background-color: var(--accent-green); }
.tag-maladresse     { background-color: var(--accent-red);   }
.tag-non-fini       { background-color: #ffc107;             } /* jaune */
.tag-invalide       { background-color: #6c757d;             } /* gris  */

/* ---------- LIGNE D’EXERCICE ---------- */
.exercise-line {
    /* plus besoin de flex : simple bloc vertical */
    margin-bottom: 6px;
    line-height: 1.3;
}

/* ---------- TITRE ---------- */
.exercise-title {                     /* style commun */
    display: inline;                  /* reste dans le même flux que le badge */
}

/* teinte légère suivant le statut */
.exercise-title-correct    { color: var(--accent-green); }
.exercise-title-maladresse { color: var(--accent-red);   }
.exercise-title-non-fini   { color: #ffc107;             }
.exercise-title-invalide   { color: #6c757d;             }

/* -------- Professeur : liste des élèves -------- */
#professor-panel {
    padding: 20px;
    overflow-y: auto;
}

#professor-panel h2 {
    margin-top: 0;
    color: var(--text-primary);
    font-size: 1.4rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

.student-list details {
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-tertiary);
    margin-bottom: 12px;
    overflow: hidden;            /* pour que les coins restent arrondis */
}

/* En-tête cliquable -------------------------------- */
.student-list summary {
    list-style: none;            /* supprime le triangle natif */
    padding: 10px 14px;
    cursor: pointer;
    color: var(--text-primary);
    font-weight: bold;
    position: relative;
    user-select: none;
    transition: background 0.2s;
}
.student-list summary::after {   /* chevron personnalisé */
    content: "▸";
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%) rotate(0deg);
    transition: transform 0.2s;
}
.student-list details[open] summary::after {
    transform: translateY(-50%) rotate(90deg);
}
.student-list summary:hover {
    background: var(--bg-hover);
}

/* Tableau d’exercices ------------------------------ */
.exercise-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-secondary);
}

.exercise-table th,
.exercise-table td {
    padding: 0;
    text-align: left;
    font-size: 0.85rem;
}

.exercise-table thead th {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    font-weight: bold;
}

.exercise-table thead.student-head th {
    padding: 8px 12px;          /* même base que le corps */
    box-sizing: border-box;     /* garde la largeur calculée */
}

.exercise-table tbody tr:hover {
    background: var(--bg-hover);
}

.exercise-table tbody tr:hover td.exercise-wrapper {
    background: var(--bg-secondary);
    cursor: default;
}

/* Badge : garde une largeur fixe */
.exercise-table td:first-child {
    white-space: nowrap;
}

/* ----------  Largeur des colonnes (en %)  ---------- */
:root {
    --col-status: 146px;   /* fixe : badge */
    --col-date: 270px;   /* fixe : dates “créé” & “fini” */
    --chevron: 30px; 
    --col-mini-pastes: 140px;    
}

.exercise-table,
.mini-table {
    width: 100%;
    table-layout: fixed;        /* indispensable pour que <col> s'applique */
}


.col-status,
.col-mini-status  { width: var(--col-status); }

.col-created,
.col-finished,
.col-mini-date    { width: var(--col-date);  }

.col-name,
.col-mini-summary { width: auto;             }  /* occupe tout le reste */

.col-mini-pastes { width: var(--col-mini-pastes); }

/* ===== Exercices déroulants (niveau 2) ===== */
.exercise-wrapper {
    padding: 0;               /* supprime le padding par défaut du <td> */
}

.exercise-details {
    display: block;           /* nécessaire pour un layout fiable dans la cellule */
}

/* -------- Ligne “niveau 1” -------- */
.exercise-summary {
    display: grid;
    grid-template-columns:
        var(--col-status)  /* Status  */
        1fr                /* Nom     */
        var(--col-date)    /* Créé    */
        calc(var(--col-date) - var(--chevron));   /* Terminé */
    align-items: center;
    gap: 0;
    position: relative;
    padding: 8px 12px;
    cursor: pointer;
    user-select: none;
    color: var(--text-secondary);
    background: var(--bg-secondary);
}

/* Chevron perso */
.exercise-summary::before {
    content: "▸";
    position: absolute;
    left: -16px;               /* apparaît juste avant la première colonne */
    transition: transform 0.2s;
}
.exercise-details[open] .exercise-summary::before {
    transform: rotate(90deg);
}

/* Effets état ouvert / survol */
.exercise-summary:hover {
    background: var(--bg-hover);
}
.exercise-details[open] .exercise-summary {
    border-bottom: 1px solid var(--border);
}

/* cache le marker natif (Chrome) */
.exercise-summary::-webkit-details-marker {
    display: none;
}

/* -------- Mini-tableau “niveau 2” -------- */
.mini-table {
    border-collapse: collapse;
    background: var(--bg-secondary);
}

.mini-table th,
.mini-table td {
    padding: 6px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
}

.mini-table thead th {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    font-weight: bold;
}

/* cellule : même padding que les autres, aucun flex */
.copie-colle-cell {
    padding: 6px 12px;
    white-space: nowrap;           /* tout tient sur une ligne            */
}

/* pastille blanche alignée au milieu du texte */
.paste-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    margin-right: 6px;
    vertical-align: middle;        /* centre verticalement                */
    cursor: help;
}

/* ─── Désactiver le survol dans le mini-tableau ─────────────────────────── */
.exercise-table tbody tr:hover,
.exercise-table tbody tr:hover td.exercise-wrapper {
    background: var(--bg-secondary);   /* remet la couleur normale           */
}

/* Garder le survol uniquement sur l’en-tête de l’exercice */
.exercise-summary:hover {              /* règle déjà présente ; on confirme  */
    background: var(--bg-hover);
}

#login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    width: 100%;
}

#login-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 40px 32px;
    width: 320px;
    box-sizing: border-box;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.65);
}

#login-box h1 {
    color: var(--text-primary);
    text-align: center;
    margin: 0 0 24px 0;
    font-size: 1.6rem;
}

#login-box label {
    display: block;
    color: var(--text-primary);
    margin: 12px 0 6px;
    font-size: 0.95rem;
}

#login-box .input-field {
    width: 100%;
}

#login-box .side-btn {
    width: 100%;
    margin-top: 18px;
}

#question-box {
    margin-top: 26px;
}

.login-footer {
    margin-top: 20px;
    margin-bottom: 0;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

.question-sentence {
    color: var(--text-primary);
    margin: 0 0 12px 0;
    font-size: 0.95rem;
}

.question-choices button {
    width: 100%;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.floating {
    will-change: transform, box-shadow;
    backface-visibility: hidden;   /* réduit encore le flou éventuel   */
}

/* ----------  Terminal & Web‑preview  ---------- */
#web-preview {
    width: 100%;
    height: 250px;          /* même hauteur initiale que le terminal */
    flex: 0 0 250px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-tertiary);
}

/* ---------- Console Python & Web‑preview (même bloc) ---------- */
#bottom {
    display: flex;
    flex-direction: column;
    flex: 0 0 250px;          /* hauteur initiale contrôlée par le resizer */
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 4px;
}

#output,
#web-preview {
    flex: 1 1 auto;           /* ils occupent tout l'espace restant       */
    width: 100%;
    overflow: auto;
    background: var(--bg-tertiary);
    color: var(--text-primary);   /* texte blanc par défaut */
}
