/* ===== ROOT VARIABLES ===== */
:root {
    --sidebar-width: 250px;
    --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;

    /* Feature accent colors */
    --color-kelas: #6366f1;
    --color-kelas-bg: #eef2ff;
    --color-kelas-light: #a5b4fc;

    --color-absensi: #0d9488;
    --color-absensi-bg: #f0fdfa;
    --color-absensi-light: #5eead4;

    --color-tugas: #f59e0b;
    --color-tugas-bg: #fffbeb;
    --color-tugas-light: #fcd34d;

    --color-assessment: #e11d48;
    --color-assessment-bg: #fff1f2;
    --color-assessment-light: #fb7185;

    --color-peserta: #2563eb;
    --color-peserta-bg: #eff6ff;
    --color-peserta-light: #93c5fd;

    --color-jadwal: #64748b;
    --color-jadwal-bg: #f8fafc;
    --color-jadwal-light: #94a3b8;

    --color-sertifikat: #10b981;
    --color-sertifikat-bg: #ecfdf5;
    --color-sertifikat-light: #6ee7b7;

    --color-laporan: #8b5cf6;
    --color-laporan-bg: #f5f3ff;
    --color-laporan-light: #c4b5fd;
}

/* ===== BASE ===== */
body {
    font-family: var(--font-sans);
    background-color: #f8f9fc;
}

/* Override Bootstrap primary to darker blue */
:root {
    --bs-primary: #1e40af;
    --bs-primary-rgb: 30, 64, 175;
    --bs-primary-bg-subtle: #dbeafe;
    --bs-primary-border-subtle: #93c5fd;
    --bs-link-color: #1e40af;
    --bs-link-hover-color: #1e3a8a;
}
.btn-primary {
    --bs-btn-bg: #1e40af;
    --bs-btn-border-color: #1e40af;
    --bs-btn-hover-bg: #1e3a8a;
    --bs-btn-hover-border-color: #1e3a8a;
    --bs-btn-active-bg: #172554;
    --bs-btn-active-border-color: #172554;
}
.btn-outline-primary {
    --bs-btn-color: #1e40af;
    --bs-btn-border-color: #1e40af;
    --bs-btn-hover-bg: #1e40af;
    --bs-btn-hover-border-color: #1e40af;
    --bs-btn-active-bg: #1e3a8a;
}
.text-primary { color: #1e40af !important; }
.bg-primary { background-color: #1e40af !important; }
.border-primary { border-color: #1e40af !important; }

.navbar-brand {
    font-size: 1.25rem;
    letter-spacing: -0.5px;
}

/* ===== CARDS ===== */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: box-shadow 0.2s, transform 0.15s;
}

.card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

/* ===== FEATURE-SPECIFIC TABLE THEMES ===== */

/* --- KELAS (Indigo) : Ganjil-Genap --- */
.table-kelas > thead {
    background: linear-gradient(135deg, #6366f1, #818cf8) !important;
}
.table-kelas > thead th {
    color: #fff !important;
    border-bottom: none !important;
}
.table-kelas > tbody > tr.odd > *,
.table-kelas > tbody > tr:nth-child(odd) > * {
    background-color: #eef2ff !important;
}
.table-kelas > tbody > tr.even > *,
.table-kelas > tbody > tr:nth-child(even) > * {
    background-color: #ffffff !important;
}
.table-kelas > tbody > tr:hover > *,
.table-kelas > tbody > tr.odd:hover > * {
    background-color: #dde4ff !important;
}
.table-kelas .badge-kelas-draft { background-color: #c7d2fe; color: #3730a3; }
.table-kelas .badge-kelas-aktif { background-color: #a7f3d0; color: #065f46; }
.table-kelas .badge-kelas-selesai { background-color: #bfdbfe; color: #1e40af; }
.table-kelas .badge-kelas-diarsipkan { background-color: #e2e8f0; color: #475569; }

/* --- ABSENSI (Teal) : Ganjil-Genap --- */
.table-absensi > thead {
    background: linear-gradient(135deg, #0d9488, #14b8a6) !important;
}
.table-absensi > thead th {
    color: #fff !important;
    border-bottom: none !important;
}
.table-absensi > tbody > tr.odd > *,
.table-absensi > tbody > tr:nth-child(odd) > * {
    background-color: #f0fdfa !important;
}
.table-absensi > tbody > tr.even > *,
.table-absensi > tbody > tr:nth-child(even) > * {
    background-color: #ffffff !important;
}
.table-absensi > tbody > tr:hover > *,
.table-absensi > tbody > tr.odd:hover > * {
    background-color: #ccfbf1 !important;
}
.table-absensi .badge-hadir { background-color: #a7f3d0; color: #065f46; }
.table-absensi .badge-izin { background-color: #fde68a; color: #92400e; }
.table-absensi .badge-alfa { background-color: #fecaca; color: #991b1b; }

/* --- TUGAS (Amber) : Ganjil-Genap --- */
.table-tugas > thead {
    background: linear-gradient(135deg, #d97706, #f59e0b) !important;
}
.table-tugas > thead th {
    color: #fff !important;
    border-bottom: none !important;
}
.table-tugas > tbody > tr.odd > *,
.table-tugas > tbody > tr:nth-child(odd) > * {
    background-color: #fffbeb !important;
}
.table-tugas > tbody > tr.even > *,
.table-tugas > tbody > tr:nth-child(even) > * {
    background-color: #ffffff !important;
}
.table-tugas > tbody > tr:hover > *,
.table-tugas > tbody > tr.odd:hover > * {
    background-color: #fef3c7 !important;
}
.table-tugas .badge-tugas-belum { background-color: #e2e8f0; color: #475569; }
.table-tugas .badge-tugas-upload { background-color: #fde68a; color: #92400e; }
.table-tugas .badge-tugas-nilai { background-color: #a7f3d0; color: #065f46; }
.table-tugas .badge-tugas-terlambat { background-color: #fecaca; color: #991b1b; }

/* --- ASSESSMENT (Rose) : Ganjil-Genap --- */
.table-assessment > thead {
    background: linear-gradient(135deg, #e11d48, #f43f5e) !important;
}
.table-assessment > thead th {
    color: #fff !important;
    border-bottom: none !important;
}
.table-assessment > tbody > tr.odd > *,
.table-assessment > tbody > tr:nth-child(odd) > * {
    background-color: #fff1f2 !important;
}
.table-assessment > tbody > tr.even > *,
.table-assessment > tbody > tr:nth-child(even) > * {
    background-color: #ffffff !important;
}
.table-assessment > tbody > tr:hover > *,
.table-assessment > tbody > tr.odd:hover > * {
    background-color: #ffe4e6 !important;
}
.table-assessment .badge-metode-online { background-color: #bfdbfe; color: #1e40af; }
.table-assessment .badge-metode-presentasi { background-color: #fde68a; color: #92400e; }
.table-assessment .badge-metode-wawancara { background-color: #c7d2fe; color: #3730a3; }
.table-assessment .badge-metode-project { background-color: #a7f3d0; color: #065f46; }

/* --- PESERTA (Blue) : Ganjil-Genap --- */
.table-peserta > thead {
    background: linear-gradient(135deg, #2563eb, #3b82f6) !important;
}
.table-peserta > thead th {
    color: #fff !important;
    border-bottom: none !important;
}
.table-peserta > tbody > tr.odd > *,
.table-peserta > tbody > tr:nth-child(odd) > * {
    background-color: #eff6ff !important;
}
.table-peserta > tbody > tr.even > *,
.table-peserta > tbody > tr:nth-child(even) > * {
    background-color: #ffffff !important;
}
.table-peserta > tbody > tr:hover > *,
.table-peserta > tbody > tr.odd:hover > * {
    background-color: #dbeafe !important;
}
.table-peserta .badge-bayar-lunas { background-color: #a7f3d0; color: #065f46; }
.table-peserta .badge-bayar-belum { background-color: #fde68a; color: #92400e; }
.table-peserta .badge-bayar-gratis { background-color: #bfdbfe; color: #1e40af; }

/* --- JADWAL (Slate) : Ganjil-Genap --- */
.table-jadwal > thead {
    background: linear-gradient(135deg, #475569, #64748b) !important;
}
.table-jadwal > thead th {
    color: #fff !important;
    border-bottom: none !important;
}
.table-jadwal > tbody > tr.odd > *,
.table-jadwal > tbody > tr:nth-child(odd) > * {
    background-color: #f8fafc !important;
}
.table-jadwal > tbody > tr.even > *,
.table-jadwal > tbody > tr:nth-child(even) > * {
    background-color: #ffffff !important;
}
.table-jadwal > tbody > tr:hover > *,
.table-jadwal > tbody > tr.odd:hover > * {
    background-color: #e2e8f0 !important;
}

/* --- SERTIFIKAT (Emerald) : Ganjil-Genap --- */
.table-sertifikat > thead {
    background: linear-gradient(135deg, #059669, #10b981) !important;
}
.table-sertifikat > thead th {
    color: #fff !important;
    border-bottom: none !important;
}
.table-sertifikat > tbody > tr.odd > *,
.table-sertifikat > tbody > tr:nth-child(odd) > * {
    background-color: #ecfdf5 !important;
}
.table-sertifikat > tbody > tr.even > *,
.table-sertifikat > tbody > tr:nth-child(even) > * {
    background-color: #ffffff !important;
}
.table-sertifikat > tbody > tr:hover > *,
.table-sertifikat > tbody > tr.odd:hover > * {
    background-color: #d1fae5 !important;
}

/* --- LAPORAN (Violet) : Ganjil-Genap --- */
.table-laporan > thead {
    background: linear-gradient(135deg, #7c3aed, #8b5cf6) !important;
}
.table-laporan > thead th {
    color: #fff !important;
    border-bottom: none !important;
}
.table-laporan > tbody > tr.odd > *,
.table-laporan > tbody > tr:nth-child(odd) > * {
    background-color: #f5f3ff !important;
}
.table-laporan > tbody > tr.even > *,
.table-laporan > tbody > tr:nth-child(even) > * {
    background-color: #ffffff !important;
}
.table-laporan > tbody > tr:hover > *,
.table-laporan > tbody > tr.odd:hover > * {
    background-color: #ede9fe !important;
}

/* ===== GENERIC TABLE BASE ===== */
.table {
    margin-bottom: 0;
}
.table > thead th {
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.85rem 0.75rem;
    border-bottom: 2px solid #e9ecef;
    color: #495057;
    white-space: nowrap;
}
.table > tbody td {
    padding: 0.7rem 0.75rem;
    vertical-align: middle;
    font-size: 0.9rem;
}
.table tbody tr {
    transition: background-color 0.12s;
}
.table-striped > tbody > tr:nth-of-type(odd) {
    background-color: rgba(0,0,0,0.015);
}

/* Card header accent bar per feature */
.card-header-accent-kelas { border-left: 4px solid var(--color-kelas); }
.card-header-accent-absensi { border-left: 4px solid var(--color-absensi); }
.card-header-accent-tugas { border-left: 4px solid var(--color-tugas); }
.card-header-accent-assessment { border-left: 4px solid var(--color-assessment); }
.card-header-accent-peserta { border-left: 4px solid var(--color-peserta); }
.card-header-accent-jadwal { border-left: 4px solid var(--color-jadwal); }
.card-header-accent-sertifikat { border-left: 4px solid var(--color-sertifikat); }
.card-header-accent-laporan { border-left: 4px solid var(--color-laporan); }

/* ===== BADGES ===== */
.badge {
    padding: 0.4em 0.7em;
    font-weight: 500;
    border-radius: 6px;
}

/* ===== BUTTONS ===== */
.btn {
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-weight: 500;
    transition: all 0.15s;
}
.btn-sm {
    border-radius: 6px;
    padding: 0.3rem 0.65rem;
    font-size: 0.82rem;
}
.btn-group-sm > .btn {
    border-radius: 4px;
}

/* ===== FORMS ===== */
.form-control, .form-select {
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    border: 1px solid #dee2e6;
    font-size: 0.9rem;
}
.form-control:focus, .form-select:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.2rem rgba(13,110,253,0.15);
}

/* ===== ALERTS ===== */
.alert {
    border: none;
    border-radius: 10px;
}

/* ===== MODALS ===== */
.modal-header {
    background-color: #f8f9fc;
    border-radius: 12px 12px 0 0;
}

/* ===== LOGIN ===== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a8a 0%, #312e81 100%);
}
.login-card {
    width: 100%;
    max-width: 420px;
    border: none;
    border-radius: 16px;
}
.login-card .card-body {
    padding: 2.5rem;
}
.login-logo {
    font-size: 2.5rem;
    color: #1e40af;
}

/* ===== FOOTER ===== */
.footer {
    font-size: 0.85rem;
    color: #6c757d;
    text-align: center;
    padding: 1rem 0;
}

/* ===== PROGRESS BARS ===== */
.progress {
    border-radius: 99px;
    background-color: #e9ecef;
}
.progress-bar {
    border-radius: 99px;
}

/* ===== DATA TABLE WRAPPER ===== */
.dataTables_wrapper .dataTables_filter input {
    border-radius: 8px;
    border: 1px solid #dee2e6;
    padding: 0.3rem 0.6rem;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 6px !important;
}

/* ===== RESPONSIVE ===== */

/* Tablet landscape / small desktop (max 992px) */
@media (max-width: 992px) {
    .container-fluid {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
    .card {
        border-radius: 10px;
    }
    .card-body {
        padding: 1rem;
    }
    .table > thead th {
        font-size: 0.72rem;
        padding: 0.65rem 0.5rem;
    }
    .table > tbody td {
        font-size: 0.82rem;
        padding: 0.55rem 0.5rem;
    }
}

/* Tablet portrait (max 768px) */
@media (max-width: 768px) {
    .container-fluid {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
    .row.g-3 > [class*="col-"] {
        margin-bottom: 0.5rem;
    }
    .stat-card .stat-value {
        font-size: 1.4rem;
    }
    .stat-card .stat-label {
        font-size: 0.78rem;
    }
    .card {
        border-radius: 8px;
    }
    .card-header {
        padding: 0.75rem 1rem;
    }
    .card-body {
        padding: 0.85rem;
    }
    .table > thead th {
        font-size: 0.68rem;
        padding: 0.55rem 0.4rem;
        white-space: nowrap;
    }
    .table > tbody td {
        font-size: 0.78rem;
        padding: 0.45rem 0.4rem;
    }
    .btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.85rem;
    }
    .btn-sm {
        padding: 0.2rem 0.5rem;
        font-size: 0.75rem;
    }
    .btn-group {
        flex-wrap: wrap;
        gap: 2px;
    }
    .btn-group .btn {
        border-radius: 6px !important;
        margin: 1px;
    }
    .btn-group-sm > .btn {
        border-radius: 4px !important;
    }
    .form-control, .form-select {
        font-size: 0.85rem;
        padding: 0.4rem 0.6rem;
    }
    h4.fw-bold {
        font-size: 1.15rem;
    }
    h5.fw-bold {
        font-size: 1rem;
    }
    .badge {
        font-size: 0.7rem;
        padding: 0.25em 0.5em;
    }
    .progress {
        height: 6px !important;
    }

    /* Make table action columns stack vertically on mobile */
    .table td:last-child .btn-group,
    .table td:last-child .d-inline {
        display: flex;
        flex-wrap: wrap;
        gap: 3px;
    }
    .table td:last-child .btn-group .btn {
        flex: 1 1 auto;
        min-width: 32px;
        text-align: center;
    }

    /* Page header: stack title and buttons */
    .d-flex.justify-content-between.align-items-center.mb-3 {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.5rem;
    }
    .d-flex.justify-content-between.align-items-center.mb-3 > div:last-child,
    .d-flex.justify-content-between.align-items-center.mb-3 > a:last-child {
        align-self: stretch;
    }
    .d-flex.justify-content-between.align-items-center.mb-3 > div:last-child .btn,
    .d-flex.justify-content-between.align-items-center.mb-3 > a:last-child {
        width: 100%;
    }

    /* Dashboard stat cards: 2 columns on tablet */
    .dashboard-stats .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Navbar adjustments */
    .navbar-brand {
        font-size: 1rem;
    }
    .navbar .dropdown-menu {
        border-radius: 0 0 8px 8px;
    }

    /* Table wrapper for horizontal scroll */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Hide DataTables search and length on very narrow */
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        float: none !important;
        text-align: left !important;
        margin-bottom: 0.5rem;
    }
    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* Phone (max 576px) */
@media (max-width: 576px) {
    .container-fluid {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }
    .row {
        margin-left: -4px;
        margin-right: -4px;
    }
    .row > [class*="col-"] {
        padding-left: 4px;
        padding-right: 4px;
    }

    /* Dashboard stats: full width */
    .dashboard-stats .col-md-3 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .card {
        border-radius: 6px;
        box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    }
    .card-header {
        padding: 0.6rem 0.75rem;
    }
    .card-body {
        padding: 0.65rem;
    }

    .table > thead th {
        font-size: 0.62rem;
        padding: 0.45rem 0.3rem;
        letter-spacing: 0.3px;
    }
    .table > tbody td {
        font-size: 0.72rem;
        padding: 0.4rem 0.3rem;
    }

    .btn {
        padding: 0.35rem 0.6rem;
        font-size: 0.78rem;
        border-radius: 6px;
    }
    .btn-sm {
        padding: 0.15rem 0.4rem;
        font-size: 0.68rem;
        border-radius: 4px;
    }

    h4.fw-bold {
        font-size: 1rem;
    }
    h5.fw-bold {
        font-size: 0.9rem;
    }
    h6.fw-bold {
        font-size: 0.82rem;
    }

    .form-control, .form-select {
        font-size: 0.8rem;
        padding: 0.35rem 0.5rem;
        border-radius: 6px;
    }

    .badge {
        font-size: 0.62rem;
        padding: 0.2em 0.4em;
    }

    /* Login page mobile */
    .login-card .card-body {
        padding: 1.5rem !important;
    }
    .login-logo {
        font-size: 2rem;
    }
    .login-card {
        max-width: 100%;
        margin: 0 10px;
    }
    .login-container {
        padding: 10px;
    }

    /* Footer mobile */
    .footer {
        font-size: 0.75rem;
        padding: 0.75rem 0;
    }

    /* Progress bars smaller on phone */
    .progress {
        height: 5px !important;
    }

    /* Tab navigation in detail page: scrollable */
    .nav-tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .nav-tabs::-webkit-scrollbar {
        display: none;
    }
    .nav-tabs .nav-item {
        flex: 0 0 auto;
    }

    /* Force DataTables pagination to wrap on phone */
    .dataTables_wrapper .dataTables_paginate {
        float: none !important;
        text-align: center !important;
        padding-top: 0.5rem;
    }
    .dataTables_wrapper .dataTables_paginate .paginate_button {
        padding: 0.2rem 0.5rem !important;
        font-size: 0.75rem;
        margin: 1px;
    }

    /* Alert mobile */
    .alert {
        font-size: 0.82rem;
        padding: 0.5rem 0.75rem;
        border-radius: 6px;
    }

    /* Modal mobile */
    .modal-header {
        padding: 0.75rem 1rem;
    }
    .modal-body {
        padding: 0.75rem;
    }
    .modal-footer {
        padding: 0.5rem 0.75rem;
    }

    /* Dropdown menu on mobile */
    .dropdown-menu {
        padding: 0.25rem 0;
        font-size: 0.85rem;
    }
    .dropdown-item {
        padding: 0.4rem 0.75rem;
    }
}
