/* ========================================
   SIDEBAR COMPONENT - RESPONSIVE
======================================== */

/* Default Sidebar Styles */
.sidebar,
#sidebar {
    width: 220px;
    max-width: 90vw;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: #fff;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1000;
    transition: transform 0.35s cubic-bezier(.4,1.3,.5,1), background 0.3s;
    box-shadow: 2px 0 20px rgba(36,113,243,0.12);
    border-radius: 0 15px 15px 0;
    border-right: 1.5px solid rgba(106,130,251,0.13);
    overflow: hidden;
}

.sidebar.collapsed {
    transform: translateX(-110%);
}

.logo {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    text-align: left;
    color: #fff;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 8px rgba(36,113,243,0.10);
    padding: 0.5rem 0;
    padding-left: 3rem; /* Tambah padding kiri agar tidak tertutup toggle button di mobile */
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    justify-content: flex-start;
}

.menu a {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem;
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.25s cubic-bezier(.4,1.3,.5,1);
    font-weight: 500;
    font-size: 0.9rem;
    background: rgba(255,255,255,0.08);
}

.menu a:hover,
.menu a.active {
    background: rgba(255,255,255,0.18);
    color: #fff;
    transform: translateX(3px);
    box-shadow: 0 2px 10px rgba(36,113,243,0.08);
}

.menu a i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.logout-btn {
    background: #dc3545;
    color: #fff;
    border: none;
    padding: 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(.4,1.3,.5,1);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-weight: 600;
    margin-top: 1rem;
    box-shadow: 0 2px 10px rgba(220,53,69,0.25);
    font-size: 0.9rem;
}

.logout-btn:hover {
    background: #c82333;
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 4px 15px rgba(220,53,69,0.35);
}

/* Mobile & Tablet: sidebar lebih ramping, padding kecil, logo center, menu rapat, logout tetap di bawah, tidak terlalu panjang */
@media (max-width: 991.98px) {
    .sidebar {
        width: 80vw;
        max-width: 220px;
        padding: 0.7rem 0.4rem 0.7rem 0.4rem;
        border-radius: 0 12px 12px 0;
        max-height: 95vh;
        height: auto;
        top: 2vh;
        bottom: auto;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        overflow-y: auto;
    }
    .logo {
        text-align: center;
        margin-bottom: 0.7rem;
        font-size: 1rem;
    }
    .menu {
        gap: 0.3rem;
    }
    .menu a {
        padding: 0.5rem 0.5rem;
        font-size: 0.92rem;
    }
    .logout-btn {
        margin-top: 0.7rem;
        padding: 0.5rem 0.5rem;
        font-size: 0.92rem;
    }
}

@media (max-width: 767.98px) {
    .sidebar {
        width: 90vw;
        max-width: 180px;
        padding: 0.5rem 0.2rem 0.5rem 0.2rem;
        border-radius: 0 8px 8px 0;
        max-height: 92vh;
    }
    .logo {
        font-size: 0.95rem;
        margin-bottom: 0.5rem;
    }
    .menu a {
        padding: 0.4rem 0.3rem;
        font-size: 0.85rem;
    }
    .logout-btn {
        padding: 0.4rem 0.3rem;
        font-size: 0.85rem;
    }
}

/* Sidebar transisi lebih smooth */
.sidebar,
.sidebar-overlay {
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), background 0.3s, opacity 0.3s;
}

/* ========================================
   RESPONSIVE MEDIA QUERIES - SIDEBAR
======================================== */

/* Large devices (laptops/desktops, 992px and up) */
@media (max-width: 1199.98px) {
    .sidebar {
        width: 200px;
        padding: 1.5rem 1rem;
        border-radius: 0 20px 20px 0;
    }
    .logo {
        font-size: 1.5rem;
        margin-bottom: 2rem;
    }
    .menu a {
        padding: 0.9rem 0.8rem;
        font-size: 0.97rem;
    }
    .menu a i {
        font-size: 1.1rem;
    }
    .logout-btn {
        padding: 0.9rem 0.8rem;
        font-size: 0.97rem;
    }
}

/* iPad specific (768px x 1024px) */
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
    .sidebar {
        width: 260px;
        padding: 1.7rem 1.2rem;
        border-radius: 0 22px 22px 0;
        top: 2vh;
        height: 96vh;
    }
    .logo {
        font-size: 1.4rem;
    }
    .menu a {
        padding: 0.95rem 0.8rem;
        font-size: 0.97rem;
        min-height: 44px; /* iOS touch target minimum */
    }
    .menu a i {
        font-size: 1.1rem;
    }
    .logout-btn {
        min-height: 44px;
        padding: 0.95rem 0.8rem;
        font-size: 0.97rem;
    }
    .sidebar-toggle {
        padding: 1rem;
        font-size: 1.2rem;
        min-height: 44px;
        min-width: 44px;
    }
    .sidebar.open ~ .sidebar-toggle {
        left: 270px;
    }
}

/* Landscape orientation adjustments */
@media (orientation: landscape) and (max-height: 500px) {
    .sidebar {
        padding: 0.5rem 0.2rem;
        top: 0.5vh;
        height: 98vh;
    }
    .logo {
        font-size: 0.8rem;
        margin-bottom: 0.7rem;
    }
    .menu {
        gap: 0.2rem;
    }
    .menu a {
        padding: 0.4rem 0.2rem;
        font-size: 0.7rem;
    }
    .menu a i {
        font-size: 0.7rem;
    }
    .logout-btn {
        padding: 0.4rem 0.2rem;
        font-size: 0.7rem;
    }
}

/* Touch devices - better touch targets */
@media (hover: none) and (pointer: coarse) {
    .menu a {
        min-height: 48px;
        padding: 1rem;
    }
    .logout-btn {
        min-height: 48px;
    }
    .sidebar-toggle {
        min-height: 48px;
        min-width: 48px;
    }
    /* Disable hover effects on touch devices */
    .menu a:hover,
    .logout-btn:hover,
    .sidebar-toggle:hover {
        transform: none;
        box-shadow: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .sidebar {
        border-right: 3px solid #000;
    }
    .menu a {
        border: 1px solid rgba(255, 255, 255, 0.3);
    }
    .menu a.active {
        border: 2px solid #fff;
    }
    .logout-btn {
        border: 2px solid rgba(255, 255, 255, 0.5);
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .sidebar-toggle,
    .sidebar-overlay,
    .menu a,
    .logout-btn {
        transition: none;
    }
}

/* Desktop - reset logo padding */
@media (min-width: 992px) {
    .logo {
        padding-left: 0; /* Reset padding di desktop */
    }
}

/* Global Logout Button Styling - Override semua warna agar konsisten merah */
.logout-btn {
    background: #dc3545 !important;
    color: #fff !important;
}

.logout-btn:hover {
    background: #c82333 !important;
    box-shadow: 0 4px 15px rgba(220,53,69,0.35) !important;
}

.logout-btn:active {
    background: #bd2130 !important;
}
