/* Tallinna Tehnikaülikooli stiiliraamatu põhjal loodud stiilid */

/*
--- Värvipalett ---
TT Magenta: #e4067e
TT Burgundy: #aa1352
TT Dark Blue: #342b60
TT Light Blue: #4dbed2
TT Grey 1: #9396b0
TT Grey 2: #dadae4
TT White: #FFFFFF
TT Black: #000000
*/

:root {
    --taltech-magenta: #e4067e;
    --taltech-burgundy: #aa1352;
    --taltech-dark-blue: #342b60;
    --taltech-light-blue: #4dbed2;
    --taltech-grey-1: #9396b0;
    --taltech-grey-2: #dadae4;
    --taltech-white: #FFFFFF;
    --taltech-black: #000000;

    --bs-primary-rgb: 228, 6, 126; /* TT Magenta */
    --bs-secondary-rgb: 52, 43, 96; /* TT Dark Blue */
    --bs-danger-rgb: 170, 19, 82; /* TT Burgundy veateadete jaoks */
    --bs-info-rgb: 77, 190, 210; /* TT Light Blue info jaoks */
    --bs-link-color: var(--taltech-burgundy);
    --bs-link-hover-color: var(--taltech-dark-blue);

    --bs-body-font-family: Verdana, sans-serif;
    --bs-body-bg: var(--taltech-white);
    --bs-body-color: var(--taltech-black);
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex-grow: 1;
}

h1,
h2,
h3,
h4,
h5,
h6,
.h1,
.h2,
.h3,
.h4,
.h5,
.h6 {
    font-weight: bold;
    color: var(--taltech-dark-blue);
    line-height: 1.25;
    letter-spacing: -0.015em;
}

.card {
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.1);
    transition: 0.3s;
    border-radius: 8px;
    border-color: var(--taltech-grey-2);
}

.card:hover {
    box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
}

.card-header h1,
.card-header h2,
.card-header h3 {
    margin-bottom: 0;
}

/* TalTechi tumesinine kaardipäis (Variant B - EN 301 549 & WCAG AAA kontrastsussuhe 12.65:1) */
.card-header-taltech,
.card-header.bg-dark-blue {
    background-color: var(--taltech-dark-blue) !important;
    color: var(--taltech-white) !important;
    border-bottom: 3px solid var(--taltech-magenta);
}

.card-header-taltech h1,
.card-header-taltech h2,
.card-header-taltech h3,
.card-header-taltech h4,
.card-header-taltech h5,
.card-header-taltech h6,
.card-header-taltech .h1,
.card-header-taltech .h2,
.card-header-taltech .h3,
.card-header-taltech .h4,
.card-header-taltech .h5,
.card-header-taltech .h6,
.card-header.bg-dark-blue h1,
.card-header.bg-dark-blue h2,
.card-header.bg-dark-blue h3,
.card-header.bg-dark-blue .h1,
.card-header.bg-dark-blue .h2,
.card-header.bg-dark-blue .h3 {
    color: var(--taltech-white) !important;
}

/* Tagame pealkirjade korrektse teksti värvi heleda/tumeda kaardipäise sees */
.card-header.text-white h1,
.card-header.text-white h2,
.card-header.text-white h3,
.card-header.text-white .h1,
.card-header.text-white .h2,
.card-header.text-white .h3 {
    color: var(--taltech-white) !important;
}

.card-header.text-dark h1,
.card-header.text-dark h2,
.card-header.text-dark h3,
.card-header.bg-warning h1,
.card-header.bg-warning h2,
.card-header.bg-warning h3 {
    color: #212529 !important;
}

.btn-primary,
.btn-secondary,
.btn-outline-secondary {
    font-weight: bold;
}

.btn-primary {
    --bs-btn-bg: var(--taltech-magenta);
    --bs-btn-border-color: var(--taltech-magenta);
    --bs-btn-hover-bg: var(--taltech-burgundy);
    --bs-btn-hover-border-color: var(--taltech-burgundy);
    --bs-btn-focus-shadow-rgb: 228, 6, 126;
    --bs-btn-active-bg: var(--taltech-burgundy);
    --bs-btn-active-border-color: var(--taltech-burgundy);
    background-color: var(--taltech-magenta);
    border-color: var(--taltech-magenta);
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background-color: var(--taltech-burgundy);
    border-color: var(--taltech-burgundy);
    box-shadow: 0 0 0 0.25rem rgba(228, 6, 126, 0.5) !important;
}

.btn-outline-primary {
    --bs-btn-color: var(--taltech-magenta);
    --bs-btn-border-color: var(--taltech-magenta);
    --bs-btn-hover-color: var(--taltech-white);
    --bs-btn-hover-bg: var(--taltech-magenta);
    --bs-btn-hover-border-color: var(--taltech-magenta);
    --bs-btn-focus-shadow-rgb: 228, 6, 126;
    --bs-btn-active-color: var(--taltech-white);
    --bs-btn-active-bg: var(--taltech-magenta);
    --bs-btn-active-border-color: var(--taltech-magenta);
    color: var(--taltech-magenta);
    border-color: var(--taltech-magenta);
    background-color: transparent;
}

/* Ligipääsetavuse (kontrastsuse) parandus text-muted klassile, kuna vaikimisi #6c757d ei läbi 4.5:1 nõuet valgel taustal */
.text-muted {
    color: #495057 !important;
}

.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-primary:active {
    color: var(--taltech-white);
    background-color: var(--taltech-magenta);
    border-color: var(--taltech-magenta);
    box-shadow: 0 0 0 0.25rem rgba(228, 6, 126, 0.5) !important;
}

.btn-secondary {
    --bs-btn-bg: var(--taltech-dark-blue);
    --bs-btn-border-color: var(--taltech-dark-blue);
    --bs-btn-hover-bg: #1e1833;
    --bs-btn-hover-border-color: #1e1833;
    --bs-btn-focus-shadow-rgb: 52, 43, 96;
    --bs-btn-active-bg: #1e1833;
    --bs-btn-active-border-color: #1e1833;
    background-color: var(--taltech-dark-blue);
    border-color: var(--taltech-dark-blue);
}

.btn-secondary:hover,
.btn-secondary:focus,
.btn-secondary:active {
    background-color: #1e1833;
    border-color: #1e1833;
    box-shadow: 0 0 0 0.25rem rgba(52, 43, 96, 0.5) !important;
}

.btn-outline-secondary {
    --bs-btn-color: var(--taltech-dark-blue);
    --bs-btn-border-color: var(--taltech-dark-blue);
    --bs-btn-hover-color: var(--taltech-white);
    --bs-btn-hover-bg: var(--taltech-dark-blue);
    --bs-btn-hover-border-color: var(--taltech-dark-blue);
    --bs-btn-focus-shadow-rgb: 52, 43, 96;
    --bs-btn-active-color: var(--taltech-white);
    --bs-btn-active-bg: var(--taltech-dark-blue);
    --bs-btn-active-border-color: var(--taltech-dark-blue);
    color: var(--taltech-dark-blue);
    border-color: var(--taltech-dark-blue);
    background-color: transparent;
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus,
.btn-outline-secondary:active {
    color: var(--taltech-white);
    background-color: var(--taltech-dark-blue);
    border-color: var(--taltech-dark-blue);
    box-shadow: 0 0 0 0.25rem rgba(52, 43, 96, 0.5) !important;
}


/* Lehtede taustavärvid erinevate testitüüpide jaoks */

/* Ühekordne hindamine (vaikimisi ja valik.php) */
.bg-hindamine {
    background-color: #f8f9fa;
    /* Neutraalne helehall */
}

/* Harjutamine (valik_harjuta.php) */
.bg-harjutamine {
    background-color: #eef9fb;
    /* Väga hele sinine --taltech-light-blue alusel */
}

/* Harjutamisega hindamine (valik_hh.php) */
.bg-harjutamisega-hindamine {
    background-color: #fceef5;
    /* Väga hele roosa/magenta --taltech-magenta alusel */
}


/* Kella stiilid */
/* Old clock styles removed - consolidated below */



/* Keelevaliku nupud */
.lang-switch {
    display: inline-flex;
    align-items: center;
}

.lang-switch a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: var(--taltech-dark-blue);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.15s ease-in-out, color 0.15s ease-in-out;
}

.lang-switch a:hover {
    background-color: var(--taltech-grey-2);
    color: var(--taltech-dark-blue);
}

.lang-switch a:focus-visible {
    outline: 2px solid var(--taltech-magenta);
    outline-offset: 1px;
}

.lang-switch img {
    height: 18px;
    width: auto;
    border-radius: 3px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}


/* Raami lehe jaoks */
html.frame-page,
body.frame-page {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.frame-kell {
    flex: 0 0 32px !important;
    height: 32px !important;
    min-height: 32px !important;
    max-height: 32px !important;
    overflow: hidden !important;
    border: none;
    border-bottom: 1px solid var(--taltech-grey-2);
    width: 100%;
    display: block;
    /* Fallback */
}

.frame-kysimused {
    flex-grow: 1;
    /* Võtab ülejäänud ruumi */
    border: none;
    width: 100%;
}


/* Kysimused.php stiilid */
.question-card {
    transition: all 0.3s ease-in-out;
}

.question-card.marked-for-review {
    border-color: var(--taltech-magenta) !important;
    box-shadow: 0 0 .5rem rgba(228, 6, 126, 0.5);
}

.question-card .card-header {
    background-color: rgba(0, 0, 0, 0.015);
}

.form-check-label {
    cursor: pointer;
}

/* Hinda.php stiilid */
.grade-display {
    font-size: 3rem;
    font-weight: bold;
    color: var(--taltech-dark-blue);
}

.table-grade-user {
    background-color: var(--taltech-light-blue) !important;
    color: var(--taltech-black) !important;
    font-weight: bold;
}

.table-grade-user td {
    background-color: inherit !important;
}

.correctness-badge {
    min-width: 80px;
    text-align: center;
    display: inline-block;
    color: white;
    font-weight: bold;
    border-radius: .25rem;
    padding: .25em .6em;
}

.badge-correct {
    background-color: #198754;
    /* Bootstrap success green */
}

.badge-incorrect {
    background-color: #dc3545;
    /* Bootstrap danger red */
}


/* valik_harjuta.php and valik_hh.php */
.list-group-item .exercise-details,
.list-group-item .text-muted {
    font-size: 0.9em;
    color: #495057 !important;
    /* Bootstrap's original #6c757d text-muted doesn't pass 4.5:1 contrast on white background */
}

.list-group-item .exercise-stats {
    font-size: 0.85em;
    color: var(--taltech-dark-blue);
    background-color: rgba(77, 190, 210, 0.1);
    /* light blue tint */
    padding: 0.75rem;
    border-radius: 0.25rem;
    margin-top: 0.75rem;
    border-left: 4px solid var(--taltech-light-blue);
}

/* Tighter line-height for instructions */
.instruction-text {
    line-height: 1.4;
}

.instruction-text p,
.instruction-text ul,
.instruction-text ol {
    margin-bottom: 0.75rem;
}

.instruction-text b,
.instruction-text strong {
    color: var(--taltech-dark-blue);
}

/* index.php secondary actions */
.list-group-item-action {
    font-weight: 500;
    color: var(--taltech-dark-blue);
    font-weight: bold;
}

.list-group-item-action i {
    color: var(--taltech-magenta);
}

/* Hover effect for answer options */
.answer-option {
    transition: background-color 0.15s ease-in-out;
}

.answer-option:hover {
    background-color: #f8f9fa;
    /* A light grey hover effect, same as .bg-light */
}

/* Test selection options styling and visual feedback */
.test-option {
    cursor: pointer;
    transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    border: 2px solid transparent !important;
}

.test-option:hover {
    background-color: #f4f5f8;
    border-color: var(--taltech-grey-2) !important;
    position: relative;
    z-index: 1;
}

/* Selected state with TalTech Magenta styling */
.test-option:has(.form-check-input:checked) {
    background-color: rgba(228, 6, 126, 0.04);
    border-color: var(--taltech-magenta) !important;
    box-shadow: 0 2px 8px rgba(228, 6, 126, 0.12);
    position: relative;
    z-index: 2;
}

/* Keyboard focus state for EN 301 549 accessibility */
.test-option:focus-within {
    outline: 2px solid var(--taltech-dark-blue);
    outline-offset: 2px;
    position: relative;
    z-index: 3;
}

.test-option:has(.form-check-input:focus:not(:focus-visible)) {
    outline: none;
}

/* Radio button customization in test options matching TalTech palette */
.test-option .form-check-input {
    border: 2px solid var(--taltech-dark-blue);
    cursor: pointer;
    width: 1.25em;
    height: 1.25em;
    margin-top: 0.15em;
}

.test-option .form-check-input:checked {
    background-color: var(--taltech-magenta);
    border-color: var(--taltech-magenta);
}

.test-option .form-check-input:focus {
    box-shadow: 0 0 0 0.25rem rgba(228, 6, 126, 0.25);
    border-color: var(--taltech-magenta);
}

/* Accessibility fix: Ensure secondary text has high contrast */
.test-option .text-muted,
.test-option .exercise-details {
    color: #495057 !important;
}

.test-option:hover .text-muted,
.test-option:hover .exercise-details,
.test-option:has(.form-check-input:checked) .text-muted,
.test-option:has(.form-check-input:checked) .exercise-details {
    color: #212529 !important;
}

/* Test metadata and badges */
.test-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.test-badge {
    display: inline-flex;
    align-items: center;
    background-color: #f1f3f7;
    color: #495057;
    border: 1px solid var(--taltech-grey-2);
    border-radius: 4px;
    padding: 0.35rem 0.65rem;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.3;
}

.test-badge strong {
    color: var(--taltech-dark-blue);
    margin-left: 0.25rem;
}

.test-option:has(.form-check-input:checked) .test-badge {
    background-color: #ffffff;
    border-color: rgba(228, 6, 126, 0.3);
}

.test-option:has(.form-check-input:checked) .test-badge strong {
    color: var(--taltech-magenta);
}

/* Exercise details block */
.exercise-details {
    line-height: 1.5;
    font-size: 0.925rem;
}

/* Accessibility and Mobile-Friendly Improvements for Question View */

/* Accessibility and Mobile-Friendly Improvements for Question View */

/* Clock frame styles moved to line 161 */

/* --- CLOCK CONTENT (kell.php) --- */
/* Style the body of the clock page */
body.kell-body {
    background-color: #f8f9fa;
    /* Light grey background for better separation */
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* Style the clock container itself */
#kell-container {
    font-size: 1.1rem;
    /* Reduced font size for thinner bar */
    font-weight: 500;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

#kell-container .aega-tekst {
    color: var(--bs-secondary);
}

#kell-container .aeg {
    font-family: var(--bs-body-font-family);
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--bs-body-color);
}

/* Static footer button container */
.footer-container {
    background-color: #f8f9fa;
    /* bg-light */
    border-top: 1px solid var(--taltech-grey-2);
    padding: 1rem;
    margin-top: 2rem;
    /* Add some space above the footer */
}

/* Remove default background and shadow from the card-body when it's part of a question card */
.question-card>.card-body {
    background-color: transparent;
    box-shadow: none;
}

/* Custom styles for the confirmation checkbox on the generator page */
.generator-confirmation {
    background-color: rgba(52, 43, 96, 0.05);
    /* Õrn TalTech Dark Blue taust */
    border: 2px solid var(--taltech-grey-2);
    border-radius: 8px;
    padding: 1.25rem;
    margin: 1.5rem 0;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    /* Terve kast on kursoriga */
}

/* Hover ja Focus olekud */
.generator-confirmation:hover,
.generator-confirmation:focus-within {
    border-color: var(--taltech-dark-blue);
    background-color: #fff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Valitud olek - visuaalne kinnitus (JS lisab klassi) või input:checked alusel */
.generator-confirmation.is-checked,
.generator-confirmation:has(.form-check-input:checked) {
    background-color: rgba(228, 6, 126, 0.05);
    /* Väga õrn TalTech Magenta taust */
    border-color: var(--taltech-magenta);
}

.generator-confirmation .form-check-input {
    width: 1.8em;
    height: 1.8em;
    margin-top: 0;
    margin-right: 1rem;
    border: 2px solid var(--taltech-dark-blue);
    cursor: pointer;
    flex-shrink: 0;
    float: none;
    /* Tühistame Bootstrapi floati, et flexbox töötaks */
    margin-left: 0;
    position: relative;
    z-index: 2;
    /* Et oleks klikitav stretched-linki peal */
}

/* Märgitud olek TalTech Magenta värviga */
.generator-confirmation .form-check-input:checked {
    background-color: var(--taltech-magenta);
    border-color: var(--taltech-magenta);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10l3 3l6-6'/%3e%3c/svg%3e");
}

/* Fookuse ring ligipääsetavuse jaoks */
.generator-confirmation .form-check-input:focus {
    box-shadow: 0 0 0 0.25rem rgba(228, 6, 126, 0.25);
    border-color: var(--taltech-magenta);
}

.generator-confirmation .form-check-label {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--taltech-dark-blue);
    cursor: pointer;
    line-height: 1.4;
    user-select: none;
    display: block;
    /* Tagab, et stretched-link töötab korrektselt */
}

/* Flexbox joondus */
.generator-confirmation.form-check {
    display: flex;
    align-items: center;
    padding-left: 1.25rem;
    /* Taastame paddingu, mis muidu kaob .form-check klassiga */
}


/* --- CLOCK TIME'S UP STYLES --- */
body.kell-body.aeg-yle {
    background-color: #fceef5;
    /* Very light tint of TT Magenta */
    transition: background-color 0.5s ease;
}

#kell-container.aeg-yle .aega-tekst,
#kell-container.aeg-yle .aeg,
#kell-container.aeg-yle {
    color: var(--taltech-burgundy);
    /* TT Burgundy for text */
}

/* ==========================================================================
   LÕPLIK LAHENDUS: STIILID MOBIILISÕBRALIKE TABELITE JAOKS
   See koodiblokk rakendab "kaartideks" kohanduva vaate kõikidele
   tabelitele, millel on klass .table-responsive.
   ========================================================================== */

/* --- ÜLDINE KUJUNDUS (MÕJUTAB KÕIKI VAATEID) --- */

/* Konteiner faililingile (ikoon, nimi, suurus) */
.file-link-line {
    display: flex;
    align-items: center;
    /* <-- SEE ON PARANDUS */
    flex-wrap: wrap;
    gap: 0px 8px;
}

/* Faili allalaadimise link (ikoon + nimi) */
.file-download-link {
    color: var(--bs-link-color);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    word-break: break-all;
}

.file-download-link:hover {
    color: var(--bs-link-hover-color);
    text-decoration: underline;
}

/* Väike faili-ikoon */
.file-icon-sm {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    flex-shrink: 0;
}

/* Faili suurus */
.file-size {
    font-size: 0.9em;
    color: #6c757d;
    white-space: nowrap;
    flex-shrink: 0;
}

/* --- TÄISVAADE (EKRAANID LAIEMAD KUI 768px) --- */

@media (min-width: 769px) {

    /* Peidame akordioni avamise nupu, kuna sisu on alati nähtav */
    .materials-toggle {
        display: none;
    }

    /* Sunnime sisuploki alati avatuks */
    .materials-accordion .collapse {
        display: block !important;
    }

    /* Eemaldame sisuplokilt üleliigse polsterduse ja äärejoone */
    .materials-content {
        padding: 0;
        border-top: none;
    }
}


/* --- MOBIILIVAADE (EKRAANID KUNI 768px) --- */

@media (max-width: 768px) {

    /* Peidame tabeli päise */
    .table-responsive .table thead {
        display: none;
    }

    /* Muudame tabeli elemendid plokktaseme elementideks */
    .table-responsive .table,
    .table-responsive .table tbody,
    .table-responsive .table tr,
    .table-responsive .table td {
        display: block;
        width: 100%;
    }

    /* Stiilime iga rea "kaardina" */
    .table-responsive .table tr {
        margin-bottom: 1rem;
        border: 1px solid var(--taltech-grey-2);
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
        overflow: hidden;
    }

    .table-responsive .table tr:last-child {
        margin-bottom: 0;
    }

    /* Üldine lahtri stiil (kaheveeruline grid) */
    .table-responsive .table td {
        display: grid;
        grid-template-columns: 45% 55%;
        align-items: center;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid #f0f0f0;
        min-height: 44px;
        text-align: left;
    }

    .table-responsive .table tr td:last-child {
        border-bottom: none;
    }

    /* Sildi stiil */
    .table-responsive .table td::before {
        content: attr(data-label);
        font-weight: bold;
        color: var(--taltech-dark-blue);
        padding-right: 1rem;
        word-break: break-word;
    }

    /* Erandid pika sisuga lahtritele (küsimus, kirjeldus jne) */
    .table-responsive .table td[data-label*="Kirjeldus"],
    .table-responsive .table td[data-label*="Küsimus"],
    .table-responsive .table td[data-label*="kommentaar"] {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
    }

    .table-responsive .table td[data-label*="Kirjeldus"]::before,
    .table-responsive .table td[data-label*="Küsimus"]::before,
    .table-responsive .table td[data-label*="kommentaar"]::before {
        padding: 0;
    }

    /* Erand materjalide lahtrile (akordion) */
    .table-responsive .table td[data-label*="Materjale"] {
        grid-template-columns: 1fr;
        padding: 0;
    }

    .table-responsive .table td[data-label*="Materjale"]::before {
        display: none;
    }

    /* Akordioni nupu stiil */
    .materials-toggle {
        display: block;
        width: 100%;
        padding: 0.75rem 1rem;
        text-decoration: none;
        font-weight: bold;
        color: var(--taltech-dark-blue);
        position: relative;
        background-color: transparent;
        border: none;
        text-align: left;
    }

    .materials-toggle:hover {
        background-color: rgba(0, 0, 0, 0.02);
    }

    .materials-toggle::after {
        content: '▼';
        position: absolute;
        right: 1rem;
        top: 50%;
        transform: translateY(-50%);
        font-size: 0.7em;
    }

    .materials-toggle[aria-expanded="true"]::after {
        content: '▲';
    }

    /* Akordioni sisu stiil */
    .materials-content {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
        border-top: 1px solid #f0f0f0;
    }

    .materials-content .file-link-line {
        margin-bottom: 0;
    }

    /* Peidame õige vastuse korral "Tegelik vastus" rea */
    .vastus-oige td[data-label*="Tegelik"] {
        display: none;
    }
}

/* --- Tagasi üles nupp --- */
#btn-back-to-top {
    position: fixed;
    bottom: calc(110px + env(safe-area-inset-bottom, 0px));
    right: 30px;
    display: none;
    /* Vaikimisi peidetud */
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--taltech-magenta);
    color: var(--taltech-white);
    border: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.3s, opacity 0.3s;
    opacity: 0.9;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

#btn-back-to-top:hover {
    background-color: var(--taltech-burgundy);
    transform: translateY(-3px);
    opacity: 1;
}

#btn-back-to-top:focus {
    outline: 3px solid var(--taltech-dark-blue);
    outline-offset: 2px;
}

/* Ikooni joondus */
#btn-back-to-top i {
    line-height: 0;
}

/* Mobiilis veidi väiksem ja servale lähemal */
@media (max-width: 768px) {
    #btn-back-to-top {
        bottom: calc(120px + env(safe-area-inset-bottom, 0px));
        right: 20px;
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
    }
}

/* Sujuv kerimine tervele lehele */
html {
    scroll-behavior: smooth;
}

/* ==========================================================================
   KÜSIMUSTE NAVIGATSIOONIPANEEL
   ========================================================================== */

/* --- DESKTOP (≥769px): Sticky külgpaneel --- */
.question-nav-sidebar {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    padding: 1rem;
    background-color: var(--taltech-white);
    border: 1px solid var(--taltech-grey-2);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.question-nav-sidebar .nav-title {
    font-weight: bold;
    font-size: 0.85rem;
    color: var(--taltech-dark-blue);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--taltech-grey-2);
}

.question-nav-sidebar .nav-progress {
    font-size: 0.8rem;
    color: var(--taltech-grey-1);
    margin-bottom: 0.75rem;
}

.question-nav-sidebar .nav-progress strong {
    color: var(--taltech-dark-blue);
}

/* Küsimuste nuppude grid */
.question-nav-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-bottom: 1rem;
}

/* Üksiku küsimuse nupp */
.question-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid var(--taltech-grey-2);
    border-radius: 6px;
    background-color: #f8f9fa;
    color: var(--taltech-dark-blue);
    font-weight: bold;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    text-decoration: none;
    padding: 0;
    line-height: 1;
}

.question-nav-btn:hover {
    border-color: var(--taltech-dark-blue);
    background-color: var(--taltech-grey-2);
    color: var(--taltech-dark-blue);
    transform: scale(1.05);
    text-decoration: none;
}

.question-nav-btn:focus-visible {
    outline: 3px solid var(--taltech-magenta);
    outline-offset: 2px;
}

/* Vastatud olek */
.question-nav-btn.answered {
    background-color: #198754;
    border-color: #198754;
    color: var(--taltech-white);
}

.question-nav-btn.answered:hover {
    background-color: #157347;
    border-color: #157347;
    color: var(--taltech-white);
}

/* Märgitud olek */
.question-nav-btn.flagged {
    border-color: var(--taltech-magenta);
    box-shadow: 0 0 0 2px rgba(228, 6, 126, 0.3);
}

/* Aktiivne küsimus (vaateväljas) */
.question-nav-btn.active-question {
    border-color: var(--taltech-dark-blue);
    box-shadow: 0 0 0 2px rgba(52, 43, 96, 0.4);
}

/* Paneeli esitamisnupp */
.question-nav-submit {
    width: 100%;
    margin-top: 0.5rem;
}

/* --- MOBIIL: Ujuv avamisnupp --- */
#btn-nav-panel-toggle {
    position: fixed;
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    right: 20px;
    display: none;
    width: auto;
    min-width: 50px;
    height: 50px;
    border-radius: 25px;
    background-color: var(--taltech-dark-blue);
    color: var(--taltech-white);
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1040;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.3s;
    opacity: 0.95;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 16px;
    font-weight: bold;
    font-size: 0.9rem;
}

#btn-nav-panel-toggle:hover {
    background-color: #1e1833;
    transform: translateY(-2px);
}

#btn-nav-panel-toggle:focus {
    outline: 3px solid var(--taltech-magenta);
    outline-offset: 2px;
}

/* --- MOBIIL: Offcanvas paneeli stiilid --- */
#questionNavOffcanvas .offcanvas-header {
    background-color: var(--taltech-dark-blue);
    color: var(--taltech-white);
}

#questionNavOffcanvas .offcanvas-header .btn-close {
    filter: invert(1);
}

#questionNavOffcanvas .question-nav-grid {
    grid-template-columns: repeat(6, 1fr);
}

/* --- RESPONSIVE --- */

@media (min-width: 769px) {
    /* Desktop: Peidetud ujuv nupp ja offcanvas */
    #btn-nav-panel-toggle,
    #questionNavOffcanvas {
        display: none !important;
    }

    /* Desktop: Pealehe layout kaks veergu */
    .test-layout-with-nav {
        display: grid;
        grid-template-columns: 1fr 200px;
        gap: 1.5rem;
        align-items: start;
    }
}

@media (max-width: 768px) {
    /* Mobiil: Peidetud desktop paneel */
    .question-nav-sidebar.desktop-nav {
        display: none;
    }

    /* Mobiil: Ujuv nupp nähtav */
    #btn-nav-panel-toggle {
        display: flex;
    }

    /* "Tagasi üles" nupu positsioon ei kattuks uuega */
    #btn-back-to-top {
        bottom: 120px;
    }
}

/* ==========================================================================
   TABELITE SORTEERIMINE JA 3-TAASEMELINE ESILETÕSTMINE (VARIANT A)
   Euroopa digiligipääsetavuse standard EN 301 549 & TalTechi stiiliraamat
   ========================================================================== */

/* 1. tase: Aktiivne nooleindikaator (TalTechi aktsentpunane #E0004D vektorkolmnurk) */
.sort-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    color: #E0004D !important;
    vertical-align: middle;
    flex-shrink: 0;
    white-space: nowrap;
}

.sort-arrow-svg {
    display: inline-block;
    vertical-align: -0.05em;
    width: 13px;
    height: 13px;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.15));
}

/* 2. tase: Aktiivselt sorditud päiselahter ise */
/* Hele päis (vaikimisi thead.table-light või thead th) */
th[aria-sort="ascending"],
th[aria-sort="descending"],
th.sortable-header[aria-sort="ascending"],
th.sortable-header[aria-sort="descending"],
th.sorted {
    background-color: #f1f5f9 !important;
    color: #1e293b !important;
    box-shadow: inset 0 -3px 0 #E0004D !important;
    font-weight: 600 !important;
}

/* Tume päis (kui tabel kasutab tumesinist päisetausta #003366 või thead.table-dark) */
.table-dark th[aria-sort="ascending"],
.table-dark th[aria-sort="descending"],
thead.table-dark th[aria-sort="ascending"],
thead.table-dark th[aria-sort="descending"] {
    background-color: #002244 !important;
    color: #ffffff !important;
    box-shadow: inset 0 -3px 0 #E0004D !important;
    font-weight: 600 !important;
}

/* 3. tase: Sorteeritavate veergude hõljukolek (:hover) ja Fittsi seadusele vastav klõpsatavus */
th.sortable,
th.sortable-header,
th:has(.sort-header-link) {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease, color 0.15s ease;
    white-space: normal;
    vertical-align: middle;
}

/* Jrk / järjekorranumbri veeru stabiilsus - ei poolita pealkirja kahele reale ega muutu liiga kitsaks */
th[data-sort-col="jrk"],
th[data-col-slug="jrk"],
th[data-sort-col="nr"],
th[data-col-slug="nr"],
th.col-jrk,
td.col-jrk {
    white-space: nowrap !important;
    width: 1%;
    text-align: center;
}

/* Tegevuse/graafiku veerg - kompaktne ega veni liigselt laiaks */
th.col-action,
td.col-action {
    white-space: nowrap !important;
    width: 1%;
    text-align: center;
}

/* Andmetabelite päiste ja lahtrite vertikaalne joondus */
.data-table-sortable thead th {
    vertical-align: middle;
}

/* Heleda päise hõljukolek */
th.sortable:hover,
th.sortable-header:hover,
th:has(.sort-header-link):hover {
    background-color: #f8fafc !important;
}

/* Tumeda päise hõljukolek */
.table-dark th.sortable:hover,
.table-dark th.sortable-header:hover,
thead.table-dark th.sortable:hover,
thead.table-dark th.sortable-header:hover {
    background-color: #002b55 !important;
}

/* Fittsi seadus: link täidab 100% lahtri pinnast, hoides teksti ja noole kompaktselt koos */
.sort-header-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: 100%;
    color: inherit !important;
    text-decoration: none !important;
    white-space: normal;
}

.sort-header-link span {
    white-space: normal;
}

th:hover .sort-header-link {
    color: inherit !important;
}

/* Digiligipääsetavuse klaviatuurifookus (EN 301 549) */
th.sortable:focus-visible,
th.sortable-header:focus-visible,
.sort-header-link:focus-visible,
.mobile-sort-select:focus-visible {
    outline: 2px solid #E0004D !important;
    outline-offset: -2px !important;
    border-radius: 2px;
}

/* Mobiilne sorteerimisriba (<select>) tabeli kohal */
.mobile-sort-bar {
    display: none; /* Töölaual vaikimisi peidetud */
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    background-color: #ffffff;
    border: 1px solid var(--taltech-grey-2);
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.mobile-sort-bar .mobile-sort-label {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--taltech-dark-blue);
    white-space: nowrap;
    margin-bottom: 0;
}

.mobile-sort-bar .mobile-sort-select {
    flex-grow: 1;
    font-size: 0.875rem;
    border-color: var(--taltech-grey-2);
}

@media (max-width: 768px) {
    /* Mobiilivaates kuvatakse sorteerimisriba kaardivaate kohal */
    .mobile-sort-bar {
        display: flex;
    }
}

/* --- LEHEKÜLJESTAMINE JA TÕRKEKINDLUS (STEPPER & RESILIENCE) --- */

.question-page {
    display: block;
}

.question-page[hidden] {
    display: none !important;
}

.question-page.active-page {
    animation: fadeInPage 0.2s ease-in-out;
}

@keyframes fadeInPage {
    from {
        opacity: 0.4;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-header {
    border-left: 4px solid var(--taltech-magenta) !important;
}

.page-footer {
    border-top: 2px solid var(--taltech-grey-2) !important;
}

.page-footer .btn {
    min-width: 140px;
    padding: 0.6rem 1.25rem;
    font-weight: 600;
}

@media (max-width: 576px) {
    .page-footer {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }
    .page-footer .btn {
        width: 100%;
    }
}

/* Mustandi staatuse indikaator textarea all */
.draft-indicator {
    min-height: 1.25rem;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    font-size: 0.85rem;
    color: #555;
    font-style: italic;
}

.draft-indicator.visible {
    opacity: 1;
}

/* Kinnitusakna hüppenupud vastamata ja märgitud küsimustele */
.modal-jump-btn {
    min-width: 2.5rem;
    font-weight: 600;
    border-radius: 4px;
    transition: transform 0.1s ease-in-out;
}

.modal-jump-btn:hover {
    transform: scale(1.05);
}

.modal-jump-btn:focus-visible {
    outline: 2px solid var(--taltech-magenta) !important;
    outline-offset: 1px;
}

/* Küsimuste paneeli lehemarker */
.question-nav-btn.current-page-btn {
    box-shadow: 0 0 0 2px var(--taltech-dark-blue);
    font-weight: 700;
}