/* ============================================================
   GLOBAL
============================================================ */
:root {
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --accent-color: #e74c3c;
    --light-color: #ecf0f1;
    --dark-color: #2c3e50;
    --success-color: #2ecc71;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #3b82f6;
    --sidebar-width: 150px;
    --sidebar-collapsed-width: 50px;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Plus Jakarta Sans', sans-serif; }
html, body { height: 100%; }
body { 
    background-color: #f8fafc; 
    color: #1e293b; 
    line-height: 1.6; 
}
a { text-decoration: none; color: inherit; }

.dashboard-container { display: flex; min-height: 100vh; }

/* ============================================================
   SIDEBAR
============================================================ */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: white;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
    transition: width 0.3s ease, transform 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    transform: translateX(0);
}

.sidebar-header {
    padding: 9px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.logo { display: flex; align-items: center; gap: 8px; overflow: hidden; }
.logo-icon { font-size: 14px; width: 23px; height: 23px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.1); border-radius: 5px; flex-shrink: 0; }
.logo-text { overflow: hidden; white-space: nowrap; transition: opacity 0.2s ease, width 0.3s ease; }
.logo-text strong { font-size: 11px; font-weight: 700; }

.sidebar-nav { padding: 12px 0; flex: 1; }

.nav-item {
    display: flex; align-items: center;
    padding: 6px 12px;
    color: rgba(255,255,255,0.75);
    transition: all 0.2s;
    border-left: 3px solid transparent;
    white-space: nowrap; overflow: hidden;
    cursor: pointer;
    gap: 8px;
}
.nav-item i { font-size: 11px; flex-shrink: 0; width: 14px; text-align: center; }
.nav-item span { font-size: 9px; font-weight: 500; transition: opacity 0.2s ease; flex: 1; min-width: 0; }
.nav-item:hover { background-color: var(--sidebar-hover); color: white; }
.nav-item.active { background-color: var(--sidebar-active); color: white; border-left-color: white; }

.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,0.1); flex-shrink: 0; }
.logout-btn { display: flex; align-items: center; gap: 9px; padding: 8px 12px; color: #f87171; border-radius: 6px; transition: all 0.2s; white-space: nowrap; overflow: hidden; }
.logout-btn:hover { background-color: rgba(239,68,68,0.1); }
.logout-btn i { flex-shrink: 0; width: 12px; text-align: center; }

/* ============================================================
   SIDEBAR — COLLAPSED STATE
============================================================ */
.sidebar.collapsed { width: 50px; }

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .logout-btn span { display: none; }

.sidebar.collapsed .sidebar-header { justify-content: center; padding: 12px 8px; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 14px 0; gap: 0; border-left: 3px solid transparent; }
.sidebar.collapsed .nav-item.active { border-left-color: white; }
.sidebar.collapsed .logout-btn { justify-content: center; padding: 10px 0; gap: 0; }

/* Tooltip saat collapsed (hover label) */
.sidebar.collapsed .nav-item { position: relative; }
.sidebar.collapsed .nav-item::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(var(--sidebar-collapsed-width) + 8px);
    background: #334155;
    color: white;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 9999;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.sidebar.collapsed .nav-item:hover::after { opacity: 1; }

/* ============================================================
   DROPDOWN NAVIGATION
============================================================ */
.nav-dropdown {
    display: flex;
    flex-direction: column;
}

.nav-item.dropdown-toggle {
    justify-content: flex-start;
    position: relative;
}

.dropdown-arrow {
    margin-left: auto;
    font-size: 8px;
    transition: transform 0.25s ease;
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-item.dropdown-toggle.open .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;          /* default tersembunyi */
    overflow: hidden;
    transition: max-height 0.3s ease;
    background-color: rgba(0, 0, 0, 0.15);
    border-left: 2px solid rgba(59, 130, 246, 0.4);
    margin-left: 12px;
}

.dropdown-menu.show {
    max-height: 400px;
}

.nav-item.sub-item {
    padding: 7px 15px 7px 18px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.65);
    border-left: none;
    gap: 9px;
    display: flex;
    align-items: center;
}

.nav-item.sub-item .nav-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.nav-item.sub-item .nav-text span {
    font-size: 10px;
    font-weight: 500;
    line-height: 1.2;
}

.nav-item.sub-item .nav-text small {
    font-size: 8px;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.2;
    margin-top: 1px;
    font-weight: 400;
}

.nav-item.sub-item:hover {
    background-color: var(--sidebar-hover);
    color: white;
}

.nav-item.sub-item.active {
    background-color: rgba(59, 130, 246, 0.25);
    color: #93c5fd;
    border-left: none;
}

/* Ikon nav */
.nav-icon {
    font-size: 12px;
    flex-shrink: 0;
    width: 15px;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Tampilkan dropdown saat collapsed */
.sidebar.collapsed .dropdown-arrow { display: none; }
.sidebar.collapsed .dropdown-menu  { max-height: 0 !important; }
.sidebar.collapsed .nav-item.dropdown-toggle { justify-content: center; }

/* ============================================================
   MAIN CONTENT — animasi expand saat sidebar collapsed
============================================================ */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 16px 20px;
    padding-top: 16px;
    flex: 1;
    min-width: 0;
    transition: margin-left 0.3s ease, padding-top 0.3s ease;
}

/* Saat sidebar collapsed, main-content melebar */
.main-content.expanded {
    margin-left: var(--sidebar-collapsed-width);
}

/* TOPBAR — visible on mobile, hidden on desktop by default */
.topbar { 
    display: none; 
    justify-content: space-between;
    align-items: center;
    padding: 9px 12px;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 998;
    height: 45px;
}

/* Show header on all screens when needed */
.topbar.show-desktop {
    display: flex !important;
}

/* Adjust main content when header is visible on desktop */
.main-content.with-header {
    padding-top: 66px !important;
}

.topbar-hamburger { 
    background: none; 
    border: none; 
    font-size: 15px; 
    cursor: pointer; 
    padding: 6px; 
    border-radius: 5px; 
    color: #1e293b;
    transition: background-color 0.2s;
}

.topbar-hamburger:hover {
    background-color: #f1f5f9;
}

.topbar-title { 
    font-size: 12px; 
    font-weight: 700; 
    color: #1e293b;
    flex: 1;
    text-align: center;
    margin: 0 12px;
}

.topbar-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.topbar-search {
    background: none;
    border: none;
    font-size: 12px;
    cursor: pointer;
    padding: 6px;
    border-radius: 5px;
    color: #64748b;
    transition: background-color 0.2s;
}

.topbar-search:hover {
    background-color: #f1f5f9;
}

/* Search Overlay */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 60px;
    animation: fadeIn 0.3s ease;
}

.search-overlay.show {
    display: flex;
}

.search-container {
    background: white;
    border-radius: 9px;
    padding: 15px;
    width: 90%;
    max-width: 375px;
    box-shadow: 0 8px 23px rgba(0,0,0,0.2);
    animation: slideDown 0.3s ease;
}

.search-input {
    width: 100%;
    padding: 9px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12px;
    outline: none;
    transition: border-color 0.2s;
}

.search-input:focus {
    border-color: var(--primary-color);
}

.search-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 15px;
    cursor: pointer;
    color: #64748b;
    padding: 6px;
    border-radius: 5px;
    transition: all 0.2s;
}

.search-close:hover {
    background-color: #f1f5f9;
    color: #1e293b;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* OVERLAY */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 999; cursor: pointer; }
.sidebar-overlay.show { display: block; }

/* ============================================================
   CARD COMPONENTS
============================================================ */
.card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

/* ============================================================
   PAGE TITLE
============================================================ */
.page-title { font-size: 24px; font-weight: 700; margin-bottom: 24px; color: #1e293b; }

/* ============================================================
   STATS GRID
============================================================ */
.stats-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 
    gap: 16px; 
    margin-bottom: 28px;
}
.btn-plus { display: block; text-decoration: none; color: inherit; }
.stat-card { 
    background: white; 
    border-radius: 12px; 
    padding: 24px; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.1); 
    transition: transform 0.2s, box-shadow 0.2s; 
    border-left: 4px solid transparent;
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, rgba(52,152,219,0.1) 0%, rgba(52,152,219,0.05) 100%);
    border-radius: 0 12px 0 60px;
}
.stat-card:hover { 
    transform: translateY(-4px); 
    box-shadow: 0 8px 25px rgba(0,0,0,0.15); 
    border-left-color: var(--primary-color);
}
.stat-card h3 { 
    font-size: 14px; 
    font-weight: 500; 
    color: #64748b; 
    margin-bottom: 8px; 
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.stat-card p { 
    font-size: 32px; 
    font-weight: 700; 
    color: #1e293b;
    position: relative;
    z-index: 1;
}
.stat-card--warning { 
    border-left-color: #f59e0b; 
    background: linear-gradient(135deg, #fffbeb 0%, #ffffff 100%);
}
.stat-card--warning::before {
    background: linear-gradient(135deg, rgba(245,158,11,0.1) 0%, rgba(245,158,11,0.05) 100%);
}
.stat-card--warning:hover {
    border-left-color: #d97706;
}

/* Responsive stats grid */
@media (max-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
    .stat-card { padding: 20px; }
    .stat-card h3 { font-size: 13px; }
    .stat-card p { font-size: 28px; }
}

@media (max-width: 768px) {
    .stats-grid { 
        grid-template-columns: repeat(2, 1fr); 
        gap: 12px; 
        margin-bottom: 20px;
    }
    .stat-card { padding: 16px; }
    .stat-card h3 { font-size: 12px; margin-bottom: 6px; }
    .stat-card p { font-size: 24px; }
    .stat-card::before {
        width: 40px;
        height: 40px;
        border-radius: 0 8px 0 40px;
    }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-card p { font-size: 20px; }
}

/* ============================================================
   TABLE SECTION
============================================================ */
.table-section { background: white; border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin-bottom: 24px; }
.table-section h2 { font-size: 16px; font-weight: 600; margin-bottom: 14px; color: #1e293b; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.table-section--alert { border: 1px solid #fca5a5; background-color: #fff5f5; }
.table-section--alert h2 { color: #dc2626; }
.badge-alert { font-size: 0.7rem; font-weight: 600; background-color: #dc2626; color: #fff; padding: 2px 10px; border-radius: 999px; }

.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
    /* Custom scrollbar untuk webkit browsers */
}

.table-container::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}

.table-container::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.table-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.custom-table, table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px; /* Increased minimum width for better tablet experience */
}

.custom-table th, .custom-table td, table th, table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
    font-size: 8px;
    vertical-align: middle;
}

.custom-table th, table th {
    background-color: #f8fafc;
    font-weight: 600;
    color: #475569;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    position: sticky;
    top: 0;
    z-index: 10;
}

.custom-table tr:last-child td, table tr:last-child td { border-bottom: none; }
.custom-table tr:hover td, table tr:hover td { background-color: #f8fafc; }

.row-habis   { background-color: #fee2e2 !important; }
.row-menipis { background-color: #fff7ed !important; }
.badge { display: inline-block; font-size: 0.68rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; }
.badge--habis   { background-color: #dc2626; color: #fff; }
.badge--menipis { background-color: #f59e0b; color: #fff; }
.empty-data { text-align: center; color: #94a3b8; padding: 32px !important; }

/* Responsive table helpers */
@media (max-width: 1200px) {
    .custom-table, table { min-width: 700px; }
    .custom-table th, .custom-table td, table th, table td { padding: 10px 12px; font-size: 13px; }
}

@media (max-width: 900px) {
    .custom-table, table { min-width: 600px; }
    .custom-table th, .custom-table td, table th, table td { padding: 8px 10px; font-size: 12px; }
}

/* ============================================================
   BUTTONS
============================================================ */
.btn, .btn-add, .btn-submit, .btn-login { background-color: var(--primary-color); color: white; border: none; padding: 10px 16px; border-radius: 6px; cursor: pointer; font-size: 0.9rem; transition: background-color 0.2s; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover, .btn-add:hover, .btn-submit:hover, .btn-login:hover { background-color: #2980b9; }
.btn-cancel { background-color: #6c757d; color: white; border: none; padding: 10px 16px; border-radius: 6px; cursor: pointer; font-size: 0.9rem; transition: background-color 0.2s; display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; }
.btn-cancel:hover { background-color: #5a6268; }
.btn-edit   { color: var(--warning-color); margin-right: 8px; }
.btn-delete { color: var(--danger-color); }

/* ============================================================
   FORMS
============================================================ */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 14px; }
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="file"],
.form-group select,
.form-group textarea { width: 100%; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 1rem; background: white; transition: border-color 0.2s; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(52,152,219,0.1); }
.form-group textarea { min-height: 90px; resize: vertical; }

/* ============================================================
   ALERTS
============================================================ */
.alert { padding: 10px 15px; border-radius: 6px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; font-size: 14px; }
.alert.error   { background-color: #fde8e8; color: var(--danger-color); border-left: 4px solid var(--danger-color); }
.alert.success { background-color: #d4edda; color: #155724; border-left: 4px solid #28a745; }
.success-message { background-color: #d4edda; color: #155724; padding: 10px 15px; border-radius: 6px; margin-bottom: 16px; border-left: 4px solid #28a745; }
.error-message   { background-color: #f8d7da; color: #721c24; padding: 10px 15px; border-radius: 6px; margin-bottom: 16px; border-left: 4px solid #dc3545; }

/* ============================================================
   LOGIN
============================================================ */
.login-page { display: flex; justify-content: center; align-items: center; min-height: 100vh; background-color: var(--light-color); padding: 16px; }
.login-container { background-color: white; padding: 40px; border-radius: 10px; box-shadow: var(--shadow); width: 100%; max-width: 400px; text-align: center; }
.login-container h1 { margin-bottom: 30px; color: var(--primary-color); }

/* ============================================================
   MODAL
============================================================ */
.modal { display: none; position: fixed; z-index: 1100; inset: 0; background-color: rgba(0,0,0,0.5); overflow: auto; padding: 16px; }
.modal-content { background-color: white; margin: 5% auto; padding: 24px; border-radius: 8px; width: 100%; max-width: 600px; box-shadow: 0 5px 15px rgba(0,0,0,0.3); position: relative; }
.close { position: absolute; top: 12px; right: 16px; font-size: 1.5rem; cursor: pointer; color: #64748b; }

/* ============================================================
   MOBILE ≤ 768px
============================================================ */
@media (max-width: 768px) {

    .sidebar {
        transform: translateX(-100%) !important;
        width: var(--sidebar-width) !important;
        box-shadow: none;
        visibility: hidden; /* Hide sidebar by default on mobile */
    }

    .sidebar.open {
        transform: translateX(0) !important;
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
        visibility: visible; /* Show sidebar when open */
    }

    /* Paksa tampilkan teks saat sidebar.open di mobile */
    .sidebar.open .logo-text,
    .sidebar.open .nav-item span,
    .sidebar.open .logout-btn span { display: block !important; }

    .sidebar.open .sidebar-header { justify-content: center; padding: 12px 8px; }

    .sidebar.open .nav-item { justify-content: flex-start !important; padding: 6px 12px !important; gap: 8px !important; border-left: 3px solid transparent; }

    .sidebar.open .nav-item.active { border-left-color: white; }

    .sidebar.open .logout-btn { justify-content: flex-start !important; gap: 8px !important; padding: 8px 0 !important; }

    /* Dropdown tetap bekerja di mobile */
    .sidebar.open .dropdown-arrow { display: inline-block !important; }

    .sidebar.open .dropdown-menu  { display: block !important; }

    .sidebar.open .dropdown-menu.show { max-height: 400px; }

    .sidebar.open .nav-item.sub-item {
        justify-content: flex-start !important;
        padding: 7px 15px 7px 18px !important;
        gap: 8px !important;
    }

    .sidebar.open .nav-item.dropdown-toggle { justify-content: flex-start !important; }

    /* Toggle button di mobile - always visible */
    .sidebar .toggle-btn {
        display: block !important;
        position: absolute;
        top: 20px;
        right: 20px;
        z-index: 1001;
        background: var(--primary-color);
        color: white;
        padding: 8px;
        border-radius: 6px;
    }

    /* Main content dengan proper mobile layout */
    .main-content {
        margin-left: 0 !important;
        padding: 16px !important;
        padding-top: 60px !important; /* Account for fixed header */
        min-height: calc(100vh - 60px); /* Account for mobile viewport */
    }

    /* class expanded tidak berlaku di mobile */
    .main-content.expanded {
        margin-left: 0 !important;
    }

    /* Topbar selalu tampil di mobile */
    .topbar {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 9px 12px;
        background: white;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 998;
        height: 45px;
    }

    /* Show header on all screens when needed */
    .topbar.show-desktop {
        display: none !important; /* Hide desktop header on mobile */
    }

    /* Adjust main content when header is visible on desktop */
    .main-content.with-header {
        padding-top: 66px !important;
    }

    .topbar-hamburger { 
        background: none; 
        border: none; 
        font-size: 15px; 
        cursor: pointer; 
        padding: 6px; 
        border-radius: 5px; 
        color: #1e293b;
        transition: background-color 0.2s;
        display: flex !important; /* Ensure hamburger is visible */
        align-items: center;
        justify-content: center;
    }

    .topbar-hamburger:hover {
        background-color: #f1f5f9;
    }

    .topbar-title { 
        font-size: 12px; 
        font-weight: 700; 
        color: #1e293b;
        flex: 1;
        text-align: center;
        margin: 0 12px;
    }

    .topbar-actions {
        display: flex;
        gap: 6px;
        align-items: center;
        flex-wrap: wrap; /* Allow actions to wrap on small screens */
    }

    .topbar-search {
        background: none;
        border: none;
        font-size: 12px;
        cursor: pointer;
        padding: 6px;
        border-radius: 5px;
        flex: 1; /* Allow search to grow */
        min-width: 0; /* Remove min-width for mobile */
    }

    .topbar-search:hover {
        background-color: #f1f5f9;
    }

    /* Stats grid mobile optimization */
    .stats-grid { 
        grid-template-columns: 1fr; 
        gap: 8px; 
        margin-bottom: 16px;
    }

    .stat-card { 
        padding: 14px 16px; 
        min-height: 80px; /* Ensure minimum height */
    }

    .stat-card h3 { 
        font-size: 12px; 
        margin-bottom: 8px;
    }

    .stat-card p  { 
        font-size: 16px; 
        line-height: 1.2; /* Better readability */
    }

    /* Table mobile optimization */
    .table-section { 
        padding: 14px; 
        overflow-x: auto; /* Enable horizontal scrolling */
    }

    .table-section h2 { 
        font-size: 14px; 
        margin-bottom: 8px;
    }

    .custom-table { 
        min-width: 600px; /* Smaller minimum for mobile */
        font-size: 12px; /* Smaller font for mobile */
    }

    .custom-table th, .custom-table td,
        table th, table td { 
        padding: 6px 8px; /* Smaller padding */
        font-size: 12px; /* Smaller font */
    }

    .page-title { 
        font-size: 18px; /* Slightly smaller for mobile */
        margin-bottom: 16px;
    }

    .modal-content { 
        margin: 8px auto; 
        padding: 16px; 
        width: 95%; /* Wider on mobile */
        max-height: 80vh; /* Limit height on mobile */
    }

    .btn, .btn-add, .btn-submit { 
        width: 100%; 
        justify-content: center; 
        padding: 12px; /* Larger touch targets */
        font-size: 14px; /* Larger font for mobile */
    }

    .btn-cancel { 
        width: 100%; 
        margin-left: 0; 
        margin-top: 8px; 
        justify-content: center; 
        padding: 12px; /* Larger touch targets */
        font-size: 14px; /* Larger font for mobile */
    }

    /* Ensure all interactive elements are properly sized for touch */
    .btn, .btn-add, .btn-submit, .btn-cancel {
        min-height: 44px; /* iOS touch target size */
    }

    /* Better mobile navigation */
    .nav-item, .nav-item.sub-item {
        min-height: 44px; /* iOS touch target size */
        align-items: center;
    }

    /* Fix mobile viewport issues */
    body {
        -webkit-text-size-adjust: 100%; /* Prevent iOS zoom */
        -ms-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    /* Ensure content is visible */
    .main-content > * {
        opacity: 1 !important; /* Ensure content is visible */
        visibility: visible !important;
    }
}

/* ============================================================
   UNIFIED STATISTICS BOXES
   ============================================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
    height: 100%;
}

.stat-card {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    height: 100%;
    min-height: 120px;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.stat-card.primary {
    background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
    color: white;
}

.stat-card.success {
    background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
    color: white;
}

.stat-card.warning {
    background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
    color: white;
}

.stat-card.danger {
    background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
    color: white;
}

.stat-card.info {
    background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
    color: white;
}

.stat-icon {
    width: 4rem;
    height: 4rem;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-card:not(.primary):not(.success):not(.warning):not(.danger):not(.info) .stat-icon {
    background: #3b82f6;
    color: white;
}

.stat-content {
    flex: 1;
    min-width: 0;
}

.stat-content h3 {
    margin: 0 0 0.5rem 0;
    font-size: 0.875rem;
    font-weight: 500;
    opacity: 1;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-content p {
    margin: 0 0 0.5rem 0;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    color: white;
}

.stat-card.primary .stat-content h3,
.stat-card.success .stat-content h3,
.stat-card.warning .stat-content h3,
.stat-card.danger .stat-content h3,
.stat-card.info .stat-content h3 {
    color: white !important;
}

.stat-card.primary .stat-icon,
.stat-card.success .stat-icon,
.stat-card.warning .stat-icon,
.stat-card.danger .stat-icon,
.stat-card.info .stat-icon {
    background: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
}

.stat-change {
    font-size: 0.75rem;
    font-weight: 500;
    opacity: 1;
    color: white;
}

.stat-change.positive::before {
    content: '↑ ';
}

.stat-change.negative::before {
    content: '↓ ';
}

.stat-change.neutral::before {
    content: '→ ';
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1rem;
        min-height: 100px;
    }
    
    .stat-icon {
        width: 3rem;
        height: 3rem;
        font-size: 1.25rem;
    }
    
    .stat-content p {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   MOBILE SIDEBAR FUNCTIONALITY
============================================================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
        z-index: 1001;
    }
    
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
    }
    
    .sidebar.open .logo-text,
    .sidebar.open .nav-item span,
    .sidebar.open .logout-btn span,
    .sidebar.open .sidebar-user-info,
    .sidebar.open .dropdown-arrow {
        display: block !important;
    }
    
    .sidebar.open .nav-item {
        justify-content: flex-start !important;
        padding: 8px 16px !important;
        gap: 10px !important;
    }
    
    .sidebar.open .sidebar-header {
        justify-content: space-between !important;
        padding: 12px !important;
    }
    
    .sidebar.open .logout-btn {
        justify-content: flex-start !important;
        padding: 10px 16px !important;
        gap: 12px !important;
    }
    
    .sidebar.open .sidebar-user {
        justify-content: flex-start !important;
        padding: 12px 18px !important;
        gap: 10px !important;
    }
    
    .sidebar.open .dropdown-menu {
        display: block !important;
        max-height: 400px !important;
    }
    
    .sidebar.collapsed {
        width: var(--sidebar-width) !important;
        transform: translateX(-100%);
    }
    
    .sidebar.collapsed.open {
        transform: translateX(0);
    }
}

/* Overlay untuk mobile sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* Prevent body scroll when sidebar is open on mobile */
.sidebar.open ~ .main-content {
    pointer-events: none;
}

/* Touch gesture indicators */
@media (max-width: 768px) {
    .sidebar {
        -webkit-overflow-scrolling: touch;
    }
    
    body.is-swiping {
        overflow: hidden;
    }
    
    body.is-swiping .sidebar {
        transition: none;
    }
    
    body.is-swiping .sidebar-overlay {
        transition: none;
    }
}

/* Improved transitions for smooth mobile experience */
@media (max-width: 768px) {
    .sidebar {
        will-change: transform;
        -webkit-transform: translateX(-100%);
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        -webkit-transform: translateX(0);
        transform: translateX(0);
    }
    
    .sidebar-overlay {
        will-change: opacity;
    }
}
