/* ----------  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;
    justify-content: space-between;
    margin-bottom: 10px;
}

.dropdown-group label {
    flex: 0 0 40%;
    text-align: left;
    color: var(--text-secondary);
}

.select-wrapper {
    position: relative;
    flex: 0 0 55%;
}

.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;
    color: var(--text-secondary);
    font-size: 12px;
}

.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;
}

/* ----------  Console redimensionnable ---------- */
#bottom {
    display: flex;
    flex-direction: column;
    flex: 0 0 250px;
    overflow: hidden;
}

#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;
}

.exercise-line--resumable {
    cursor: pointer;
    border-radius: 4px;
    padding: 2px 4px;
    margin-left: -4px;
    transition: background 0.15s;
}

.exercise-line--resumable:hover {
    background: rgba(255, 255, 255, 0.06);
}

/* ---------- 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;
}

/* ================================================
   PROFESSOR PAGE – body override
   ================================================ */
body:has(#professor-panel) {
    overflow-y: auto;
    display: block;
    height: auto;
    min-height: 100dvh;
}

/* ================================================
   PROFESSOR PANEL – Layout
   ================================================ */
#professor-panel {
    max-width: 1280px;
    margin: 0 auto;
    padding: 36px 32px;
}

#professor-panel h2 {
    margin: 0 0 28px;
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: bold;
    letter-spacing: -0.3px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 14px;
}

/* ================================================
   STUDENT CARDS
   ================================================ */
.student-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.student-card {
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent-blue);
    border-radius: 8px;
    background: var(--bg-secondary);
    overflow: visible;
    /* allow paste tooltips to overflow */
    transition: box-shadow 0.2s;
}

.student-card:hover {
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}

.student-header {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    padding-right: 36px;
    /* room for chevron */
    cursor: pointer;
    color: var(--text-primary);
    font-weight: bold;
    font-size: 0.95rem;
    letter-spacing: 0.2px;
    position: relative;
    user-select: none;
    background: var(--bg-tertiary);
    border-radius: 6px 6px 0 0;
    transition: background 0.2s;
}

.student-card:not([open]) .student-header {
    border-radius: 6px;
}

/* ---- Paste dots ---- */

.student-header::after {
    content: “▸”;
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%) rotate(0deg);
    transition: transform 0.2s;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.student-card[open]>.student-header::after {
    transform: translateY(-50%) rotate(90deg);
}

.student-header:hover {
    background: var(--bg-hover);
}

.student-header::-webkit-details-marker {
    display: none;
}

/* ================================================
   EXERCISE LIST
   ================================================ */
.exercise-list {
    display: flex;
    flex-direction: column;
}

/* shared column grid: status | title | created | finished */
.exercise-col-header,
.exercise-row,
.exercise-item--static {
    display: grid;
    grid-template-columns: 130px 1fr 240px 240px;
    align-items: center;
}

.exercise-col-header {
    padding: 7px 41px 7px 23px;
    background: #161616;
    border-bottom: 1px solid var(--border);
}

.exercise-col-header span {
    font-size: 0.72rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--text-muted);
}

.exercise-col-header span:nth-child(2) {
    padding-left: 12px;
}

/* ---- Exercise item ---- */
.exercise-item,
.exercise-item--static {
    margin: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.exercise-row,
.exercise-item--static {
    padding: 9px 14px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    transition: background 0.15s;
    list-style: none;
    position: relative;
}

.exercise-row {
    cursor: pointer;
    user-select: none;
    padding-right: 32px;
}

.exercise-item--static {
    padding-right: 32px;
    /* align columns with exercise-row */
}

.exercise-row::after {
    content: “▸”;
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%) rotate(0deg);
    transition: transform 0.2s;
    color: var(--text-muted);
    font-size: 0.72rem;
}

.exercise-item[open]>.exercise-row::after {
    transform: translateY(-50%) rotate(90deg);
}

.exercise-row:hover,
.exercise-item--static:hover {
    background: var(--bg-hover);
}

.exercise-row::-webkit-details-marker {
    display: none;
}

.exercise-name {
    padding: 0 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.exercise-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding-right: 8px;
}

/* ================================================
   CORRECTION HISTORY
   ================================================ */
.correction-history {
    background: #111;
    border-top: 1px solid var(--border);
}

.correction-entry {
    display: grid;
    grid-template-columns: 130px 1fr 240px 240px;
    align-items: center;
    padding: 8px 32px 8px 14px;
    border-bottom: 1px solid #1c1c1c;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.correction-entry .tag {
    width: 110px;
    font-size: 0.7rem;
    padding: 2px 3px;
}


.correction-entry:last-child {
    border-bottom: none;
}

.correction-text {
    grid-column: 2;
    padding: 0 12px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.correction-paste {
    grid-column: 3;
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.paste-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    display: inline-block;
    cursor: default;
    flex-shrink: 0;
}

#paste-tooltip {
    position: fixed;
    background: #282c34;
    border: 1px solid var(--border);
    padding: 8px 10px;
    border-radius: 4px;
    max-width: 400px;
    pointer-events: none;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

#paste-tooltip pre {
    white-space: pre-wrap;
    word-break: break-all;
    font-family: 'Fira Code', monospace;
}

.correction-date {
    grid-column: 4;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding-right: 8px;
}