/* ============================================================
   DPDM Jawa Tengah - Main Stylesheet
   Tema: Full White — Navbar & Sidebar putih, tabel header abu
   ============================================================ */

:root {
    --primary:          #1565C0;
    --primary-dark:     #0D47A1;
    --primary-light:    #1976D2;
    --sidebar-width:    260px;
    --navbar-height:    60px;

    /* Navbar — putih */
    --navbar-bg:        #ffffff;
    --navbar-border:    #e5e7eb;
    --navbar-text:      #374151;
    --navbar-text-muted:#6b7280;
    --navbar-hover-bg:  #f3f4f6;
    --navbar-brand-color:#1565C0;

    /* Sidebar — putih */
    --sidebar-bg:       #ffffff;
    --sidebar-border:   #e5e7eb;
    --sidebar-text:     #374151;
    --sidebar-muted:    #9ca3af;
    --sidebar-hover:    #f0f7ff;
    --sidebar-active-bg:#e8f0fe;
    --sidebar-active-text:#1565C0;
    --sidebar-active-border:#1565C0;
    --sidebar-icon:     #6b7280;
    --sidebar-active-icon:#1565C0;

    /* Body & card */
    --body-bg:          #f3f4f6;
    --card-bg:          #ffffff;
    --border-color:     #e5e7eb;
    --text-muted:       #6b7280;
    --footer-bg:        #ffffff;
    --page-header-bg:   #ffffff;

    /* Tabel header — abu */
    --table-head-bg:    #f1f3f5;
    --table-head-color: #374151;
    --table-head-border:#dee2e6;

    --transition:       all 0.22s ease;
}

[data-bs-theme="dark"] {
    --navbar-bg:        #1a1d27;
    --navbar-border:    #2d3142;
    --navbar-text:      #e0e0e0;
    --navbar-text-muted:#8b92a5;
    --navbar-hover-bg:  rgba(255,255,255,0.07);
    --navbar-brand-color:#90CAF9;

    --sidebar-bg:       #141720;
    --sidebar-border:   #2d3142;
    --sidebar-text:     #d1d5db;
    --sidebar-muted:    #6b7280;
    --sidebar-hover:    rgba(255,255,255,0.06);
    --sidebar-active-bg:rgba(21,101,192,0.2);
    --sidebar-active-text:#90CAF9;
    --sidebar-active-border:#1565C0;
    --sidebar-icon:     #9ca3af;
    --sidebar-active-icon:#90CAF9;

    --body-bg:          #0f1117;
    --card-bg:          #1a1d27;
    --border-color:     #2d3142;
    --text-muted:       #8b92a5;
    --footer-bg:        #141720;
    --page-header-bg:   #141720;

    --table-head-bg:    #252836;
    --table-head-color: #d1d5db;
    --table-head-border:#3d4155;
}

/* ============================================================
   BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--body-bg);
    color: var(--bs-body-color);
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

html,
body {
    max-width: 100%;
}

/* ============================================================
   NAVBAR — putih dengan shadow tipis
   ============================================================ */
#mainNavbar {
    height: var(--navbar-height);
    background: var(--navbar-bg);
    border-bottom: 1px solid var(--navbar-border);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    z-index: 1050;
    padding: 0 1rem;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}
#mainNavbar .container-fluid,
#mainNavbar .navbar-brand,
#mainNavbar .ms-auto {
    min-width: 0;
}

#mainNavbar .navbar-brand {
    color: var(--navbar-brand-color) !important;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    text-decoration: none;
}
#mainNavbar .navbar-brand i {
    color: var(--primary);
}

/* Sidebar toggle button */
.sidebar-toggle {
    color: var(--navbar-text) !important;
    padding: 0.4rem;
    border-radius: 6px;
    transition: var(--transition);
    text-decoration: none;
    background: transparent;
    border: none;
}
.sidebar-toggle:hover {
    background: var(--navbar-hover-bg);
    color: var(--primary) !important;
}

/* Dark mode icon button */
.nav-icon-btn {
    color: var(--navbar-text) !important;
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    transition: var(--transition);
    text-decoration: none;
    font-size: 1.05rem;
    background: transparent;
    border: none;
}
.nav-icon-btn:hover {
    background: var(--navbar-hover-bg);
    color: var(--primary) !important;
}

/* Tapel badge */
#mainNavbar .badge {
    font-size: 0.75rem;
}

/* User dropdown button */
.nav-user-btn {
    color: var(--navbar-text) !important;
    text-decoration: none;
    padding: 0.3rem 0.6rem;
    border-radius: 8px;
    transition: var(--transition);
    background: transparent;
    border: none;
}
.nav-user-btn:hover {
    background: var(--navbar-hover-bg);
}
.nav-user-btn::after { display: none; }

.user-avatar i {
    color: var(--primary);
    font-size: 1.6rem !important;
}

.user-name {
    font-size: 0.84rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--navbar-text);
}
.user-madrasah {
    font-size: 0.71rem;
    color: var(--navbar-text-muted);
    line-height: 1.2;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Dropdown menu */
.dropdown-menu {
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    border-radius: 10px;
    padding: 0.4rem 0;
}
.dropdown-header {
    padding: 0.6rem 1rem;
    font-size: 0.82rem;
}
.dropdown-item {
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
    color: var(--navbar-text);
    transition: background 0.15s ease;
}
.dropdown-item:hover {
    background: var(--navbar-hover-bg);
    color: var(--primary);
}
.dropdown-item.text-danger:hover {
    background: #fff5f5;
    color: #dc2626 !important;
}

/* ============================================================
   WRAPPER & LAYOUT
   ============================================================ */
.wrapper {
    display: flex;
    min-height: 100vh;
    padding-top: var(--navbar-height);
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

/* ============================================================
   SIDEBAR — putih dengan border kanan
   ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    min-height: calc(100vh - var(--navbar-height));
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    z-index: 1040;
    transition: transform 0.28s ease, width 0.28s ease,
                background-color 0.3s ease, border-color 0.3s ease;
    overflow: hidden;
    box-shadow: 2px 0 8px rgba(0,0,0,0.04);
}

.sidebar.collapsed {
    width: 0;
    transform: translateX(-100%);
}

.sidebar-inner {
    width: var(--sidebar-width);
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Scrollbar sidebar */
.sidebar-inner::-webkit-scrollbar { width: 3px; }
.sidebar-inner::-webkit-scrollbar-track { background: transparent; }
.sidebar-inner::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

/* Sidebar header */
.sidebar-header {
    padding: 1rem 1.2rem 0.9rem;
    border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--primary);
    text-decoration: none;
}
.sidebar-logo i {
    font-size: 1.35rem;
    color: var(--primary);
}

/* Section label */
.sidebar-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sidebar-muted);
    padding: 0.9rem 1.2rem 0.3rem;
}

/* Menu list */
.sidebar-menu {
    list-style: none;
    padding: 0.5rem 0.6rem;
    margin: 0;
    flex: 1;
}

.sidebar-item {
    margin: 1px 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.85rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    transition: var(--transition);
    font-size: 0.855rem;
    font-weight: 500;
    white-space: nowrap;
    border-left: 3px solid transparent;
}
.sidebar-link i {
    font-size: 1rem;
    min-width: 18px;
    color: var(--sidebar-icon);
    transition: color 0.2s ease;
}
.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: var(--primary);
    border-left-color: transparent;
}
.sidebar-link:hover i {
    color: var(--primary);
}

/* Active state */
.sidebar-item.active > .sidebar-link {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    font-weight: 600;
    /* border-left-color: var(--sidebar-active-border)x; */
}
.sidebar-item.active > .sidebar-link i {
    color: var(--sidebar-active-icon);
}

/* Submenu */
.submenu {
    list-style: none;
    padding: 0.15rem 0 0.15rem 0.5rem;
    margin: 0;
}
.submenu li {
    margin: 1px 0;
}
.submenu li a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.85rem 0.5rem 1.1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 7px;
    font-size: 0.82rem;
    transition: var(--transition);
    border-left: 2px solid transparent;
}
.submenu li a i {
    font-size: 0.85rem;
    min-width: 16px;
    color: var(--sidebar-icon);
}
.submenu li a:hover {
    background: var(--sidebar-hover);
    color: var(--primary);
}
.submenu li a:hover i { color: var(--primary); }
.submenu li.active a {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    font-weight: 600;
    /* border-left-color: var(--sidebar-active-border); */
}
.submenu li.active a i { color: var(--sidebar-active-icon); }

/* Chevron arrow */
.submenu-arrow {
    font-size: 0.68rem !important;
    transition: transform 0.22s ease;
    color: var(--sidebar-muted) !important;
}
.sidebar-link[aria-expanded="true"] .submenu-arrow {
    transform: rotate(180deg);
}

/* Sidebar footer */
.sidebar-footer {
    padding: 0.75rem 1.2rem;
    border-top: 1px solid var(--sidebar-border);
    font-size: 0.74rem;
    color: var(--sidebar-muted);
}

/* Overlay mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.45);
    z-index: 1039;
}
.sidebar-overlay.show { display: block; }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    flex: 1;
    min-width: 0;
    width: calc(100% - var(--sidebar-width));
    max-width: calc(100% - var(--sidebar-width));
    margin-left: var(--sidebar-width);
    min-height: calc(100vh - var(--navbar-height));
    display: flex;
    flex-direction: column;
    transition: margin-left 0.28s ease;
    background: var(--body-bg);
    overflow-x: hidden;
}
.main-content.expanded {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
}

/* Page Header */
.page-header {
    background: var(--page-header-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 0.85rem 1.5rem;
    transition: background-color 0.3s ease;
    min-width: 0;
}
.page-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary);
}
.breadcrumb { font-size: 0.77rem; }
.breadcrumb,
.page-title {
    min-width: 0;
    overflow-wrap: anywhere;
}
.breadcrumb-item a {
    color: var(--primary);
    text-decoration: none;
}
.breadcrumb-item a:hover { text-decoration: underline; }

/* Content Area */
.content-area {
    padding: 1.25rem 1.5rem;
    flex: 1;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}
.content-area > * {
    max-width: 100%;
}
.content-area .row {
    max-width: 100%;
}
.content-area .row > * {
    min-width: 0;
}
.content-area .d-flex {
    min-width: 0;
}

/* ============================================================
   FOOTER
   ============================================================ */
.main-footer {
    background: var(--footer-bg);
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    font-size: 0.82rem;
    transition: background-color 0.3s ease;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: background-color 0.3s ease, border-color 0.3s ease;
    min-width: 0;
    max-width: 100%;
}
.card-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 0.85rem 1.25rem;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 10px 10px 0 0 !important;
}

/* Stat Cards */
.stat-card {
    border-radius: 10px;
    padding: 1.2rem;
    color: #fff;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.14);
}
.stat-card .stat-icon {
    font-size: 2.5rem;
    opacity: 0.18;
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
}
.stat-card .stat-value {
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1;
}
.stat-card .stat-label {
    font-size: 0.8rem;
    opacity: 0.9;
    margin-top: 0.3rem;
}

.bg-stat-1 { background: linear-gradient(135deg, #1565C0, #1E88E5); }
.bg-stat-2 { background: linear-gradient(135deg, #00695C, #00897B); }
.bg-stat-3 { background: linear-gradient(135deg, #E65100, #F57C00); }
.bg-stat-4 { background: linear-gradient(135deg, #4A148C, #7B1FA2); }
.bg-stat-5 { background: linear-gradient(135deg, #880E4F, #C2185B); }
.bg-stat-6 { background: linear-gradient(135deg, #1B5E20, #388E3C); }

/* ============================================================
   TABLES — header abu-abu
   ============================================================ */
.table-responsive {
    border-radius: 6px;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}
.table { margin-bottom: 0; }
.table code,
.table .badge {
    white-space: normal;
    overflow-wrap: anywhere;
}

.table thead th {
    background: var(--table-head-bg);
    color: var(--table-head-color);
    font-weight: 600;
    font-size: 0.79rem;
    border-bottom: 2px solid var(--table-head-border);
    border-top: none;
    white-space: nowrap;
    padding: 0.65rem 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.table tbody tr { transition: background-color 0.12s ease; }
.table tbody tr:hover { background-color: #f0f7ff; }
.table td {
    vertical-align: middle;
    font-size: 0.875rem;
    border-color: #f0f0f0;
    padding: 0.55rem 0.9rem;
}
.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: #fafafa;
}

[data-bs-theme="dark"] .table tbody tr:hover {
    background-color: rgba(255,255,255,0.04);
}
[data-bs-theme="dark"] .table td { border-color: #2d3142; }
[data-bs-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: rgba(255,255,255,0.02);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}
.btn-sm { font-size: 0.78rem; }

/* ============================================================
   BADGES & JENJANG
   ============================================================ */
.badge-ra    { background: #E91E63; color: #fff; }
.badge-mi    { background: #1976D2; color: #fff; }
.badge-mts   { background: #2E7D32; color: #fff; }
.badge-ma    { background: #E65100; color: #fff; }
.badge-mak   { background: #6A1B9A; color: #fff; }
.badge-kanwil{ background: #546E7A; color: #fff; }
.badge-kab   { background: #5D4037; color: #fff; }

/* ============================================================
   FORMS
   ============================================================ */
.form-control, .form-select {
    border-radius: 7px;
    border: 1px solid #d1d5db;
    font-size: 0.875rem;
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    min-width: 0;
    max-width: 100%;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21,101,192,0.12);
}
.form-label {
    font-size: 0.83rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background: #252836;
    border-color: #3d4155;
    color: #e0e0e0;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    color: var(--primary);
    border-radius: 10px 10px 0 0;
    padding: 1rem 1.25rem;
}
.modal-header .modal-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--primary);
}
.modal-header .btn-close { filter: none; }
.modal-content {
    border-radius: 10px;
    border: 1px solid var(--border-color);
    box-shadow: 0 16px 48px rgba(0,0,0,0.12);
}
[data-bs-theme="dark"] .modal-content {
    background: #1a1d27;
    border-color: #2d3142;
}
[data-bs-theme="dark"] .modal-header {
    background: #1a1d27;
    border-color: #2d3142;
    color: #90CAF9;
}
[data-bs-theme="dark"] .modal-header .modal-title { color: #90CAF9; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination .page-link {
    border-color: var(--border-color);
    color: var(--primary);
    font-size: 0.82rem;
    padding: 0.3rem 0.6rem;
    background: var(--card-bg);
}
.pagination .page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.pagination .page-link:hover {
    background: #e8f0fe;
    border-color: var(--primary);
    color: var(--primary-dark);
}
[data-bs-theme="dark"] .pagination .page-link {
    background: #1a1d27;
    border-color: #3d4155;
    color: #90CAF9;
}
[data-bs-theme="dark"] .pagination .page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0D47A1 0%, #1565C0 50%, #1976D2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.login-card {
    background: #fff;
    border-radius: 14px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.login-logo {
    width: 68px;
    height: 68px;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 2rem;
    color: #fff;
}
.login-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--primary-dark);
    text-align: center;
    margin-bottom: 0.3rem;
}
.login-subtitle {
    font-size: 0.83rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 2rem;
}

/* ============================================================
   DARK MODE OVERRIDES
   ============================================================ */
[data-bs-theme="dark"] .login-card { background: #1a1d27; }
[data-bs-theme="dark"] .login-title { color: #90CAF9; }
[data-bs-theme="dark"] .page-header { background: var(--page-header-bg); }
[data-bs-theme="dark"] .main-footer { background: var(--footer-bg); }
[data-bs-theme="dark"] .card { background: var(--card-bg); border-color: var(--border-color); }
[data-bs-theme="dark"] .card-header { background: var(--card-bg); border-color: var(--border-color); }
[data-bs-theme="dark"] .main-content { background: var(--body-bg); }
[data-bs-theme="dark"] .table { color: #e0e0e0; }
[data-bs-theme="dark"] .dropdown-menu {
    background: #1a1d27;
    border-color: #3d4155;
}
[data-bs-theme="dark"] .dropdown-item { color: #e0e0e0; }
[data-bs-theme="dark"] .dropdown-item:hover { background: rgba(255,255,255,0.07); }
[data-bs-theme="dark"] .dropdown-item.text-danger:hover {
    background: rgba(220,38,38,0.1);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
        box-shadow: none;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,0.12);
    }
    .main-content {
        margin-left: 0 !important;
        width: 100%;
        max-width: 100%;
    }
}

@media (max-width: 575.98px) {
    #mainNavbar { padding: 0 0.65rem; }
    .content-area { padding: 0.9rem 0.75rem; }
    .page-header { padding: 0.65rem 1rem; }
    .stat-card .stat-value { font-size: 1.5rem; }
    .card-header,
    .card-body {
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-primary { color: var(--primary) !important; }
.border-primary { border-color: var(--primary) !important; }
.bg-primary-soft { background: #e8f0fe; }

.loading-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.35);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.jenjang-label {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
