/* ==========================================================
   GLOBAL VARIABLES
========================================================== */
:root {
    --transition: all 0.3s ease;

    /* LIGHT THEME */
    --bg-light: linear-gradient(135deg, #eef2ff 0%, #f7faff 100%);
    --glass-light-bg: rgba(255, 255, 255, 0.35);
    --glass-light-border: rgba(255, 255, 255, 0.25);
    --glass-light-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    --text-light: #1f1f1f;

    /* DARK THEME */
    --bg-dark: linear-gradient(135deg, #0d0d11 0%, #18181c 100%);
    --glass-dark-bg: rgba(25, 25, 25, 0.40);
    --glass-dark-border: rgba(255, 255, 255, 0.10);
    --glass-dark-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    --text-dark: #e5e5e5;

    /* ICON COLORS */
    --ff-icon-light: #1f1f1f;
    --ff-icon-dark: #e5e5e5;

    /* LOGO COLORS */
    --ff-logo-light: #0d6efd;
    --ff-logo-dark: #82baff;
}

/* ==========================================================
   BASE / OS AUTO THEME
========================================================== */
html, body {
    height: 100%;
}

body {
    transition: background 0.35s ease, color 0.35s ease;
}

@media (prefers-color-scheme: dark) {
    body:not([data-theme]) {
        background: var(--bg-dark);
        color: var(--text-dark);
    }
}

@media (prefers-color-scheme: light) {
    body:not([data-theme]) {
        background: var(--bg-light);
        color: var(--text-light);
    }
}

/* ==========================================================
   THEME: LIGHT MODE (Explicit)
========================================================== */
body[data-theme="glass-light"] {
    background: var(--bg-light);
    color: var(--text-light);
}

body[data-theme="glass-light"] .logo-text,
body[data-theme="glass-light"] .navbar-brand .svg-inline--fa {
    color: var(--ff-logo-light) !important;
}

body[data-theme="glass-light"] footer {
    background: rgba(255, 255, 255, 0.6) !important;
    color: #1f1f1f !important;
}

body[data-theme="glass-light"] footer .text-muted,
body[data-theme="glass-light"] footer a,
body[data-theme="glass-light"] footer strong {
    color: #1f1f1f !important;
}

/* ==========================================================
   THEME: DARK MODE (Explicit)
========================================================== */
body[data-theme="glass-dark"] {
    background: var(--bg-dark);
    color: var(--text-dark);
}

body[data-theme="glass-dark"] .logo-text,
body[data-theme="glass-dark"] .navbar-brand .svg-inline--fa {
    color: var(--ff-logo-dark) !important;
}

body[data-theme="glass-dark"] footer {
    background: rgba(25, 25, 25, 0.45) !important;
    color: #e5e5e5 !important;
}

body[data-theme="glass-dark"] footer .text-muted,
body[data-theme="glass-dark"] footer a,
body[data-theme="glass-dark"] footer strong {
    color: #f5f5f5 !important;
}

/* ==========================================================
   HEADER GLASS NAV & DROPDOWNS
========================================================== */
.custom-header {
    width: 100%;
}

.logo-text {
    margin-left: 5px;
}

.glass-nav {
    background: rgba(255, 255, 255, 0.35) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    padding: 8px 0 !important;
    position: relative;
    z-index: 2000 !important;
    transition: background 0.35s ease, border-color 0.35s ease;
}

/* Dark Mode Nav */
body[data-theme="glass-dark"] .glass-nav {
    background: rgba(25, 25, 25, 0.35) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
body[data-theme="glass-dark"] .glass-nav .nav-link {
    color: #f0f0f0 !important;
}

/* Nav Item Badges */
.nav-item .badge {
    font-size: 0.7rem;
    padding: 0.25em 0.4em;
}

/* Dropdown Link Image Alignment */
.nav-item.dropdown .nav-link img {
    vertical-align: middle;
    margin-top: -2px;
}

/* DROPDOWN MENU WITH REAL BLUR */
.glass-nav .dropdown-menu {
    position: relative;
    overflow: hidden !important;
    border-radius: 16px !important;
    background: transparent !important;
    border: none !important;
    padding: 0.35rem 0;
    z-index: 9999 !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Blur Layer */
.glass-nav .dropdown-menu::before {
    content: "";
    position: absolute;
    inset: 0;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.45);
    z-index: -1;
    border-radius: inherit;
}

/* Dropdown Dark Mode */
body[data-theme="glass-dark"] .glass-nav .dropdown-menu::before {
    background: rgba(25, 25, 30, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Dropdown Items */
.glass-nav .dropdown-item {
    color: #1f1f1f !important;
    position: relative;
    z-index: 2;
    transition: background 0.2s;
}
.dropdown-item i {
    width: 18px;
    text-align: center;
}

body[data-theme="glass-dark"] .glass-nav .dropdown-item {
    color: #f1f1f1 !important;
}
body[data-theme="glass-dark"] .glass-nav .dropdown-item:hover {
    background: rgba(255, 255, 255, 0.1) !important;
}

/* Theme Switcher */
body[data-theme="glass-dark"] .dropdown-menu .theme-switcher-label {
    color: #f1f1f1 !important;
}
body[data-theme="glass-dark"] .dropdown-menu .theme-switcher-label i {
    color: #ddd !important;
}

/* ==========================================================
   WIDGETS: SMALL BOXES
========================================================== */
.small-box {
    position: relative;
    display: block;
    border-radius: 16px; /* Updated to match glass theme */
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, .075);
    color: #fff;
    overflow: hidden;
    padding: 1rem;
    transition: transform 0.2s ease-in-out;
    margin-bottom: 20px;
}

.small-box:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.small-box .inner {
    z-index: 1;
    position: relative;
}

.small-box h3 {
    font-size: 2.2rem;
    font-weight: 700;
    margin: 0;
    padding: 0;
    color: #fff;
}

.small-box p {
    font-size: 1rem;
    margin: 0;
    opacity: 0.9;
    color: #fff;
}

.small-box .icon {
    position: absolute;
    top: 0.5rem;
    right: 1rem;
    z-index: 0;
    font-size: 4rem;
    opacity: 0.25;
    pointer-events: none;
    color: #fff; /* Ensure icon is white/transparent */
}

.small-box-footer {
    display: block;
    color: rgba(255, 255, 255, .9);
    text-align: center;
    padding: 0.5rem;
    text-decoration: none;
    font-weight: 500;
    border-top: 1px solid rgba(255, 255, 255, .2);
    margin-top: 0.5rem;
    border-radius: 0 0 16px 16px;
}

.small-box-footer:hover {
    color: #fff;
    background-color: rgba(0, 0, 0, .05);
}

/* Background Colors (Bootstrap Overrides) */
.bg-info { background-color: #0dcaf0 !important; }
.bg-success { background-color: #198754 !important; }
.bg-warning { background-color: #ffc107 !important; color: #212529 !important; }
.bg-danger { background-color: #dc3545 !important; }

/* Responsive Tweaks */
@media (max-width: 767.98px) {
    .small-box .icon {
        font-size: 3rem;
        opacity: 0.2;
    }
    .small-box h3 {
        font-size: 1.8rem;
    }
}

/* Dark Mode Specifics for Widgets */
body[data-theme="glass-dark"] .small-box {
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

/* ==========================================================
   CARDS & GLASS ELEMENTS
========================================================== */
.glass-card,
.stat-card,
.card-glass {
    transition: var(--transition);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-radius: 20px;
    position: relative;
    z-index: 1;
}

/* Light Mode Cards */
body[data-theme="glass-light"] .glass-card,
body[data-theme="glass-light"] .stat-card,
body[data-theme="glass-light"] .card-glass {
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: var(--glass-light-shadow);
    color: var(--text-light);
}

/* Dark Mode Cards */
body[data-theme="glass-dark"] .glass-card,
body[data-theme="glass-dark"] .stat-card,
body[data-theme="glass-dark"] .card-glass {
    backdrop-filter: blur(25px);
    background: var(--glass-dark-bg);
    border: 1px solid var(--glass-dark-border);
    box-shadow: var(--glass-dark-shadow);
    color: var(--text-dark);
}

.glass-card:hover,
.stat-card:hover {
    transform: translateY(-4px);
}

.stat-card { padding: 25px; }

.card-body {
    position: relative;
}
.card-body canvas {
    display: block;
    width: 100% !important;
    max-height: 250px;
}

/* Card Headers */
.card-glass .card-header,
.stat-card .card-header {
    background: transparent;
    border-bottom: 1px solid rgba(255, 255, 255, 0.35);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    padding: 12px 16px;
}

body[data-theme="glass-dark"] .card-glass .card-header,
body[data-theme="glass-dark"] .stat-card .card-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
body[data-theme="glass-dark"] .card-glass .card-header h5 {
    color: #f1f1f1 !important;
}

/* List Groups (Combined Logic) */
.list-group-item {
    background: transparent; /* Important for glass */
    border: none;
    border-bottom: 1px solid rgba(0, 0, 0, .1);
    padding: 0.5rem 0.75rem;
    color: inherit;
}
.list-group-item:last-child {
    border-bottom: none;
}

/* Dark Mode Lists */
body[data-theme="glass-dark"] .list-group-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #f4f4f4 !important;
}
body[data-theme="glass-dark"] .list-group-item strong,
body[data-theme="glass-dark"] .list-group-item span {
    color: #f4f4f4 !important;
}

/* ==========================================================
   BUTTONS & STATUS
========================================================== */
.btn.rounded-circle {
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-group .btn {
    padding: 0.25rem 0.4rem;
}

.status-circle {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

/* Soft Button */
.btn-soft {
    border-radius: 10px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.5);
    border: none;
    transition: 0.2s;
}
.btn-soft:hover {
    background: rgba(255, 255, 255, 0.8);
}
body[data-theme="glass-dark"] .btn-soft {
    background: rgba(40, 40, 40, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #ddd !important;
}

/* Navbar Button */
.btn-softglass {
    border-radius: 10px;
}
body[data-theme="glass-dark"] .btn-softglass {
    background: rgba(40, 40, 40, 0.55) !important;
    color: #f0f0f0 !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
}
body[data-theme="glass-dark"] .btn-softglass:hover {
    background: rgba(55, 55, 55, 0.65) !important;
}

/* Add Exam Button */
.btn-add-exam {
    border-radius: 12px;
    font-weight: 600;
    transition: 0.25s;
}
body[data-theme="glass-light"] .btn-add-exam {
    background: rgba(13, 110, 253, 0.15);
    border: 1px solid rgba(13, 110, 253, 0.35);
    color: #0d6efd;
}
body[data-theme="glass-dark"] .btn-add-exam {
    background: rgba(13, 110, 253, 0.20);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #82baff;
}

/* Filter Buttons */
.glass-reset-btn {
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(0, 0, 0, 0.15);
}
body[data-theme="glass-dark"] .glass-reset-btn {
    background: rgba(40, 40, 40, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #e5e5e5;
}
.glass-apply-btn {
    border-radius: 12px;
    background: #0d6efd;
    color: white;
}
.btn-filter-apply-active {
    background: #0d6efd !important;
    color: white !important;
    box-shadow: 0 0 12px rgba(13, 110, 253, 0.6);
}

/* ==========================================================
   FORMS & INPUTS
========================================================== */
.glass-input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.glass-label {
    font-size: 0.85rem;
    font-weight: 600;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 4px;
}
body[data-theme="glass-dark"] .glass-label {
    color: #e5e5e5;
    opacity: 0.9;
}

.glass-input,
.glass-select,
.form-control,
.form-select {
    width: 100%;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    font-size: 0.9rem;
    transition: all 0.25s ease;
    color: #1f1f1f;
}

/* Dark Inputs */
body[data-theme="glass-dark"] .glass-input,
body[data-theme="glass-dark"] .glass-select,
body[data-theme="glass-dark"] .form-control,
body[data-theme="glass-dark"] .form-select {
    background: rgba(30, 30, 30, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #e5e5e5;
}

/* Focus States */
.glass-input:focus, .glass-select:focus,
.form-control:focus, .form-select:focus {
    border-color: rgba(13, 110, 253, 0.5);
    background: rgba(255, 255, 255, 0.85);
    outline: none;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}
body[data-theme="glass-dark"] .glass-input:focus,
body[data-theme="glass-dark"] .glass-select:focus {
    background: rgba(40, 40, 40, 0.75);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Select Icons */
.glass-select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF8,%3Csvg fill='%23666' height='20' viewBox='0 0 20 20' width='20' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5.516 7.548a.75.75 0 0 1 1.06-.032L10 10.698l3.424-3.182a.75.75 0 0 1 1.028 1.092l-3.93 3.65a.75.75 0 0 1-1.028 0l-3.93-3.65a.75.75 0 0 1-.032-1.06Z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    padding-right: 40px;
}
body[data-theme="glass-dark"] .glass-select {
    background-image: url("data:image/svg+xml;charset=UTF8,%3Csvg fill='%23ccc' height='20' viewBox='0 0 20 20' width='20' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5.516 7.548a.75.75 0 0 1 1.06-.032L10 10.698l3.424-3.182a.75.75 0 0 1 1.028 1.092l-3.93 3.65a.75.75 0 0 1-1.028 0l-3.93-3.65a.75.75 0 0 1-.032-1.06Z'/%3E%3C/svg%3E");
}

/* ==========================================================
   TABLES
========================================================== */
.table {
    border-collapse: separate;
    border-spacing: 0 6px;
}

.table thead th {
    background: transparent !important;
    font-weight: 700;
    padding: 14px 12px;
    border: none !important;
    color: #1f1f1f;
}
body[data-theme="glass-dark"] .table thead th {
    color: #ffffff !important;
}

.sortable { cursor: pointer; }
.sortable::after {
    content: " \21C5";
    font-size: 0.7rem;
    opacity: 0.5;
    margin-left: 4px;
}

/* Table Rows */
.table tbody tr {
    display: table-row !important;
    background: rgba(255, 255, 255, 0.55) !important;
    backdrop-filter: blur(10px) !important;
    border-radius: 12px;
    transition: background 0.2s;
}
body[data-theme="glass-dark"] .table tbody tr {
    background: rgba(20, 20, 20, 0.75) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.table-hover tbody tr:hover {
    background: rgba(255, 255, 255, 0.85) !important;
}
body[data-theme="glass-dark"] .table-hover tbody tr:hover {
    background: rgba(40, 40, 40, 0.95) !important;
}

/* Cells */
.table tbody td {
    border: none !important;
    padding: 14px 12px;
    color: #1f1f1f;
    vertical-align: middle !important;
}
body[data-theme="glass-dark"] .table tbody td {
    color: #f6f6f6 !important;
}

/* Badges inside Tables */
.table .badge {
    padding: 6px 10px;
    font-size: 0.75rem;
    border-radius: 8px;
}
body[data-theme="glass-light"] .badge.bg-primary {
    background-color: rgba(13, 110, 253, 0.15) !important;
    color: #0d6efd !important;
}
body[data-theme="glass-dark"] .badge.bg-primary {
    background-color: rgba(70, 130, 255, 0.25) !important;
    color: #bcd4ff !important;
}

/* ==========================================================
   FILTER & MULTISELECT UTILS
========================================================== */
.filter-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: transparent;
    backdrop-filter: blur(10px);
    padding: 10px 0;
}

.btn-dropdown-multi {
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    padding: 6px 10px;
    text-align: left;
    width: 100%;
}
body[data-theme="glass-dark"] .btn-dropdown-multi {
    background: rgba(25, 25, 25, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #e5e5e5;
}

.dropdown-multi {
    max-height: 240px;
    overflow-y: auto;
    border-radius: 14px;
}
body[data-theme="glass-dark"] .dropdown-multi {
    background: rgba(25, 25, 25, 0.95) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
}

.filter-active {
    border-color: #0d6efd !important;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.25);
}
body[data-theme="glass-dark"] .filter-active {
    box-shadow: 0 0 0 3px rgba(100, 150, 255, 0.35);
}

/* ==========================================================
   PANELS & FOOTER
========================================================== */
.footer {
    font-size: 0.85rem;
    z-index: 100;
}

#examStatusPanel {
    backdrop-filter: blur(18px);
    background: rgba(255, 255, 255, 0.60);
    border-radius: 16px;
    transition: all 0.35s ease;
}

/* Specific list items in Exam Panel */
#examStatusPanel .list-group-item {
    border: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding: 0.4rem 0.5rem;
}
#examStatusPanel .list-group-item:last-child {
    border-bottom: none;
}

#examStatusBtn {
    width: 24px;
    height: 24px;
}

/* Dark Mode Exam Panel */
body[data-theme="glass-dark"] #examStatusPanel {
    background: rgba(25, 25, 25, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.10);
    color: #f0f0f0;
}
body[data-theme="glass-dark"] #examStatusPanel .list-group-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}