/* ================= ROOT VARIABLES ================= */

:root {
    --primary: #6b3129;
    --primary-dark: #4b1f19;
    --accent: #843c31;

    --bg: #f3f4f6;
    --card-bg: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
}

body.dark {
    --bg: #111827;
    --card-bg: #1f2937;
    --text: #f3f4f6;
    --muted: #9ca3af;
}

/* ================= RESET ================= */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', sans-serif;
}

body {
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
}

html {
    overflow-y: scroll;
}

/* ================= LAYOUT STRUCTURE ================= */

.dashboard {
    display: flex;
    min-height: 100vh;
}

/* ================= SIDEBAR ================= */

.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
}

.logo h2 {
    font-size: 1.3rem;
}

.logo span {
    font-size: 0.85rem;
    opacity: 0.8;
}

.sidebar-nav {
    margin-top: 40px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.sidebar-nav a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0.9;
    transition: 0.2s ease;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    opacity: 1;
}

/* ================= MAIN AREA ================= */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ================= TOPBAR ================= */

.topbar {
    background: var(--card-bg);
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.topbar h1 {
    font-size: 1.5rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.theme-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text);
}

/* ================= CONTENT WRAPPER ================= */

.content {
    padding: 40px;
    display: flex;                /* STACK SECTIONS VERTICALLY */
    flex-direction: column;
    gap: 40px;                    /* STRONG SECTION SEPARATION */
}

/* ================= CARD CONTAINER ================= */

.card {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    border: 1px solid rgba(0,0,0,0.05); /* subtle separation */
    transition: background 0.3s ease;
}

.card h3 {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-grid-4x3 {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 columns */
    grid-template-rows: repeat(3, auto);  /* 3 rows */
    gap: 20px;                             /* spacing between cards */
}

/* ================= GENERIC GRID (HOMEPAGE) ================= */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 18px;
    margin-top: 10px;
}

/* ================= BUTTONS ================= */

.card-btn {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border: none;
    border-radius: 14px;
    padding: 16px;
    color: white;
    font-weight: 600;
    cursor: pointer;

    display: flex;
    align-items: center;
    gap: 10px;

    transition: all 0.25s ease;
}

.card-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 18px rgba(0,0,0,0.15);
}

.card-btn.secondary {
    background: linear-gradient(135deg, #374151, #1f2937);
}

/* ================= FIELDSETS (QUIZ PAGE) ================= */

fieldset {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 16px;
    border: none;
    box-shadow: 0 6px 18px rgba(0,0,0,0.05);
    margin-bottom: 30px;
}

legend {
    font-weight: bold;
    color: var(--primary);
    padding: 0 10px;
}

/* ================= EMPLOYEE GRID ================= */

.employee-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
}

/* ================= FORM ELEMENTS ================= */

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

input[type="text"],
input[type="password"],
select {
    width: 100%;
    padding: 12px;
    margin-bottom: 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    background: var(--bg);
    color: var(--text);
}


input:focus,
select:focus {
    border-color: var(--primary);
    outline: none;
}

/* ================= QUIZ GRID ================= */

.quiz-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;

    max-height: 65vh;
    overflow-y: auto;

    padding-right: 8px;

    scroll-behavior: smooth;
}

/* Subtle scrollbar styling */
.quiz-grid::-webkit-scrollbar {
    width: 8px;
}

.quiz-grid::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: 10px;
}

body.dark .quiz-grid::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
}

/* Quiz Question Card */
.quiz-question {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.05);
    transition: transform 0.2s ease;
}

.quiz-question:hover {
    transform: translateY(-3px);
}

.quiz-question h3 {
    margin-bottom: 10px;
    color: var(--primary);
}

.quiz-question p {
    margin-bottom: 12px;
    font-weight: 500;
}

.quiz-question label {
    font-weight: normal;
    margin-bottom: 6px;
    display: block;
    cursor: pointer;
}

/* ================= BUTTON ROW ================= */

.button-row {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 20px;
}

.button-group-left,
.button-group-right {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.action-button,
.secondary-button {
    border: none;
    border-radius: 14px;
    padding: 14px 20px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}

.action-button {
    background: linear-gradient(135deg, var(--primary), var(--accent));
}

.secondary-button {
    background: linear-gradient(135deg, #374151, #1f2937);
}

.action-button:hover,
.secondary-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 18px rgba(0,0,0,0.15);
}

/* ================= RESULTS ================= */

.correct {
    border: 2px solid #16a34a;
    background-color: #dcfce7;
}

.incorrect {
    border: 2px solid #dc2626;
    background-color: #fee2e2;
}

.result-box {
    margin-top: 20px;
    padding: 15px;
    border-radius: 12px;
    font-weight: bold;
}

.result-box.pass {
    background-color: #dcfce7;
    color: #166534;
}

.result-box.fail {
    background-color: #fee2e2;
    color: #991b1b;
}

/* ================= RESPONSIVE ================= */

@media (max-width: 1100px) {
    .quiz-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {

    .sidebar {
        display: none;
    }

    .content {
        padding: 20px;
    }

    .quiz-grid {
        grid-template-columns: 1fr;
    }

    .employee-grid {
        grid-template-columns: 1fr;
    }

    .button-row {
        justify-content: center;
    }
}

.quiz-panel {
    position: relative;
}

.quiz-panel::after {
    content: "";
    position: absolute;
    bottom: 80px; /* above sticky bar */
    left: 0;
    right: 0;
    height: 40px;
    pointer-events: none;

    background: linear-gradient(
        to bottom,
        rgba(255,255,255,0),
        var(--card-bg)
    );
}

body.dark .quiz-panel::after {
    background: linear-gradient(
        to bottom,
        rgba(17,24,39,0),
        var(--card-bg)
    );
}

.quiz-panel {
    display: flex;
    flex-direction: column;
}

/* ================= STICKY QUIZ ACTION BAR ================= */

.quiz-panel form {
    display: flex;
    flex-direction: column;
}

.quiz-panel .button-row,
.quiz-panel .result-box,
.quiz-panel #postQuizActions {
    position: sticky;
    bottom: 0;

    background: var(--card-bg);
    padding-top: 15px;
    padding-bottom: 10px;

    z-index: 5;
}

.quiz-panel .button-row {
    border-top: 1px solid rgba(0,0,0,0.08);
    margin-top: 10px;
}

body.dark .quiz-panel .button-row {
    border-top: 1px solid rgba(255,255,255,0.1);
}

body.dark {
    --bg: #0f172a;          /* deeper navy */
    --card-bg: #1e293b;     /* stronger contrast */
    --text: #f8fafc;
    --muted: #94a3b8;
}

body.dark .quiz-question {
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}

body.dark fieldset {
    box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}

body.dark .correct {
    background-color: #064e3b;
    border-color: #10b981;
    color: #d1fae5;
}

body.dark .incorrect {
    background-color: #7f1d1d;
    border-color: #ef4444;
    color: #fee2e2;
}

body.dark .result-box.pass {
    background-color: #065f46;
    color: #d1fae5;
}

body.dark .result-box.fail {
    background-color: #7f1d1d;
    color: #fee2e2;
}


/* ================= QUIZ PROGRESS ================= */

.quiz-progress {
    margin-bottom: 20px;
}

.progress-text {
    font-weight: 600;
    margin-bottom: 8px;
}

.progress-bar {
    height: 8px;
    background: rgba(0,0,0,0.08);
    border-radius: 20px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transition: width 0.3s ease;
}

body.dark .progress-bar {
    background: rgba(255,255,255,0.1);
}

.home-button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background-color: #1e3a8a; /* adjust to match theme */
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    transition: background 0.2s ease;
}

.home-button:hover {
    background-color: #162d6b;
}

/* Override .grid for 4x3 fixed card layout */
.content .grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: auto;
    gap: 20px;
}

@media (max-width: 1100px) {
    .content .grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 700px) {
    .content .grid {
        grid-template-columns: 1fr;
    }
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* Left align ONLY Name and Course columns */
table th:nth-child(1),
table td:nth-child(1),
table th:nth-child(2),
table td:nth-child(2) {
    text-align: left;
}