/* --- CSS VARIABLES & CUSTOMIZATION --- */
:root {
    /* Color Palette */
    --primary-navy: #0a2647;
    /* Deep Navy Blue */
    --primary-navy-dark: #051426;
    --accent-gold: #d4af37;
    /* Metallic Gold */
    --accent-gold-hover: #b5952f;
    --bg-body: #f4f6f9;
    /* Light Grey Background */
    --bg-card: #ffffff;
    --text-main: #333333;
    --text-muted: #6c757d;
    --text-light: #e2e8f0;

    /* Dimensions */
    --header-height: 60px;
    --footer-height: 45px;
    --sidebar-width: 260px;
    --sidebar-width-collapsed: 70px;

    /* Transitions */
    --transition-speed: 0.3s;
}

/* --- GLOBAL RESET & TYPOGRAPHY --- */
body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    font-size: 0.9rem;
    /* Compact font size */
    overflow-x: hidden;
}

a {
    text-decoration: none;
}

/* Layout Wrapper */
.wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* --- SIDEBAR STYLES --- */
#sidebar {
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    background: var(--primary-navy);
    color: var(--text-light);
    transition: all var(--transition-speed);
    position: fixed;
    height: 100vh;
    z-index: 1000;

    /* HILANGKAN SCROLL DI SIDEBAR UTAMA */
    overflow: hidden;

    display: flex;
    flex-direction: column;
}

#sidebar.active {
    margin-left: calc(var(--sidebar-width) * -1);
}

/* Sidebar Scrollbar Styling */
#sidebar::-webkit-scrollbar {
    width: 6px;
}

#sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    background-color: var(--primary-navy-dark);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);

    color: var(--accent-gold);
    font-weight: 700;
    font-size: 1.1rem;

    /* INI KUNCINYA */
    position: sticky;
    top: 0;
    z-index: 10;
}

.sidebar-brand i {
    font-size: 1.5rem;
    margin-right: 10px;
}

.sidebar-menu {
    padding: 1rem 0;
    list-style: none;
    margin-bottom: 0;
}

.sidebar-menu-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Scrollbar halus khusus menu */
.sidebar-menu-wrapper::-webkit-scrollbar {
    width: 6px;
}

.sidebar-menu-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}


.sidebar-menu li a {
    display: flex;
    align-items: center;
    padding: 0.6rem 1.25rem;
    color: var(--text-light);
    font-size: 0.9rem;
    transition: 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-menu li a:hover,
.sidebar-menu li a.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
    border-left-color: var(--accent-gold);
}

.sidebar-menu li a i {
    font-size: 1.1rem;
    margin-right: 12px;
    width: 20px;
    text-align: center;
    color: var(--accent-gold);
}

/* Submenu Styles */
.sidebar-submenu {
    background: var(--primary-navy-dark);
    padding-left: 0;
    list-style: none;
    display: none;
    /* Hidden by default */
    font-size: 0.85rem;
}

/* --- ACTIVE STATE UNTUK SUB-MENU (Level 2 & 3) --- */
.sidebar-submenu li a.active {
    /* Warna Teks Emas sesuai request */
    color: var(--accent-gold) !important; 
    
    /* Hilangkan efek transparan abu-abu agar terlihat jelas */
    opacity: 1 !important; 
    
    /* Tambah sedikit ketebalan agar lebih menonjol */
    font-weight: 600;
    
    /* Opsional: Tambah background sangat tipis agar lebih elegan */
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-submenu.show {
    display: block;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* UPDATE: Styling untuk items di dalam submenu (Level 2) */
.sidebar-submenu li a {
    padding: 0.5rem 1.25rem 0.5rem 3.5rem;
    /* Indented */
    border-left: none;
    opacity: 0.8;

    /* CSS Baru untuk Flexbox & Posisi Icon di Pojok Kanan */
    display: flex;
    justify-content: space-between;
    /* Taruh item di ujung kiri dan kanan */
    align-items: center;
    /* Posisi vertikal di tengah */
}

/* Posisi icon panah agar rapi di pojok kanan */
.sidebar-submenu li a i.bi-chevron-right {
    font-size: 0.7rem;
    margin-left: 10px;
    /* Beri jarak sedikit dari text */
}

.sidebar-submenu li a:hover {
    opacity: 1;
    color: var(--accent-gold);
}

/* Dropdown Arrow Animation Level 1 */
.has-dropdown .arrow {
    margin-left: auto;
    transition: 0.3s;
    font-size: 0.8rem;
}

.has-dropdown.open .arrow {
    transform: rotate(180deg);
}

/* --- MAIN CONTENT AREA --- */
#content {
    width: 100%;
    margin-left: var(--sidebar-width);
    transition: all var(--transition-speed);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

#content.active {
    margin-left: 0;
}

/* --- HEADER --- */
.main-header {
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 900;
}

.toggle-btn {
    background: transparent;
    border: 1px solid #dee2e6;
    color: var(--text-muted);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: 0.2s;
}

.toggle-btn:hover {
    background: var(--bg-body);
    color: var(--primary-navy);
}

/* Search Bar */
.search-bar {
    position: relative;
    max-width: 400px;
    width: 100%;
    margin-left: 20px;
    display: none;
    /* Hidden on very small mobile */
}

@media (min-width: 768px) {
    .search-bar {
        display: block;
    }
}

.search-bar input {
    width: 100%;
    padding: 0.5rem 1rem 0.5rem 2.3rem;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    background: var(--bg-body);
    font-size: 0.85rem;
}

.search-bar i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.action-icon {
    position: relative;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
}

.badge-notif {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    font-size: 0.65rem;
    padding: 2px 5px;
    border-radius: 50%;
}

.user-profile {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding-left: 1rem;
    border-left: 1px solid #e2e8f0;
}

.user-profile img {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-gold);
}

.user-info {
    margin-left: 0.5rem;
    display: none;
}

@media (min-width: 576px) {
    .user-info {
        display: block;
    }
}

.user-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--primary-navy);
    display: block;
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* --- MAIN CONTENT & CARDS --- */
.main-body {
    flex: 1;
    padding: 1.5rem;
}

.breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.breadcrumb-item.active {
    color: var(--accent-gold);
}

/* Premium Cards */
.card-premium {
    background: var(--bg-card);
    border: none;
    border-radius: 8px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.03);
    transition: 0.3s;
    margin-bottom: 1.5rem;
    border-top: 3px solid transparent;
}

.card-premium:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.06);
    border-top-color: var(--accent-gold);
}

.card-header-premium {
    background: transparent;
    border-bottom: 1px solid #f0f0f0;
    padding: 1rem 1.25rem;
    font-weight: 600;
    color: var(--primary-navy);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-icon {
    width: 45px;
    height: 45px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.bg-navy-light {
    background: rgba(10, 38, 71, 0.1);
    color: var(--primary-navy);
}

.bg-gold-light {
    background: rgba(212, 175, 55, 0.15);
    color: var(--accent-gold);
}

/* Table Styles */
.table-custom th {
    font-weight: 600;
    color: var(--primary-navy);
    border-top: none;
    font-size: 0.85rem;
    padding: 1rem;
}

.table-custom td {
    vertical-align: middle;
    font-size: 0.85rem;
    padding: 0.75rem 1rem;
    color: #555;
}

.mytable>tbody>tr>td,
.mytable>tbody>tr>th,
.mytable>tfoot>tr>td,
.mytable>tfoot>tr>th,
.mytable>thead>tr>td,
.mytable>thead>tr>th {
    padding: 5px;
}

th {
    padding: 4px;
    color: var(--primary-navy);
    border-top: 1px solid #dddddd !important;
    border-bottom: 3px solid #dddddd !important;
    padding: 8px;
}

.avatar-xs {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin-right: 8px;
}

/* --- FOOTER --- */
.main-footer {
    height: var(--footer-height);
    background: var(--primary-navy);
    color: rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    font-size: 0.75rem;
}

/* --- RESPONSIVE MOBILE --- */
@media (max-width: 992px) {
    #sidebar {
        margin-left: calc(var(--sidebar-width) * -1);
    }

    #sidebar.active {
        margin-left: 0;
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.1);
    }

    #content {
        margin-left: 0;
    }

    #content.active {
        /* Overlay effect */
    }

    .overlay {
        display: none;
        position: fixed;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 998;
    }

    .overlay.active {
        display: block;
    }
}

/* --- FORM STYLING --- */
.card-form {
    background: #fff;
    border: none;
    border-radius: 8px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.03);
    border-top: 3px solid var(--accent-gold);
    margin-bottom: 2rem;
    position: relative;
    /* Penting untuk Z-Index Select2 */
}

.form-label {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-main);
    margin-bottom: 0.4rem;
}

.form-control,
.form-select {
    padding: 0.65rem 0.9rem;
    font-size: 0.9rem;
    border-color: #e2e8f0;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-navy);
    box-shadow: 0 0 0 3px rgba(10, 38, 71, 0.1);
}

.form-check-input:checked {
    background-color: var(--accent-gold);
    border-color: var(--accent-gold);
}

.section-header {
    background: var(--primary-navy);
    color: #fff;
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
}

/* --- SELECT2 CUSTOM DESIGN --- */
/* Menyamakan tinggi dan padding dengan .form-control */
.select2-container--bootstrap-5 .select2-selection {
    min-height: calc(1.5em + 1.3rem + 2px) !important;
    /* Menyesuaikan padding 0.65rem */
    padding: 0.35rem 0.5rem !important;
    font-size: 0.9rem !important;
    /* Sama dengan .form-control */
    border-color: #e2e8f0 !important;
    border-radius: 6px !important;
}

/* Menyamakan warna teks di dalam box select */
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    color: var(--text-main) !important;
    padding-left: 0.4rem !important;
}

/* Menyamakan warna placeholder */
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__placeholder {
    color: var(--text-muted) !important;
    font-size: 0.9rem !important;
}

/* Menyamakan style saat Focus (Border Navy & Shadow) */
.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: var(--primary-navy) !important;
    box-shadow: 0 0 0 3px rgba(10, 38, 71, 0.1) !important;
}

/* Menyamakan tampilan Dropdown List */
.select2-container--bootstrap-5 .select2-dropdown {
    border-color: #e2e8f0 !important;
    border-radius: 6px !important;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1) !important;
    z-index: 9999;
    /* Pastikan di atas elemen lain */
}

/* Menyamakan teks pilihan di dalam list */
.select2-results__option {
    font-size: 0.9rem !important;
    padding: 8px 15px !important;
}

/* Menyamakan warna saat item dipilih/hover */
.select2-container--bootstrap-5 .select2-results__option--highlighted {
    background-color: var(--primary-navy) !important;
    color: #ffffff !important;
}

/* --- CARD & TABLE STYLING --- */
.card-table {
    background: #fff;
    border: none;
    border-radius: 8px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.03);
    border-top: 3px solid var(--accent-gold);
    margin-bottom: 2rem;
    padding: 1.5rem;
}

.table-custom thead {
    background-color: var(--primary-navy);
    color: white;
}

.table-custom th {
    font-weight: 500;
    color: white;
    border-bottom: none;
    padding: 1rem;
}

.table-custom td {
    vertical-align: middle;
    padding: 0.75rem 1rem;
    color: #555;
}

/* --- DATATABLES OVERRIDES (Premium Theme) --- */

/* Pagination Styling */
.dataTables_wrapper .dataTables_paginate .paginate_button {
    color: var(--primary-navy) !important;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin: 0 2px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    color: white !important;
    background: var(--accent-gold);
    border-color: var(--accent-gold);
    font-weight: bold;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    color: white !important;
    background: var(--primary-navy);
    border-color: var(--primary-navy);
}

/* Menghilangkan spasi antar list item */
.dataTables_wrapper .dataTables_paginate ul.pagination li {
    margin: 0 1px !important;           /* Jarak antar kotak tipis saja */
}

/* Menghapus radius yang terlalu besar (opsional, agar lebih kotak elegan) */
.dataTables_wrapper .dataTables_paginate ul.pagination li:first-child a,
.dataTables_wrapper .dataTables_paginate ul.pagination li:last-child a {
    border-radius: 4px !important;
}

/* Konsistensi warna agar tetap Premium */
.dataTables_wrapper .dataTables_paginate ul.pagination li.active a {
    background-color: var(--accent-gold) !important;
    border-color: var(--accent-gold) !important;
}

/* Length Menu & Search Styling */
div.dataTables_wrapper div.dataTables_filter input {
    border-radius: 20px;
    /* Round search input */
    padding: 0.4rem 1rem;
    border: 1px solid #e2e8f0;
}

div.dataTables_wrapper div.dataTables_filter input:focus {
    border-color: var(--accent-gold);
    outline: none;
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

div.dataTables_wrapper div.dataTables_length select {
    border: 1px solid #e2e8f0;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

/* Menambah lebar dropdown 'Show entries' */
.dataTables_length select {
    width: 70px !important;
    /* Ubah angka ini sesuai keinginan */
    display: inline-block;
    margin: 0 0.5rem;
}

/* Action Buttons in Table */
.btn-action-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 4px;
}

.btn-edit {
    background: #e2e8f0;
    color: var(--primary-navy);
    border: none;
}

.btn-edit:hover {
    background: #cbd5e1;
    color: #000;
}

.btn-delete {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
    border: none;
}

.btn-delete:hover {
    background: #dc3545;
    color: white;
}

@media (max-width: 992px) {
    #sidebar {
        margin-left: calc(var(--sidebar-width) * -1);
    }

    #sidebar.active {
        margin-left: 0;
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.1);
    }

    #content {
        margin-left: 0;
    }
}

/* --- DATATABLES CONSISTENCY STYLES --- */
/* 1. Konsistensi Font & Warna untuk Seluruh Tabel */
.dataTables_wrapper {
    font-family: 'Inter', sans-serif !important;
    font-size: 0.85rem !important;
    /* Sedikit lebih kecil agar elegan di tabel padat */
    color: var(--text-main) !important;
}

/* 2. Header Tabel (thead) */
.table-custom thead th {
    background-color: var(--primary-navy) !important;
    color: #ffffff !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.8rem !important;
    font-weight: 600 !important;
    padding: 12px 15px !important;
    border: none !important;
}

/* 3. Body Tabel (td) */
.table-custom tbody td {
    color: #444 !important;
    padding: 10px 15px !important;
    border-bottom: 1px solid #f0f0f0 !important;
}

/* 4. Styling Teks "Showing x of x entries" (Info) */
.dataTables_info {
    font-size: 0.8rem !important;
    color: var(--text-muted) !important;
    padding-top: 1.5rem !important;
}

/* 5. Styling Teks Label "Show entries" dan "Search" */
.dataTables_length label,
.dataTables_filter label {
    font-weight: 500 !important;
    color: var(--text-main) !important;
    font-size: 0.85rem !important;
}

/* 6. Memperbaiki tampilan 'Empty Table' atau 'Loading' */
.dataTables_empty {
    padding: 2rem !important;
    font-style: italic;
    color: var(--text-muted) !important;
}

/* 7. Hover effect pada baris tabel agar teks tetap tajam */
.table-custom tbody tr:hover {
    background-color: rgba(212, 175, 55, 0.05) !important;
}

/* --- LOADER / PRELOADER STYLES --- */
#page-loader {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.loader-content {
    position: relative;
    width: 150px; /* Ukuran area loader */
    height: 150px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Spinner Ring Gold */
.loader-spinner {
    position: absolute;
    width: 130px;
    height: 130px;
    border: 4px solid rgba(212, 175, 55, 0.1); /* Background ring tipis */
    border-top: 4px solid var(--accent-gold);
    border-right: 4px solid var(--accent-gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1;
}

/* Logo Loader */
.loader-logo-img {
    width: 70px; /* Ukuran logo lebih kecil dari spinner */
    height: 70px;
    object-fit: contain;
    position: relative;
    z-index: 2;
    animation: pulseLogo 1.5s infinite ease-in-out;
}

/* Text Loading */
.loader-text {
    position: absolute;
    bottom: -40px; /* Posisi teks di bawah lingkaran */
    width: 200px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--primary-navy);
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    animation: fadeText 1.5s infinite alternate;
}

/* Keyframes */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulseLogo {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes fadeText {
    0% { opacity: 0.4; }
    100% { opacity: 1; }
}

.loader-hidden {
    opacity: 0;
    visibility: hidden;
}

/* 1. Perkecil Ukuran Tombol Pagination */
.dataTables_wrapper .dataTables_paginate ul.pagination li a {
    font-family: 'Inter', sans-serif !important;
    font-size: 0.75rem !important;      /* Ukuran font lebih kecil */
    padding: 0.25rem 0.5rem !important; /* Padding sangat rapat */
    min-width: 30px;                    /* Memastikan tombol tetap simetris */
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.form-select.form-select-sm {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.8rem !important;
    line-height: 1.2;
}
