/* 
 * SiPKL UI - Design System 
 * A modern, mobile-first, and lightweight custom CSS framework.
 */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Colors */
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --primary-light: #EEF2FF;
    
    --secondary: #64748B;
    --secondary-hover: #475569;
    --secondary-light: #F1F5F9;
    
    --success: #10B981;
    --success-light: #D1FAE5;
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;

    --bg-body: #F8FAFC;
    --bg-surface: #FFFFFF;
    
    --text-main: #0F172A;
    --text-muted: #64748B;
    
    --border: #E2E8F0;
    
    /* Typography */
    --font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-glass: 0 4px 30px rgba(0, 0, 0, 0.1);
    
    /* Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-pill: 9999px;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition: all 0.3s ease;
}

/* Base Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}
a:hover {
    color: var(--primary-hover);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Typography Classes */
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-muted); }

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.fw-medium { font-weight: 500; }
.text-center { text-align: center; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    gap: 0.5rem;
}
.btn-primary {
    background-color: var(--primary);
    color: white;
}
.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: var(--shadow-md);
}
.btn-secondary {
    background-color: var(--secondary-light);
    color: var(--secondary);
}
.btn-secondary:hover {
    background-color: var(--border);
    color: var(--text-main);
}
.btn-danger {
    background-color: var(--danger);
    color: white;
}
.btn-danger:hover {
    background-color: #B91C1C;
}
.btn-success {
    background-color: var(--success);
    color: white;
}
.btn-success:hover {
    background-color: #047857;
}
.btn-outline-primary {
    background-color: transparent;
    border-color: var(--primary);
    color: var(--primary);
}
.btn-outline-primary:hover {
    background-color: var(--primary);
    color: white;
}
.btn-block {
    width: 100%;
}

/* Form Elements */
.form-group {
    margin-bottom: 1rem;
}
.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.375rem;
    color: var(--text-main);
}
.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background-color: var(--bg-surface);
    color: var(--text-main);
    transition: var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Cards */
.card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: 1.5rem;
}
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background-color: rgba(249, 250, 251, 0.5);
    font-weight: 600;
}
.card-body {
    padding: 1.25rem;
}
.card-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    background-color: rgba(249, 250, 251, 0.5);
}

/* Glassmorphism utility */
.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: var(--shadow-glass);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25em 0.6em;
    font-size: 0.75em;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: var(--radius-pill);
}
.bg-primary { background-color: var(--primary); color: white; }
.bg-success { background-color: var(--success); color: white; }
.bg-danger { background-color: var(--danger); color: white; }
.bg-warning { background-color: var(--warning); color: #000; }
.bg-secondary { background-color: var(--secondary); color: white; }

.bg-primary-light { background-color: var(--primary-light); color: var(--primary); }
.bg-success-light { background-color: var(--success-light); color: var(--success); }
.bg-danger-light { background-color: var(--danger-light); color: var(--danger); }
.bg-warning-light { background-color: var(--warning-light); color: var(--warning); }

/* Utility Classes */
.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.align-items-center { align-items: center; }
.justify-content-center { justify-content: center; }
.justify-content-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.gap-4 { gap: 1.5rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }
.w-100 { width: 100%; }
.h-100 { height: 100%; }

/* Layout: General Container */
.container {
    width: 100%;
    margin-right: auto;
    margin-left: auto;
    padding-right: 1rem;
    padding-left: 1rem;
}
@media (min-width: 640px) { .container { max-width: 640px; } }
@media (min-width: 768px) { .container { max-width: 768px; } }
@media (min-width: 1024px) { .container { max-width: 1024px; } }
@media (min-width: 1280px) { .container { max-width: 1280px; } }

/* ----------------------------------
   LAYOUT: MOBILE BOTTOM NAV
----------------------------------- */
.mobile-layout {
    padding-bottom: 80px;
    padding-top: 60px;
}
.mobile-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}
.mobile-header-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary);
}
.mobile-header-actions {
    display: flex;
    gap: 0.5rem;
}
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 50;
    padding-bottom: env(safe-area-inset-bottom);
}
.nav-item-mobile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 600;
    text-decoration: none;
    width: 25%;
    padding: 0.25rem;
    transition: var(--transition);
}
.nav-item-mobile i {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}
.nav-item-mobile.active {
    color: var(--primary);
}
.nav-item-mobile:hover {
    color: var(--primary-hover);
}

/* ----------------------------------
   LAYOUT: ADMIN SIDEBAR
----------------------------------- */
.admin-layout {
    display: flex;
    min-height: 100vh;
}
.admin-sidebar {
    width: 260px;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    transition: transform 0.3s ease;
}
.sidebar-header {
    height: 70px;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border);
}
.sidebar-header h2 {
    font-size: 1.25rem;
    color: var(--primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}
.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--secondary);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius-sm);
}
.sidebar-close:hover {
    background: var(--secondary-light);
    color: var(--text-main);
}
.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}
.menu-group {
    margin-bottom: 1.5rem;
}
.menu-label {
    padding: 0 1.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}
.menu-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: var(--text-main);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
}
.menu-item i {
    width: 20px;
    margin-right: 0.75rem;
    color: var(--text-muted);
    font-size: 1.1rem;
    text-align: center;
    transition: var(--transition);
}
.menu-item:hover, .menu-item.active {
    background-color: var(--primary-light);
    color: var(--primary);
    border-left-color: var(--primary);
}
.menu-item:hover i, .menu-item.active i {
    color: var(--primary);
}

.admin-main {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.admin-header {
    height: 70px;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 30;
}
.header-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-main);
    cursor: pointer;
}
.header-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.profile-info {
    text-align: right;
}
.profile-name {
    font-weight: 600;
    font-size: 0.875rem;
}
.profile-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.profile-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}
.admin-content {
    padding: 2rem;
    flex: 1;
}

/* Profile Dropdown */
.profile-dropdown {
    position: relative;
    cursor: pointer;
}
.profile-dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: var(--transition);
    z-index: 100;
    overflow: hidden;
}
.profile-dropdown.active .profile-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.profile-dropdown-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--danger);
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
    font-size: 0.875rem;
}
.profile-dropdown-item:hover {
    background-color: var(--danger-light);
}
.profile-dropdown-item i {
    margin-right: 0.5rem;
    width: 20px;
    text-align: center;
}

@media (max-width: 991px) {
    .admin-sidebar {
        transform: translateX(-100%);
    }
    .admin-sidebar.show {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    .sidebar-close {
        display: block;
    }
    .admin-main {
        margin-left: 0;
    }
    .header-toggle {
        display: block;
    }
    .admin-header {
        padding: 0 1rem;
    }
    .admin-content {
        padding: 1rem;
    }
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}
.table {
    width: 100%;
    border-collapse: collapse;
}
.table th, .table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.table th {
    background-color: rgba(249, 250, 251, 0.5);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.table td {
    font-size: 0.875rem;
}
/* Zebra striping - alternating row colors for readability */
.table tbody tr:nth-child(odd),
.table-custom tbody tr:nth-child(odd),
.datatable tbody tr:nth-child(odd),
table.dataTable tbody tr.odd {
    background-color: #FFFFFF;
}
.table tbody tr:nth-child(even),
.table-custom tbody tr:nth-child(even),
.datatable tbody tr:nth-child(even),
table.dataTable tbody tr.even,
.table-striped > tbody > tr:nth-of-type(even) {
    background-color: #F1F5F9;
}
/* Bootstrap 5 override: force striped color via CSS variable */
.table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-accent-bg: #FFFFFF;
    --bs-table-bg-type: #FFFFFF;
}
.table-striped > tbody > tr:nth-of-type(even) > * {
    --bs-table-accent-bg: #F1F5F9;
    --bs-table-bg-type: #F1F5F9;
}
.table tbody tr:hover,
.table-custom tbody tr:hover,
.datatable tbody tr:hover,
table.dataTable tbody tr.odd:hover,
table.dataTable tbody tr.even:hover {
    background-color: var(--primary-light);
}
.table-striped > tbody > tr:hover > * {
    --bs-table-accent-bg: var(--primary-light);
    --bs-table-bg-type: var(--primary-light);
}

/* Grid System Helper */
.row {
    display: flex;
    flex-wrap: wrap;
}
.col-12 { width: 100%; }
.col-6 { width: 50%; }
.col-4 { width: 33.333333%; }
.col-3 { width: 25%; }

@media (max-width: 576px) {
    .col-sm-12 { width: 100%; }
}

/* DataTables Overrides for Modern Look */
.dataTables_wrapper {
    font-size: 0.875rem;
    color: var(--text-main);
    padding: 1rem 0;
}
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    padding: 0 1.25rem 1rem 1.25rem;
}
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    padding: 1rem 1.25rem;
}
.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.25rem 0.5rem;
    outline: none;
}
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.4rem 0.75rem;
    margin-left: 0.5rem;
    outline: none;
}
.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 0.4rem 0.8rem !important;
    margin-left: 0.25rem;
    border-radius: var(--radius-md) !important;
    border: 1px solid transparent !important;
    background: transparent !important;
    color: var(--text-main) !important;
    transition: var(--transition);
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--gray-100) !important;
    border: 1px solid var(--border) !important;
    color: var(--text-main) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--primary) !important;
    color: white !important;
    border: 1px solid var(--primary) !important;
    box-shadow: var(--shadow-sm);
}
.dataTables_wrapper .dataTables_info {
    padding-top: 1rem !important;
    color: var(--text-muted);
}
table.dataTable.no-footer {
    border-bottom: 1px solid var(--border) !important;
}
table.dataTable thead th, table.dataTable thead td {
    border-bottom: 2px solid var(--border) !important;
    padding: 1rem !important;
}
table.dataTable tbody td {
    padding: 1rem !important;
    vertical-align: middle;
}

/* Mobile Layout for Non-Admin */
.mobile-layout {
    background-color: var(--bg-body);
    padding-top: 60px;
    padding-bottom: 80px;
}
.mobile-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 60px;
    background: white;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    z-index: 1000;
}
.mobile-header-title {
    font-weight: 800;
    color: var(--primary);
    font-size: 1.25rem;
    letter-spacing: -0.5px;
}
.mobile-header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.mobile-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 65px;
    background: white;
    box-shadow: 0 -4px 15px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--border);
}
.nav-item-mobile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--secondary);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 600;
    flex: 1;
    height: 100%;
    transition: var(--transition);
}
.nav-item-mobile i {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
    transition: transform 0.2s;
}
.nav-item-mobile:hover i, .nav-item-mobile.active i {
    transform: translateY(-2px);
}
.nav-item-mobile:hover, .nav-item-mobile.active {
    color: var(--primary);
}
.nav-item-mobile.active {
    position: relative;
}
.nav-item-mobile.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 4px;
    background: var(--primary);
    border-radius: 0 0 4px 4px;
}

/* ===== SELECT2 =====
 * Tanpa aturan ini, <select class="select2"> yang sudah jadi display:block
 * bisa terukur 1px saat select2 mengukurnya, sehingga dropdown-nya sempit
 * 1px dan daftar pilihannya tidak kelihatan sama sekali.
 * Jaring pengaman: select2 Selalu diinisialisasi dengan width:'100%'
 * (lihat initDynamic() di index.php).
 */
select.select2,
select.form-select-custom.select2 {
    width: 100%;
}

.select2-container {
    max-width: 100%;
}

.select2-container--default .select2-dropdown {
    min-width: 12rem;
}


/* Dropdown aksi tabel diposisikan fixed oleh JS saat dibuka (lihat handler
   .dropdown-btn di index.php) agar keluar dari wrapper overflow tabel. */
.dropdown-content.show {
    z-index: 2000;
}
