/* Global Category Sidebar: Studio Premium Design */

:root {
    --sidebar-width: 420px;
    --sidebar-transition: cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-bg: rgba(255, 255, 255, 0.98);
    --sidebar-border-radius: 1.5rem;
}

@media (max-width: 1440px) {
    :root {
        --sidebar-width: 380px;
    }
}

@media (max-width: 1024px) {
    :root {
        --sidebar-width: 340px;
    }
}

/* Container & Background Overlay */
.category-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s var(--sidebar-transition), visibility 0.4s;
}

.category-sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Sidebar Drawer */
.category-sidebar-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    box-shadow: none; /* Removed default shadow to prevent bleed into viewport when closed */
    z-index: 2000;
    transform: translateX(-100%);
    transition: transform 0.4s var(--sidebar-transition);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.category-sidebar-drawer.active {
    transform: translateX(0);
    box-shadow: 20px 0 50px rgba(0, 0, 0, 0.15);
}

/* Header Section */
.category-sidebar-header {
    padding: 24px;
    border-bottom: 1px solid #f1f5f9;
    background: #ffffff;
}

.sidebar-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.sidebar-title {
    font-size: 14px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-title .highlight {
    color: #DB4E39;
}

.sidebar-close-btn {
    background: #f8fafc;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: all 0.2s;
    cursor: pointer;
}

.sidebar-close-btn:hover {
    background: #fee2e2;
    color: #b91c1c;
    transform: rotate(90deg);
}

/* Search Bar */
.sidebar-search-container {
    position: relative;
}

.sidebar-search-input {
    width: 100%;
    padding: 12px 16px 12px 42px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-size: 14px;
    color: #1e293b;
    transition: all 0.3s;
}

.sidebar-search-input:focus {
    outline: none;
    border-color: #DB4E39;
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(219, 78, 57, 0.1);
}

.sidebar-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 18px;
}

.sidebar-search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: #e2e8f0;
    border: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 10px;
}

.sidebar-search-clear:hover {
    background: #fee2e2;
    color: #b91c1c;
}

/* Categories List/Tree */
.category-sidebar-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 16px 0;
    background: #ffffff;
}

/* Custom Scrollbar */
.category-sidebar-body::-webkit-scrollbar {
    width: 5px;
}

.category-sidebar-body::-webkit-scrollbar-track {
    background: transparent;
}

.category-sidebar-body::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

/* Recursive Accordion Styles (Shared and Independent) */
.drawer-cat-list,
.aside-cat-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.drawer-cat-item,
.aside-cat-item {
    border-bottom: 1px solid #f8fafc;
}

.drawer-cat-header,
.aside-cat-header {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    gap: 12px;
}

.drawer-cat-header.has-chevron,
.aside-cat-header.has-chevron {
    gap: 12px;
}

.cat-label-link {
    flex-grow: 1;
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
    gap: 12px;
}

.drawer-cat-header:hover .cat-label,
.aside-cat-header:hover .cat-label {
    color: #DB4E39;
}


.drawer-cat-header:hover,
.aside-cat-header:hover {
    background: #fff8f8;
}

.cat-icon-container {
    width: 28px;
    height: 28px;
    background: #f1f5f9;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: all 0.3s;
    flex-shrink: 0;
}

.cat-icon-container i {
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.drawer-cat-header:hover .cat-icon-container,
.aside-cat-header:hover .cat-icon-container {
    background: #fee2e2;
    color: #DB4E39;
}

.cat-label {
    flex-grow: 1;
    font-size: 14.5px;
    font-weight: 600;
    color: #334155;
}

.cat-toggle-icon {
    font-size: 16px;
    color: #94a3b8;
    transition: transform 0.3s;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    margin-left: auto;
}

.drawer-cat-item.expanded > .drawer-cat-header .cat-toggle-icon,
.aside-cat-item.expanded > .aside-cat-header .cat-toggle-icon {
    transform: rotate(180deg);
}

.drawer-cat-item.active > .drawer-cat-header,
.aside-cat-item.active > .aside-cat-header {
    background: #fff5f5;
    border-left: none; /* Removed physical border to prevent text shift */
    box-shadow: inset 4px 0 0 #DB4E39, inset 5px 0 10px rgba(219, 78, 57, 0.05); /* Simulates border without layout impact */
}

.drawer-cat-item.active > .drawer-cat-header .cat-label,
.aside-cat-item.active > .aside-cat-header .cat-label {
    color: #DB4E39;
    font-weight: 700;
}

.drawer-cat-item.active > .drawer-cat-header .cat-toggle-icon,
.aside-cat-item.active > .aside-cat-header .cat-toggle-icon {
    color: #DB4E39;
}

/* Sub-levels indenting */
.drawer-sub-list,
.aside-sub-list {
    background: #fbfcfd;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.drawer-cat-item.expanded > .drawer-sub-list,
.aside-cat-item.expanded > .aside-sub-list {
    max-height: 3500px; /* High value for smooth expansion */
}

.level-2 .drawer-cat-header,
.level-2 .aside-cat-header {
    padding-left: 54px;
    background: rgba(248, 250, 252, 0.4);
}

.level-3 .drawer-cat-header,
.level-3 .aside-cat-header {
    padding-left: 84px;
    font-size: 13px;
    color: #64748b;
}

.level-3 .cat-label {
    font-weight: 500;
}

/* 3rd Level Arrow Transition (Watch Hand Style) */
.level-3 .cat-toggle-icon {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), color 0.3s;
    transform: rotate(-30deg); /* Initial "5% / 5-min" position */
}

.level-3 .drawer-cat-header:hover .cat-toggle-icon,
.level-3 .aside-cat-header:hover .cat-toggle-icon {
    transform: rotate(0deg); /* Hover "15% / 15-min" position (Right) */
    color: #DB4E39;
}

/* Empty State */
.sidebar-empty-state {
    padding: 60px 40px;
    text-align: center;
    color: #94a3b8;
}

.sidebar-empty-state i {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.3;
}

/* Loading State */
.sidebar-loading-state {
    padding: 60px 40px;
    text-align: center;
    color: #94a3b8;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.drawer-loading-state {
    padding: 60px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    color: #64748b;
}

.drawer-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(219, 78, 57, 0.1);
    border-radius: 50%;
    border-top-color: #DB4E39;
    animation: drawer-spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes drawer-spin {
    to { transform: rotate(360deg); }
}

/* Mobile & Tablet Adjustments */
@media (max-width: 1024px) {
    .category-sidebar-drawer {
        width: 100%;
        max-width: 100%;
    }
    .category-sidebar-popup {
        display: none !important; /* Hide popup on tablets/mobile, use click-to-expand instead */
    }
    .drawer-cat-header {
        padding: 12px 20px;
    }
    /* On mobile, make the entire Level 2 row tappable to toggle subcats */
    .level-2 .drawer-cat-header.has-chevron {
        cursor: pointer;
    }
    .level-2 .drawer-cat-header.has-chevron .cat-label-link {
        pointer-events: none; /* Disable link so the whole row toggles */
        flex-grow: 1;
    }
    /* View category link shown only on mobile inside expanded sub-list */
    .mobile-view-cat-link {
        display: flex !important;
    }
}

@media (max-width: 480px) {
    .drawer-cat-header .cat-label {
        font-size: 13.5px;
    }
    .category-sidebar-header {
        padding: 16px;
    }
}

/* 4K and 2K Screen Optimization */
@media (min-width: 2560px) {
    :root {
        --sidebar-width: 550px;
    }
    .drawer-cat-header .cat-label {
        font-size: 18px;
    }
    .drawer-cat-header {
        padding: 20px 40px;
    }
}

@media (min-width: 3840px) {
    :root {
        --sidebar-width: 750px;
    }
    .drawer-cat-header .cat-label {
        font-size: 24px;
    }
    .drawer-cat-header {
        padding: 30px 60px;
    }
    .cat-icon-container {
        width: 48px;
        height: 48px;
    }
}

/* Mega-Hover Popup Panel */
.category-sidebar-popup {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    width: min(750px, calc(100vw - var(--sidebar-width)));
    height: 100vh;
    background: #ffffff;
    box-shadow: 20px 0 60px rgba(0, 0, 0, 0.1);
    z-index: 2001; /* Must be higher than overlay (1999) */
    display: flex;
    flex-direction: column;
    padding: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-20px);
    transition: all 0.4s var(--sidebar-transition);
    border-left: 1px solid #f1f5f9;
}

.category-sidebar-popup.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.popup-header {
    padding: 30px 40px;
    text-align: center;
    border-bottom: 1px solid #f8fafc;
}

.popup-parent-name {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.4;
}

.popup-body {
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 30px;
}

/* Discovery Grid */
.popup-discovery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
}

.grid-item-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    text-decoration: none;
    padding: 15px;
    border-radius: 16px;
    transition: all 0.3s;
    border: 1px solid transparent;
}

.grid-item-card:hover {
    background: #f8fafc;
    border-color: #e2e8f0;
    transform: translateY(-5px);
}

.card-img-wrapper {
    width: 180px;
    height: 180px;
    background: #ffffff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    overflow: hidden;
    padding: 10px;
}

.card-img-wrapper img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.3s;
}

.grid-item-card:hover .card-img-wrapper img {
    transform: scale(1.1);
}

.card-title {
    font-size: 13.5px;
    font-weight: 400;
    color: #475569;
    line-height: 1.4;
}

.grid-item-card:hover .card-title {
    color: #DB4E39;
}

/* Premium Leaf Category Discovery View (Split-Catalog Layout) */
.leaf-category-discovery {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    height: 100%;
    padding: 60px 40px; /* Generous breathing room */
}

.leaf-card {
    display: flex; /* Split layout */
    align-items: center;
    gap: 40px;
    background: transparent;
    padding: 0;
    text-align: left; /* Aligned left for split */
    max-width: 650px;
    transition: all 0.4s ease;
    border: none;
}

.leaf-img-container {
    flex-shrink: 0;
    width: 200px; /* Restored size for split balance */
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(8px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    padding: 20px;
}

.leaf-img-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.leaf-content {
    flex-grow: 1;
}

.leaf-content h3 {
    font-size: 16px; /* Scaled down title */
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 6px;
    letter-spacing: -0.2px;
    line-height: 1.2;
}

.leaf-content p {
    font-size: 12px; /* Scaled down description */
    color: #64748b;
    max-width: 250px;
    margin-bottom: 16px;
    line-height: 1.4;
}

.btn-shop-collection {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #DB4E39;
    color: #ffffff;
    padding: 8px 18px; /* Compact padding */
    border-radius: 8px;
    font-weight: 700;
    font-size: 12px; /* Small font size */
    text-decoration: none;
    transition: all 0.3s;
}

    transition: all 0.3s;
}

.btn-shop-collection:hover {
    background: #c23d2a;
    transform: scale(1.05);
    color: #ffffff;
}

.btn-shop-collection i {
    font-size: 14px;
    transition: transform 0.3s;
}

.btn-shop-collection:hover i {
    transform: translateX(5px);
}
