:root {
    --primary: #2c3e50;
    --secondary: #27ae60;
    --danger: #e74c3c;
    --warning: #f39c12;
    --bg-light: #ecf0f1;
    --text-dark: #333;
    --white: #fff;
    --sidebar-width: 260px;
}

/* ================= RESET & DASAR ================= */
* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
}
body { 
    background-color: var(--bg-light); 
    color: var(--text-dark); 
    display: flex; 
    overflow-x: hidden; 
    width: 100%;
}

/* ================= SIDEBAR ================= */
#sidebar {
    width: var(--sidebar-width);
    background: var(--primary);
    color: var(--white);
    min-height: 100vh;
    transition: all 0.3s ease;
    position: fixed;
    z-index: 1000;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
}
#sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-width)); }
#sidebar .logo { padding: 20px; font-size: 1.5rem; font-weight: bold; border-bottom: 1px solid rgba(255,255,255,0.1); letter-spacing: 1px; }
#sidebar ul { list-style: none; padding: 10px 0; }
#sidebar ul li a { display: block; padding: 15px 20px; color: var(--white); text-decoration: none; transition: 0.2s; font-size: 0.95rem; }
#sidebar ul li a:hover { background: rgba(255,255,255,0.1); border-left: 4px solid var(--secondary); padding-left: 16px; }

/* ================= MAIN CONTENT & TOPBAR ================= */
#main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    transition: all 0.3s ease;
    min-height: 100vh;
    padding-bottom: 50px;
}
#main-content.expanded { margin-left: 0; width: 100%; }

.topbar { 
    background: var(--white); 
    padding: 15px 20px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); 
    position: sticky; 
    top: 0; 
    z-index: 998; 
}
.burger-btn { font-size: 1.5rem; cursor: pointer; background: none; border: none; color: var(--primary); padding: 5px; }

/* ================= DASHBOARD GRID & CARDS ================= */
.dashboard-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); 
    gap: 20px; 
    padding: 20px; 
}
.card { 
    background: var(--white); 
    border-radius: 8px; 
    padding: 20px; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.05); 
    border-top: 4px solid var(--primary); 
    transition: transform 0.2s; 
    width: 100%;
    max-width: 100%;
}
.card:hover { transform: translateY(-2px); }
.card.danger { border-top-color: var(--danger); }
.card.success { border-top-color: var(--secondary); }
.card.warning { border-top-color: var(--warning); }
.card h3 { margin-bottom: 10px; font-size: 1.2rem; color: var(--primary); }

/* ================= BUTTONS ================= */
.btn { 
    padding: 10px 15px; 
    border: none; 
    border-radius: 5px; 
    cursor: pointer; 
    color: var(--white); 
    font-weight: bold; 
    text-decoration: none; 
    display: inline-block; 
    transition: opacity 0.2s; 
    text-align: center; 
}
.btn:hover { opacity: 0.9; }
.btn-primary { background: var(--primary); }
.btn-success { background: var(--secondary); }
.btn-danger { background: var(--danger); }
.btn-warning { background: var(--warning); color: #fff; }

/* ================= FORMS & INPUT ================= */
.form-group { margin-bottom: 15px; width: 100%; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 0.95rem; color: #444; }
.form-control { 
    width: 100%; 
    padding: 10px 12px; 
    border: 1px solid #ccc; 
    border-radius: 4px; 
    transition: border 0.3s; 
    font-size: 0.95rem; 
    box-sizing: border-box; 
}
.form-control:focus { border-color: var(--primary); outline: none; }
textarea.form-control { resize: vertical; }

/* ================= TABEL DEFAULT LAPTOP ================= */
table { 
    width: 100%; 
    border-collapse: collapse; 
}
th, td { padding: 12px 15px; border-bottom: 1px solid #eee; text-align: left; }
th { background-color: var(--primary); color: white; font-weight: 500; }
tr:hover { background-color: #fdfdfd; }

/* ================= MODAL ZOOM / LIGHTBOX ================= */
.modal { display: none; position: fixed; z-index: 9999; padding-top: 20px; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.9); overflow: auto; }
.modal-content { margin: auto; display: block; max-width: 95%; max-height: 90vh; object-fit: contain; cursor: grab; transition: transform 0.2s; }
.modal-content:active { cursor: grabbing; }
.close-modal { position: absolute; top: 15px; right: 25px; color: #f1f1f1; font-size: 40px; font-weight: bold; cursor: pointer; z-index: 10000; }
.close-modal:hover, .close-modal:focus { color: #bbb; text-decoration: none; cursor: pointer; }

/* ================= RESPONSIVE MOBILE (SMARTPHONES) ================= */
@media (max-width: 768px) {
    /* 1. Sidebar & Layar Penuh */
    #sidebar { margin-left: calc(-1 * var(--sidebar-width)); }
    #sidebar.mobile-open { margin-left: 0; box-shadow: 5px 0 15px rgba(0,0,0,0.5); }
    #main-content { margin-left: 0; width: 100%; max-width: 100vw; }
    
    /* 2. Grid & Card Constraints */
    .dashboard-grid { grid-template-columns: 1fr !important; padding: 10px; gap: 15px; }
    .card { padding: 15px; width: 100%; overflow: hidden; } 
    
    /* 3. Menyusun Form Berjejer Menjadi Kebawah */
    div[style*="display:flex"], div[style*="display: flex"] {
        flex-direction: column !important;
        gap: 15px !important;
    }
    form[style*="display:flex"], form[style*="display: flex"], form[style*="display:grid"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
    }
    
    /* 4. SOLUSI MUTLAK UNTUK TABEL YANG TERPOTONG */
    table {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        border: 1px solid #eee;
        border-radius: 5px;
    }
    th, td {
        white-space: nowrap !important; /* Memaksa teks tidak turun, sehingga memicu scroll bar menyamping */
        padding: 10px 15px !important;
    }

    /* 5. Mencegah Tombol di Dalam Tabel Ikut Melebar */
    td form { display: flex !important; flex-direction: row !important; gap: 5px !important; }
    td .btn { padding: 8px 10px !important; font-size: 0.85rem !important; flex: none !important; }
    
    /* 6. Anti-Zoom iOS pada Input */
    input, select, textarea { font-size: 16px !important; width: 100% !important; }
    
    /* 7. Memastikan Teks Panjang Terpotong Rapi (Misal: Link) */
    td, p, span, a, small { word-break: break-word; }
}