/* assets/css/style.css - vFinal Mobile Fix */

/* --- 1. SETUP ASAS --- */
:root {
    --primary: #4f46e5;
    --primary-bg: #e0e7ff;
    --sidebar-width: 270px;
    --bottom-nav-height: 70px;
    --radius: 12px;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: #f1f5f9;
    color: #1e293b;
    overflow-x: hidden;
    padding-bottom: calc(var(--bottom-nav-height) + 20px);
}

/* --- 2. SIDEBAR MODEN (DESKTOP & MOBILE DRAWER) --- */
.sidebar {
    position: fixed; top: 0; left: 0; height: 100vh;
    width: var(--sidebar-width);
    background: #ffffff;
    z-index: 1060; /* Lebih tinggi dari Bottom Nav (1050) */
    display: flex; flex-direction: column;
    border-right: 1px solid #e2e8f0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Logo Area */
.sidebar-header {
    padding: 1.5rem;
    flex-shrink: 0; /* Jangan kecut */
}

/* Scrollable Menu Area */
.sidebar-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0 1rem;
    /* Custom Scrollbar */
    scrollbar-width: thin;
}

/* Footer Area (Logout) - Sentiasa di bawah */
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid #f1f5f9;
    background: #ffffff;
    flex-shrink: 0; /* Jangan kecut */
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

/* --- 3. MENU ITEMS (FORCE RECTANGULAR) --- */
.nav-pills .nav-link {
    border-radius: var(--radius) !important; /* Paksa bucu bulat kecil */
    padding: 0.8rem 1rem;
    margin-bottom: 4px;
    color: #64748b;
    font-weight: 500;
    display: flex; align-items: center;
    transition: all 0.2s;
}

.nav-pills .nav-link i {
    font-size: 1.25rem; margin-right: 12px; width: 24px; text-align: center;
}

.nav-pills .nav-link:hover {
    background-color: #f8fafc; color: var(--primary);
}

.nav-pills .nav-link.active {
    background-color: var(--primary);
    color: white !important;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3);
}

/* --- 4. MOBILE BEHAVIOR (< 992px) --- */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%); /* Sorok kiri */
        box-shadow: none;
    }
    
    .sidebar.show {
        transform: translateX(0); /* Masuk */
        box-shadow: 10px 0 30px rgba(0,0,0,0.2);
    }

    .main-content {
        margin-left: 0; padding: 1rem;
    }

    /* Overlay Gelap */
    #sidebar-overlay {
        position: fixed; top: 0; left: 0; width: 100%; height: 100%;
        background: rgba(15, 23, 42, 0.5);
        z-index: 1055; /* Bawah sikit dari Sidebar */
        backdrop-filter: blur(2px);
        display: none;
    }
    #sidebar-overlay.show { display: block; }
}

/* --- 5. MAIN CONTENT (DESKTOP) --- */
@media (min-width: 992px) {
    .main-content { margin-left: var(--sidebar-width); padding: 2rem; }
    #sidebar-overlay { display: none !important; }
}

/* --- 6. MOBILE BOTTOM NAV --- */
.mobile-bottom-nav {
    display: none;
}

@media (max-width: 991.98px) {
    .mobile-bottom-nav {
        display: flex; justify-content: space-around; align-items: center;
        position: fixed; bottom: 0; left: 0; width: 100%;
        height: var(--bottom-nav-height);
        background: #ffffff;
        border-top: 1px solid #e2e8f0;
        z-index: 1050;
        padding-bottom: env(safe-area-inset-bottom);
        box-shadow: 0 -5px 20px rgba(0,0,0,0.03);
    }

    .bottom-nav-item {
        color: #94a3b8;
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        font-size: 0.7rem; font-weight: 500; width: 100%; height: 100%;
        text-decoration: none;
    }
    .bottom-nav-item i { font-size: 1.4rem; margin-bottom: 2px; }
    .bottom-nav-item.active { color: var(--primary); }
}

/* --- 7. DARK MODE --- */
[data-bs-theme="dark"] body { background-color: #0f172a; color: #f8fafc; }
[data-bs-theme="dark"] .sidebar, [data-bs-theme="dark"] .mobile-bottom-nav, [data-bs-theme="dark"] .sidebar-footer { 
    background-color: #1e293b; border-color: #334155; 
}
[data-bs-theme="dark"] .nav-link { color: #cbd5e1; }
[data-bs-theme="dark"] .nav-link:hover { background-color: #334155; }
[data-bs-theme="dark"] .nav-link.active { background-color: var(--primary); color: white; }
[data-bs-theme="dark"] .card { background-color: #1e293b; border: 1px solid #334155; }

/* --- 8. PRINT RULES (ASAL) --- */
@media print {
    .sidebar, .mobile-bottom-nav, .navbar-toggler, #theme-toggle-mobile,
    .d-md-none.sticky-top, #sidebar-overlay, .fab-add, .fab-save-container,
    .wizard-footer, #mode-selection, .modal { display: none !important; }
    
    body, .main-content, .card { 
        background: white !important; color: black !important; margin: 0 !important; padding: 0 !important; border: none !important; box-shadow: none !important; width: 100% !important;
    }
}