/* ============================================
   LAC Category Sidebar - Premium Design
   ============================================ */

/* Main Sidebar Container */
.lac-category-sidebar {
    background: linear-gradient(to bottom, #ffffff 0%, #fafbfc 100%) !important;
    border-radius: 12px !important;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.04),
        0 2px 8px rgba(0, 0, 0, 0.04),
        0 8px 24px rgba(0, 0, 0, 0.06) !important;
    overflow: visible !important;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", sans-serif !important;
    max-width: 100% !important;
    width: 100% !important;
    position: relative !important;
    transition: box-shadow 0.3s ease;
}

.lac-category-sidebar:hover {
    box-shadow:
        0 0 0 1px rgba(0, 121, 243, 0.1),
        0 4px 12px rgba(0, 0, 0, 0.06),
        0 12px 32px rgba(0, 0, 0, 0.08) !important;
}

/* Hide Header */
.lac-sidebar-header {
    display: none !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Navigation */
.lac-sidebar-nav {
    padding: 6px !important;
    margin: 0 !important;
    overflow: visible !important;
}

/* Reset Lists */
.lac-category-list {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Level 1 - Main Categories (Visible) */
.lac-level-1 {
    display: block !important;
    position: relative !important;
    overflow: visible !important;
}

/* Level 2 & 3 - Flyout Panels with Grid */
.lac-level-2,
.lac-level-3 {
    display: none;
    position: fixed;
    min-width: 340px;
    max-width: 900px;
    width: auto;
    background: #ffffff;
    border-radius: 12px;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.06),
        0 12px 40px rgba(0, 0, 0, 0.12),
        0 24px 80px rgba(0, 0, 0, 0.15);
    padding: 16px;
    z-index: 999999;

    /* Grid Layout */
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 6px;
    max-height: 85vh;
    overflow-y: auto;

    /* Animations */
    animation: lacFlyoutAppear 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: left center;
}

/* Adjust grid based on item count */
.lac-level-2[data-item-count="1"],
.lac-level-2[data-item-count="2"],
.lac-level-2[data-item-count="3"] {
    grid-template-columns: 1fr;
    min-width: 280px;
}

.lac-level-2[data-item-count="4"],
.lac-level-2[data-item-count="5"],
.lac-level-2[data-item-count="6"],
.lac-level-2[data-item-count="7"],
.lac-level-2[data-item-count="8"] {
    grid-template-columns: repeat(2, 1fr);
    min-width: 520px;
}

.lac-level-3[data-item-count="1"],
.lac-level-3[data-item-count="2"],
.lac-level-3[data-item-count="3"] {
    grid-template-columns: 1fr;
    min-width: 280px;
}

/* Show on Hover */
.lac-category-item:hover > .lac-level-2,
.lac-category-item:hover > .lac-level-3 {
    display: grid !important;
}

/* Flyout Appear Animation */
@keyframes lacFlyoutAppear {
    from {
        opacity: 0;
        transform: translateX(-12px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* Category Items */
.lac-category-item {
    position: relative;
    background: transparent;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 0;
    border-radius: 8px;
}

/* Level 1 Items (Main Categories) */
.lac-level-1 > .lac-category-item {
    overflow: visible;
    margin: 3px 0;
}

.lac-level-1 > .lac-category-item:first-child {
    margin-top: 0;
}

.lac-level-1 > .lac-category-item:last-child {
    margin-bottom: 0;
}

.lac-level-1 > .lac-category-item:not(:last-child)::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 16px;
    right: 16px;
    height: 1px;
    background: linear-gradient(to right,
        transparent,
        rgba(0, 0, 0, 0.06) 20%,
        rgba(0, 0, 0, 0.06) 80%,
        transparent);
}

/* Level 2 & 3 Items (Grid Children) */
.lac-level-2 .lac-category-item,
.lac-level-3 .lac-category-item {
    border-radius: 8px;
    margin: 0;
    border: none;
}

/* Hover States */
.lac-level-1 > .lac-category-item:hover {
    background: linear-gradient(to right,
        rgba(0, 121, 243, 0.04),
        rgba(0, 121, 243, 0.06),
        rgba(0, 121, 243, 0.04));
    transform: translateX(2px);
}

.lac-level-2 .lac-category-item:hover,
.lac-level-3 .lac-category-item:hover {
    background: linear-gradient(135deg,
        rgba(0, 121, 243, 0.08),
        rgba(0, 121, 243, 0.04));
    transform: translateY(-1px);
}

/* Active/Current State */
.lac-level-1 > .lac-category-item.current-cat,
.lac-level-1 > .lac-category-item.current-cat-parent {
    background: linear-gradient(to right,
        rgba(0, 121, 243, 0.08),
        rgba(0, 121, 243, 0.12),
        rgba(0, 121, 243, 0.08));
    border-left: 3px solid #0079f3;
    padding-left: 3px;
}

/* Category Header */
.lac-category-header {
    display: flex;
    align-items: center;
    padding: 0;
    cursor: pointer;
    position: relative;
}

.lac-level-1 > .lac-category-item > .lac-category-header {
    padding: 15px 18px;
}

.lac-level-2 .lac-category-header,
.lac-level-3 .lac-category-header {
    padding: 10px 14px;
}

/* Chevron Indicator for Items with Children */
.lac-level-1 > .lac-category-item.has-children > .lac-category-header::after,
.lac-level-2 > .lac-category-item.has-children > .lac-category-header::after {
    content: "";
    position: absolute;
    right: 18px;
    width: 7px;
    height: 7px;
    border-top: 2.5px solid #0079f3;
    border-right: 2.5px solid #0079f3;
    transform: rotate(45deg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.6;
}

.lac-level-1 > .lac-category-item.has-children:hover > .lac-category-header::after,
.lac-level-2 > .lac-category-item.has-children:hover > .lac-category-header::after {
    right: 16px;
    opacity: 1;
    transform: rotate(45deg) scale(1.1);
}

/* Category Link */
.lac-category-link {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-decoration: none;
    color: #1d1d1f;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: -0.02em;
    gap: 12px;
}

.lac-level-1 > .lac-category-item > .lac-category-header .lac-category-link {
    font-size: 15.5px;
    font-weight: 500;
}

.lac-category-link:hover {
    color: #0079f3;
}

.lac-level-2 .lac-category-link {
    font-size: 14px;
    font-weight: 500;
}

.lac-level-3 .lac-category-link {
    font-size: 13px;
    font-weight: 400;
    color: #424245;
}

/* Category Name */
.lac-category-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 8px;
}

/* Category Count Badge */
.lac-category-count {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 700;
    color: #6b7280;
    background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
    padding: 3px 8px;
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    letter-spacing: 0.02em;
}

.lac-category-link:hover .lac-category-count {
    background: linear-gradient(135deg, #0079f3, #0066d6);
    color: #ffffff;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 121, 243, 0.3);
}

.lac-category-item.current-cat .lac-category-count,
.lac-category-item.current-cat-parent .lac-category-count {
    background: linear-gradient(135deg, #0079f3, #0066d6);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 121, 243, 0.3);
}

/* Current Category Highlighting */
.lac-category-item.current-cat > .lac-category-header .lac-category-link,
.lac-category-item.current-cat-parent > .lac-category-header .lac-category-link {
    color: #0079f3;
    font-weight: 600;
}

/* Scrollbar Styling */
.lac-sidebar-nav {
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - 200px);
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 121, 243, 0.3) transparent;
}

.lac-sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.lac-sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.lac-sidebar-nav::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom,
        rgba(0, 121, 243, 0.3),
        rgba(0, 121, 243, 0.5));
    border-radius: 3px;
}

.lac-sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom,
        rgba(0, 121, 243, 0.5),
        rgba(0, 121, 243, 0.7));
}

/* Flyout Scrollbar */
.lac-level-2::-webkit-scrollbar,
.lac-level-3::-webkit-scrollbar {
    width: 8px;
}

.lac-level-2::-webkit-scrollbar-thumb,
.lac-level-3::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #d1d5db, #9ca3af);
    border-radius: 4px;
}

.lac-level-2::-webkit-scrollbar-thumb:hover,
.lac-level-3::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #9ca3af, #6b7280);
}

/* Prevent Text Selection */
.lac-category-link {
    user-select: none;
    -webkit-user-select: none;
}

/* Mobile Styles */
@media (max-width: 1024px) {
    .lac-category-sidebar {
        border-radius: 10px !important;
    }

    .lac-sidebar-nav {
        padding: 4px !important;
    }

    .lac-level-2,
    .lac-level-3 {
        position: static;
        display: block !important;
        box-shadow: none;
        padding: 0 0 0 16px;
        border-left: 3px solid #e5e7eb;
        margin-top: 6px;
        margin-left: 16px;
        background: transparent;
        min-width: auto;
        max-width: none;
        grid-template-columns: 1fr;
        animation: none;
    }

    .lac-level-2 .lac-category-item,
    .lac-level-3 .lac-category-item {
        margin: 2px 0;
    }

    .lac-category-item.has-children > .lac-category-header::after {
        transform: rotate(135deg);
        border-color: #6b7280;
    }

    .lac-category-item.is-expanded > .lac-category-header::after {
        transform: rotate(45deg);
        border-color: #0079f3;
    }

    .lac-category-item:hover > .lac-level-2,
    .lac-category-item:hover > .lac-level-3 {
        display: none !important;
    }

    .lac-category-item.is-expanded > .lac-level-2,
    .lac-category-item.is-expanded > .lac-level-3 {
        display: block !important;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .lac-category-sidebar,
    .lac-category-item,
    .lac-category-link,
    .lac-category-count,
    .lac-level-2,
    .lac-level-3 {
        animation: none !important;
        transition: none !important;
    }
}

/* Print Styles */
@media print {
    .lac-category-sidebar {
        box-shadow: none !important;
        border: 1px solid #000;
    }

    .lac-level-2,
    .lac-level-3 {
        position: static !important;
        display: block !important;
        box-shadow: none !important;
    }

    .lac-category-item.has-children > .lac-category-header::after {
        display: none !important;
    }
}
