/* ENHANCED SHADCN-UI DESIGN SYSTEM */

/* Filter Bar Container */
.filter-bar-premium {
    background: #fff;
    padding: 15px 20px;
    margin: 0 auto 30px auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
    /* border: 1px solid #eee; */
    border-radius: 12px;
    position: relative;
    max-width: 85%;
    /* FIX: High z-index for the bar itself to establish stacking context */
    z-index: 1000;
}

.filter-group-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Filter Pills - Core Component */
.filter-pill {
    background: #ffffff;
    border: 1.5px dashed #e4e4e7;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 13.5px;
    color: #09090b;
    cursor: pointer;
    transition: all 0.15s ease-out;
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    height: 34px;
    letter-spacing: -0.01em;
}

.filter-pill:hover {
    background: #fafafa;
    border-color: #d4d4d8;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.filter-pill.active {
    background: #f4f4f5;
    border: 1.5px solid #09090b;
    border-style: solid;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.filter-pill.active:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}

/* Dropdown Menus - Enhanced Depth */
.filter-dropdown-menu {
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1),
        0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border: 1px solid #e4e4e7;
    padding: 16px;
    min-width: 260px;
    margin-top: 8px;
    /* FIX: Very high z-index to ensure it floats above menu/table headers */
    z-index: 99999 !important;
    background: #ffffff;
    animation: slideDown 0.15s ease-out;
    position: absolute;
    /* Find reliable positioning */
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Dropdown Headings */
.filter-dropdown-menu h5 {
    font-size: 14px;
    font-weight: 600;
    color: #09090b;
    letter-spacing: -0.01em;
    margin-top: 0;
}

/* Separator */
.filter-separator {
    height: 20px;
    width: 1px;
    background: #e4e4e7;
    margin: 0 12px;
    opacity: 0.8;
}

/* Global Apply Button */
.btn-apply-global {
    background: #09090b;
    color: #ffffff;
    border-radius: 8px;
    font-weight: 500;
    border: none;
    padding: 6px 16px;
    font-size: 13.5px;
    letter-spacing: -0.01em;
    transition: all 0.15s ease-out;
    cursor: pointer;
    height: 34px;
    display: inline-flex;
    align-items: center;
}

.btn-apply-global:hover {
    background: #27272a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-apply-global:active {
    transform: translateY(0);
}

/* Apply Button - Premium Feel (Inside Dropdown) */
.btn-apply {
    background: #09090b;
    color: #ffffff;
    border-radius: 8px;
    font-weight: 500;
    border: none;
    padding: 10px 0;
    margin-top: 12px;
    width: 100%;
    font-size: 13.5px;
    letter-spacing: -0.01em;
    transition: all 0.15s ease-out;
    cursor: pointer;
}

.btn-apply:hover {
    background: #18181b;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}

.btn-apply:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Badge Counter - Refined */
.filter-badge-count {
    background: #09090b;
    color: #ffffff;
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 10.5px;
    height: 18px;
    min-width: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* Price Inputs */
.price-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.price-inputs input {
    width: 100%;
    border-radius: 8px;
    border: 1.5px solid #e4e4e7;
    padding: 9px 12px;
    font-size: 13.5px;
    color: #09090b;
    transition: all 0.15s ease-out;
}

.price-inputs input:focus {
    outline: none;
    border-color: #a1a1aa;
    box-shadow: 0 0 0 3px rgba(161, 161, 170, 0.1);
}

.price-inputs input::placeholder {
    color: #a1a1aa;
}

/* Filter Items - Color & Size */
.color-check-item,
.size-check-item {
    display: flex;
    align-items: center;
    padding: 10px 6px;
    cursor: pointer;
    margin: 0;
    font-weight: 400;
    border-radius: 6px;
    transition: all 0.12s ease-out;
    font-size: 13.5px;
    color: #09090b;
    width: 100%;
    /* Full width for clickable area */
}

/* Hide default checkbox */
.color-check-item input,
.size-check-item input {
    display: none;
}

.color-check-item:hover,
.size-check-item:hover {
    background: #f4f4f5;
}

.color-check-item:active,
.size-check-item:active {
    background: #e4e4e7;
}

/* Selected State Highlighting */
.color-check-item input:checked~.color-dot {
    box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #09090b;
    border-color: #09090b;
}

.color-check-item input:checked~span {
    font-weight: 600;
}

.size-check-item input:checked~span {
    font-weight: 600;
    color: #09090b;
}

.size-check-item:has(input:checked),
.color-check-item:has(input:checked) {
    background-color: #f4f4f5;
}

/* Sort Item Styling */
.sort-item {
    display: block;
    padding: 8px 12px;
    font-size: 13.5px;
    color: #09090b;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.12s ease-out;
}

.sort-item:hover {
    background: #f4f4f5;
    color: #000;
    text-decoration: none;
}

/* Color Dot Enhancement */
.color-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1.5px solid #e4e4e7;
    transition: all 0.15s ease-out;
    margin-right: 12px;
    /* Spacing */
    flex-shrink: 0;
}

.color-check-item:hover .color-dot {
    border-color: #d4d4d8;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

/* Active Tags Section */
.active-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
    width: 100%;
}

.active-tag {
    background: #f0f0f0;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.active-tag i {
    cursor: pointer;
    font-size: 10px;
}

/* Clear Links */
a[href*="Clear"],
a[href*="Reset"] {
    transition: all 0.15s ease-out;
}

a[href*="Clear"]:hover,
a[href*="Reset"]:hover {
    color: #09090b !important;
    text-decoration: none !important;
}

/* Mobile Responsiveness & Drawer */
@media (max-width: 768px) {
    .filter-bar-premium {
        max-width: 100%;
        padding: 10px 15px;
        border-radius: 0;
        border: none;
        border-bottom: 1px solid #eee;
        margin-bottom: 20px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
    }

    /* Mobile Trigger Button */
    .mobile-filter-trigger {
        display: flex;
        align-items: center;
        gap: 8px;
        background: #09090b;
        color: white;
        border: none;
        padding: 8px 16px;
        border-radius: 8px;
        font-size: 13.5px;
        font-weight: 500;
        cursor: pointer;
    }

    /* Sort Section on Mobile */
    .filter-group-right {
        flex: 1;
        display: flex;
        justify-content: flex-end;
    }

    .filter-group-right .dropdown {
        width: auto;
        /* Let it size naturally */
    }

    .filter-group-right .filter-pill {
        width: auto;
        min-width: 140px;
    }

    /* Hide Desktop Label */
    .desktop-filter-label {
        display: none !important;
    }

    /* The Drawer (Full Screen Overlay) */
    .filter-group-left {
        position: fixed;
        top: 140px;
        left: 0;
        width: 100%;
        height: 100vh;
        background: #ffffff !important;
        /* Force white */
        z-index: 9999999;
        /* Highest Z-Index */
        padding: 0;
        border-radius: 0;
        transform: translateY(100%);
        /* Start hidden (slide up) */
        transition: transform 0.3s ease-in-out;
        display: flex;
        flex-direction: column;
        gap: 0;
        max-height: none;
        overflow-y: auto;
        align-items: stretch !important;
        /* Fix: Override desktop center alignment */
    }

    /* Active Drawer State */
    .filter-group-left.mobile-active {
        transform: translateY(0);
        bottom: auto;
    }

    /* Remove old overlay */
    .filter-group-left.mobile-active::before {
        display: none;
    }

    /* We handle backdrop close via JS or a separate element better, but for now purely CSS visual */

    /* Drawer Header */
    .mobile-drawer-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin: 0;
        border-bottom: 1px solid #f4f4f5;
        padding: 20px 25px;
        width: 100%;
        /* Ensure full width */
        /* Add padding here since container is 0 */
    }

    .mobile-drawer-header h5 {
        font-size: 18px;
        font-weight: 700;
        margin: 0;
        color: #09090b;
    }

    /* FIX: Ensure dropdown containers specific width */
    .filter-group-left .dropdown,
    .filter-group-left .mobile-filter-wrapper {
        width: 100% !important;
        display: block !important;
        margin: 0 !important;
        position: relative;
        /* Ensure positioning context */
    }

    .close-drawer {
        background: none;
        border: none;
        font-size: 24px;
        padding: 0;
        cursor: pointer;
        color: #71717a;
    }

    /* Make pills look like accordion headers in drawer */
    .filter-pill {
        width: 100%;
        justify-content: space-between;
        height: auto;
        /* Let it grow */
        background: #ffffff !important;
        /* Force White */
        border: none;
        border-bottom: 1px solid #f4f4f5;
        border-radius: 0;
        font-size: 16px;
        /* Larger font */
        padding: 18px 25px;
        /* Comfortable touch area */
        margin: 0;
        font-weight: 500;
    }

    .filter-pill:hover,
    .filter-pill.active {
        background: #ffffff !important;
        /* Keep White */
        transform: none;
        box-shadow: none;
        border-bottom: 1px solid #f4f4f5;
    }

    /* Embedded Dropdown Content */
    .filter-dropdown-menu {
        position: static !important;
        width: 100% !important;
        box-shadow: none;
        border: none;
        margin: 0;
        padding: 10px 25px 30px 25px;
        /* Indent content */
        display: none;
        background: #ffffff !important;
        /* Force white */
        border-radius: 0;
    }

    /* When open in drawer (Support BS3 .open, BS4 .show, and Custom .mobile-open) */
    .dropdown.open .filter-dropdown-menu,
    .dropdown.show .filter-dropdown-menu,
    .filter-dropdown-menu.show,
    .mobile-filter-wrapper.mobile-open .filter-dropdown-menu {
        display: block;
        animation: none;
        /* No slide animation inside list */
    }

    /* Hide specific desktop elements in drawer */
    .filter-separator {
        display: none;
    }

    .filter-badge-count {
        font-size: 12px;
        padding: 4px 8px;
        background: #f4f4f5;
        color: #09090b;
    }

    /* Larger Checkboxes for Touch */
    .color-check-item,
    .size-check-item {
        padding: 14px 0;
        /* Larger tap area */
        font-size: 15px;
    }

    /* Sticky Apply Button Logic (optional, but good for UX) */
    /* For now, just explicit full width styling */
    /* Apply Button Container */
    .mobile-apply-container {
        padding: 20px 25px;
        border-top: 1px solid #f4f4f5;
        margin-top: auto;
        /* Push to bottom if flex container has height */
    }

    .btn-apply-global {
        width: 90%;
        margin: auto;
        justify-content: center;
        height: 52px;
        margin-top: 20px;
        margin-bottom: 20px;
        font-size: 16px;
        font-weight: 600;
        background: #09090b;
        color: white;
        border-radius: 12px;
    }

    /* Reset Link Styling in Drawer */
    a[href*="Reset"] {
        display: block;
        text-align: center;
        padding: 15px;
        color: #71717a;
    }
}

/* Base styles for new elements (hidden on desktop) */
@media (min-width: 769px) {
    .mobile-filter-trigger {
        display: none;
    }

    .mobile-drawer-header {
        display: none;
    }
}

/* Pill Layout Update */
.filter-pill {
    justify-content: space-between !important;
    /* Force text left, arrow right */
    width: 100%;
    /* Ensure full width for spacing */
}

/* Chevron Animation */
.pill-arrow {
    transition: transform 0.25s ease;
    will-change: transform;
}

/* Rotate on Desktop (Bootstrap 'open' class) */
.dropdown.open .pill-arrow,
/* Rotate on Mobile (Custom 'expanded' class) */
.filter-pill.expanded .pill-arrow {
    transform: rotate(180deg);
}

/* Reset Button Style */
.reset-filters-btn:hover {
    text-decoration: none;
    opacity: 0.8;
}

html.no-scroll,
body.no-scroll {
    overflow: hidden !important;
    height: 100% !important;
    /* Lock height to prevent scroll jank */
    touch-action: none;
    /* Disable touch on body */
}

/* NUCLEAR OPTION: Force Kill Backdrop on Mobile */
@media (max-width: 768px) {
    .dropdown-backdrop {
        display: none !important;
        z-index: -1000 !important;
        opacity: 0 !important;
        width: 0 !important;
        height: 0 !important;
        pointer-events: none !important;
    }
}