/* CSS Dasar untuk Dashboard */
:root {
    --primary: #ee4d2d;
    --dark: #2c3e50;
    --light: #f4f6f9;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
}

body {
    font-family: 'Segoe UI', sans-serif;
    margin: 0;
    padding: 0;
    background: var(--light);
}

.sidebar {
    width: 250px;
    height: 100vh;
    background: var(--dark);
    color: white;
    position: fixed;
    left: 0;
    top: 0;
    padding: 20px 0;
    z-index: 50; /* Lower than modals (SweetAlert uses 1060+) */
}

.sidebar h2 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 18px;
    border-bottom: 1px solid #444;
    padding-bottom: 20px;
}

.nav-item {
    padding: 15px 25px;
    display: block;
    color: #ddd;
    text-decoration: none;
    transition: 0.3s;
}

.nav-item:hover, .nav-item.active {
    background: var(--primary);
    color: white;
}

.sidebar .nav-item.active-parent {
    background-color: #3e5165; /* Slightly different color for parent */
    color: white;
}

 .sidebar .has-submenu + .submenu {
    display: none;
    padding: 5px 0;
    background-color: #1a252f;
}

.sidebar .submenu a {
    padding: 12px 25px 12px 45px;
    display: block;
    color: #abbbc2;
    text-decoration: none;
    font-size: 13px;
    transition: 0.3s;
}

.sidebar .submenu a:hover, .sidebar .submenu a.active {
    color: white;
    background: rgba(238, 77, 45, 0.1);
    border-left: 3px solid var(--primary);
}

.sidebar .has-submenu + .submenu.open {
    display: block;
}

 .sidebar .submenu-toggler {
     float: right;
     display: inline-block;
     width: 16px;
     text-align: center;
 }
 
 .sidebar .submenu-toggler::after {
     content: '▼';
     font-size: 0.8em;
     transition: transform 0.3s;
     display: inline-block;
 }
 
 .sidebar .has-submenu.active-parent .submenu-toggler::after {
     transform: rotate(180deg);
 }

.main-content {
    margin-left: 250px;
    padding: 20px;
    transition: all 0.3s ease;
}

/* --- UTILITY CLASSES FOR RESPONSIVE FORMS --- */
.responsive-form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

@media (max-width: 600px) {
    .responsive-form-grid {
        grid-template-columns: 1fr !important;
    }
}

.header {
    background: white;
    padding: 15px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    overflow: hidden; /* Prevent visual overflow */
}

/* --- GRID SYSTEM --- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

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

@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
        padding: 15px;
    }
    
    .sidebar {
        transform: translateX(-100%);
        z-index: 1000;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .card-grid {
        grid-template-columns: 1fr;
    }
}

.card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    border: 1px solid #f0f0f0;
    transition: transform 0.2s;
}

.card:hover {
    transform: translateY(-2px);
}

.card h3 {
    margin-top: 0;
    color: #7f8c8d;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 15px;
}

.card .value {
    font-size: 28px;
    font-weight: 800;
    color: var(--dark);
    display: block;
    margin-bottom: 5px;
}

.card .sub-value {
    font-size: 13px;
    color: #95a5a6;
}

/* --- STAT CARD WITH ICON --- */
.stat-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.alert-box {
    background: #fff3cd;
    border-left: 5px solid var(--warning);
    padding: 15px;
    margin-bottom: 10px;
}

.btn {
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background: var(--primary);
    color: white;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

th, td {
    padding: 10px;
    border-bottom: 1px solid #eee;
    text-align: left;
}

/* --- RESPONSIVE IMPROVEMENTS --- */

/* Sidebar Toggle UI */
.sidebar-toggle {
    display: none; 
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1010;
    background: var(--dark);
    color: white;
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 8px;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.sidebar-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.sidebar-toggle.active {
    background: var(--primary);
}

.sidebar-toggle.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.sidebar-toggle.active span:nth-child(2) { opacity: 0; transform: translateX(-10px); }
.sidebar-toggle.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(3px);
}

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

/* Table Wrapper for Horizontal Scroll */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 15px;
    border-radius: 8px;
    border: 1px solid #eee;
}

.table-responsive table {
    margin-top: 0;
    min-width: 600px; /* Force scroll on small screens */
}

/* --- MOBILE MEDIA QUERY (FORCEFUL) --- */
@media (max-width: 768px) {
    .sidebar {
        left: -280px !important;
        width: 260px !important;
        z-index: 1050 !important; /* High, but still lower than SweetAlert (1060) */
        transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1) !important;
    }
    
    .sidebar.active {
        transform: translateX(280px) !important;
        box-shadow: 5px 0 25px rgba(0,0,0,0.3) !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 15px !important;
        padding-top: 80px !important;
        padding-bottom: 100px !important; /* Extra space for bottom elements */
    }

    .sidebar-toggle {
        display: flex !important;
    }

    .card {
        padding: 15px !important;
        margin-bottom: 15px !important;
    }

    .header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
        padding: 15px !important;
    }

    .card-grid {
        grid-template-columns: 1fr !important;
    }

    /* Force tables to scroll */
    .table-responsive {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
    }
}

/* Scroll mode for very long vertical content */
.scroll-vertical {
    max-height: 500px;
    overflow-y: auto;
    padding-right: 5px;
}

.scroll-vertical::-webkit-scrollbar {
    width: 6px;
}

.scroll-vertical::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

/* --- LOCKED FEATURE STYLES --- */
.nav-item.locked {
    opacity: 0.5;
    filter: grayscale(1);
    cursor: pointer;
    position: relative;
    background: rgba(0,0,0,0.2);
    pointer-events: auto !important;
}

.nav-item.locked::after {
    content: '🔒';
    position: absolute;
    right: 15px;
    font-size: 12px;
}

/* --- SWEETALERT OVERRIDE --- */
.swal2-container {
    z-index: 9999 !important; /* Always on top of everything */
}
