/* ========================================
   CATEGORIES SIDEBAR (Fixed Left)
   ======================================== */

/* Ensure header is always above sidebar */
.header,
header,
#mainHeader {
    position: sticky !important;
    top: 0 !important;
    z-index: 1000 !important;
}

.categories-sidebar {
    position: fixed;
    left: 0;
    top: 80px; /* Below header */
    width: 280px;
    height: calc(100vh - 80px);
    background: #ffffff;
    border-right: 2px solid #e8ecf1;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.08);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100; /* Below header (header is z-index 1000) */
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.categories-sidebar.hidden {
    transform: translateX(-100%);
}

/* Sidebar Header */
.categories-sidebar .sidebar-header {
    padding: 35px 20px 25px 20px; /* More space at top */
    background: #ffffff;
    border-bottom: 2px solid #e8ecf1;
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.categories-sidebar .sidebar-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 10px;
}

.categories-sidebar .sidebar-header h3 i {
    font-size: 1rem;
    color: #e74c3c;
}

/* Sidebar Toggle Button (Hide Sidebar) */
.sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    color: #e74c3c;
    cursor: pointer;
    width: 35px;
    height: 35px;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 1rem;
}

.sidebar-toggle-btn:hover {
    background: #e74c3c;
    color: white;
    border-color: #e74c3c;
    transform: scale(1.05);
}

.sidebar-close-btn {
    display: none; /* Only show on mobile */
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #95a5a6;
    cursor: pointer;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.sidebar-close-btn:hover {
    background: #e9ecef;
    color: #e74c3c;
}

/* Sidebar Show Button (When Hidden) */
.sidebar-show-btn {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    background: #e74c3c;
    border: none;
    color: white;
    width: 40px;
    height: 60px;
    border-radius: 0 10px 10px 0;
    cursor: pointer;
    z-index: 90; /* Below header */
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 4px 0 15px rgba(231, 76, 60, 0.3);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1.1rem;
}

.sidebar-show-btn:hover {
    background: #c0392b;
    width: 45px;
    box-shadow: 6px 0 20px rgba(231, 76, 60, 0.5);
}

.sidebar-show-btn.visible {
    display: flex;
}

/* Categories List */
.categories-list {
    list-style: none;
    padding: 15px 0;
    margin: 0;
}

.category-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 25px;
    color: #495057;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    border-bottom: 1px solid #f1f3f5;
    position: relative;
}

.category-item i {
    font-size: 1.1rem;
    color: #95a5a6;
    transition: all 0.2s ease;
    width: 20px;
    text-align: center;
}

.category-item:hover {
    background: #f8f9fa;
    border-left-color: #e74c3c;
    color: #2c3e50;
}

.category-item:hover i {
    color: #e74c3c;
    transform: scale(1.1);
}

.category-item.active {
    background: linear-gradient(90deg, rgba(231, 76, 60, 0.1) 0%, rgba(255, 255, 255, 0) 100%);
    border-left-color: #e74c3c;
    color: #e74c3c;
    font-weight: 600;
}

.category-item.active i {
    color: #e74c3c;
}

/* Scrollbar Styling */
.categories-sidebar::-webkit-scrollbar {
    width: 6px;
}

.categories-sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.categories-sidebar::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.categories-sidebar::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Main Container Adjustment */
.main-container {
    margin-left: 280px;
    margin-right: 0;
    transition: margin 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
                width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
                max-width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Main Content - Smooth transition with scale */
.main-content {
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
                width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    will-change: transform, opacity;
}

/* Centered when sidebar is hidden */
.main-container.centered {
    margin-left: auto;
    margin-right: auto;
    max-width: 1400px;
    padding-left: 20px;
    padding-right: 20px;
}

/* Centered content - Smooth scale animation */
.main-container.centered .main-content {
    animation: expandContent 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Not centered - return to normal */
.main-container:not(.centered) .main-content {
    animation: contractContent 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes expandContent {
    0% {
        transform: scale(0.98);
        opacity: 0.95;
    }
    50% {
        transform: scale(1.01);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes contractContent {
    0% {
        transform: scale(1.01);
        opacity: 1;
    }
    50% {
        transform: scale(0.99);
        opacity: 0.98;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Hero Section - Smooth width expansion */
.hero-section {
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

.main-container.centered .hero-section {
    animation: breathe 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes breathe {
    0% {
        transform: scale(0.98);
    }
    50% {
        transform: scale(1.02);
    }
    100% {
        transform: scale(1);
    }
}

/* Footer adjustment when sidebar is visible */
footer {
    margin-left: 280px;
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

footer.centered {
    margin-left: auto;
    margin-right: auto;
    max-width: 1400px;
    padding-left: 20px;
    padding-right: 20px;
}

/* Sidebar Overlay (Mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999; /* Below sidebar (1000) but above everything else */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ========================================
   RESPONSIVE
   ======================================== */

/* Tablet */
@media (max-width: 1024px) {
    .categories-sidebar {
        width: 260px;
    }
    
    .main-container {
        margin-left: 260px;
    }
    
    .category-item {
        padding: 12px 20px;
        font-size: 0.9rem;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .categories-sidebar {
        transform: translateX(-100%);
        top: 0;
        height: 100vh;
        width: 300px;
        z-index: 1000;
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.2);
    }
    
    .categories-sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar-toggle-btn {
        display: none; /* Hide toggle on mobile, only show X */
    }
    
    .sidebar-close-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .sidebar-show-btn {
        display: none !important; /* No show button on mobile */
    }
    
    .main-container,
    .main-container.centered {
        margin-left: 0 !important;
        margin-right: 0 !important;
        max-width: 100%;
        padding-left: 0;
        padding-right: 0;
    }
    
    footer,
    footer.centered {
        margin-left: 0 !important;
        margin-right: 0 !important;
        max-width: 100%;
        padding-left: 0;
        padding-right: 0;
    }
}

@media (max-width: 480px) {
    .categories-sidebar {
        width: 280px;
    }
    
    .category-item {
        padding: 12px 18px;
        font-size: 0.85rem;
    }
}
