/**
 * Product Filters - Styles
 * 
 * Desktop and mobile responsive styles for product filtering system
 */

/* ==========================================================================
   Filter Panel - Desktop
   ========================================================================== */

.product-filters {
    position: relative;
}

.product-filters__mobile-toggle {
    display: none; /* Hidden on desktop */
}

.product-filters__panel {
    display: block; /* FIXED: Explicitly show on desktop */
    border-radius: 4px;
    padding: 0;
}

.product-filters__mobile-header {
    display: none; /* Hidden on desktop */
}

.product-filters__content {
    padding: 0;
    display: grid;
    gap: 10px !important;
}

/* Mobile mode - add padding-bottom to prevent footer overlap */
.product-filters.mobile-mode .product-filters__content,
body > .product-filters__panel.mobile-mode-panel .product-filters__content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 20px;
}

/* ==========================================================================
   Filter Groups
   ========================================================================== */

.filter-group {
    border-bottom: 1px solid #f0f0f0;
    background-color: #ffffff;
    border-radius: 5px;
    padding: 15px;
    margin: 0px 0px;
}

.filter-group:last-child {
    margin-bottom: 0;
    padding-bottom: 15px;
    border-bottom: none;
}

.breakdance .filter-group .filter-group__title h5 {
    font-size: 16px !important;
    font-weight: 600;
    margin: 0 0 15px 0;
    color: #333;
}

/* Even more specific override for Breakdance */
.breakdance .product-filters .filter-group .filter-group__title h5,
.breakdance h5.filter-group__title,
.product-filters__panel .filter-group__title h5 {
    font-size: 16px !important;
    font-weight: 600 !important;
}

/* Direct target: h5 element that HAS the filter-group__title class */
.breakdance .filter-group h5.filter-group__title,
.breakdance .product-filters h5.filter-group__title,
body .breakdance h5.filter-group__title {
    font-size: 16px !important;
    font-weight: 600 !important;
    margin: 0 !important;
    color: #333 !important;
    font-family: inherit !important;
}

/* Accordion functionality */
.filter-group__title {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    cursor: pointer !important;
    user-select: none !important;
    transition: color 0.2s ease !important;
    padding: 0 !important;
    margin-bottom: 15px !important;
}

.filter-group__title:hover {
    color: #253473 !important;
}

/* Override Breakdance specificity for accordion */
.breakdance .filter-group h5.filter-group__title,
.breakdance .product-filters h5.filter-group__title,
.product-filters__panel h5.filter-group__title {
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
}

/* Category Nav Filter - No accordion, always expanded */
.filter-group--category-nav .filter-group__title {
    cursor: default !important;
    pointer-events: none;
}

.filter-group--category-nav .filter-group__title:hover {
    color: inherit !important;
}

.filter-group--category-nav .filter-group__content {
    max-height: none !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    overflow: visible !important;
}

.filter-group__title .title-text {
    flex: 1;
}

.filter-group__title .title-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-left: 8px;
    transition: transform 0.3s ease;
    color: #666;
}

/* Collapsed state - arrow points down */
.filter-group.is-collapsed .filter-group__title .title-arrow {
    transform: rotate(0deg);
}

/* Collapsed content */
.filter-group.is-collapsed .filter-group__content {
    max-height: 0 !important;
    opacity: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
    transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease !important;
}

/* Ensure collapsed content is not clickable */
.filter-group.is-collapsed .filter-group__content {
    pointer-events: none;
}

.filter-group:not(.is-collapsed) .filter-group__content {
    pointer-events: auto;
    transition: max-height 0.3s ease, opacity 0.3s ease !important;
}

/* FIXED: Show filter content on all devices (responsive control via Breakdance) */

/* Before JS runs, show all content (no transition) */
body:not(.product-filters-js-loaded) .filter-group__content:not(.filter-group__scrollable) {
    max-height: 2000px !important;
    opacity: 1 !important;
    overflow: visible !important;
    transition: none !important; /* No flash during load */
}

/* Before JS runs, scrollable content keeps scroll */
body:not(.product-filters-js-loaded) .filter-group__content.filter-group__scrollable {
    max-height: 200px !important;
    opacity: 1 !important;
    overflow-y: auto !important;
    transition: none !important; /* No flash during load */
}

/* After JS loads, enable smooth transitions */
body.product-filters-js-loaded .filter-group__content:not(.filter-group__scrollable) {
    max-height: 2000px;
    opacity: 1;
    overflow: visible;
    transition: max-height 0.3s ease, opacity 0.3s ease !important;
}

/* Scrollable content keeps its scroll behavior */
body.product-filters-js-loaded .filter-group__content.filter-group__scrollable {
    max-height: 200px !important; /* Keep scrollable max-height */
    opacity: 1 !important;
    overflow-y: auto !important; /* Keep scroll */
    transition: max-height 0.3s ease, opacity 0.3s ease !important;
    margin-top: 15px;
}

/* After JS adds/removes is-collapsed, respect it */
body.product-filters-js-loaded .filter-group.is-collapsed .filter-group__content {
    max-height: 0 !important;
    opacity: 0 !important;
    overflow: hidden !important;
}

/* Fix for collapsed title margin */
.filter-group.is-collapsed .filter-group__title {
    margin-bottom: 0 !important;
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
    opacity: 1;
    margin-top: 15px;
}

.filter-group__scrollable {
    min-height: 0;
    max-height: 200px !important; /* Force max-height */
    overflow-y: auto !important; /* Force scroll */
    align-content: flex-start;
    margin-top: 0; /* Remove margin to avoid spacing issues */
}

/* Custom scrollbar */
.filter-group__scrollable::-webkit-scrollbar {
    width: 6px;
}

.filter-group__scrollable::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.filter-group__scrollable::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

.filter-group__scrollable::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ==========================================================================
   Price Range Filter
   ========================================================================== */

.filter-group--price .filter-group__content {
    gap: 15px;
}

.price-range-slider {
    margin: 10px 5px 0px;
}

/* noUiSlider customization */
.price-range-slider .noUi-target {
    background: #FAFAFA;
    border-radius: 4px;
    border: 0px solid #D3D3D3 !important;
    box-shadow: none !important;
}

.price-range-slider .noUi-connect {
    background: #253473;
    height: 7px;
}

.price-range-slider .noUi-base {
    height: 2px;
    background-color: #ececec;
}

.price-range-slider .noUi-handle {
    width: 20px;
    height: 20px;
    border: 2px solid #253473;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: none;
    top: -9px;
}

.price-range-slider .noUi-handle:hover {
    background: #f5f5f5;
}

.price-range-slider .noUi-handle:before,
.price-range-slider .noUi-handle:after {
    display: none;
}

.price-range-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.price-input-wrapper {
    position: relative;
}

.price-input-wrapper label {
    display: block;
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
}

.price-input-wrapper input {
    width: 100%;
    padding: 8px 30px 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.price-input-wrapper .currency {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    margin-top: 10px;
    color: #666;
    font-size: 14px;
    pointer-events: none;
}

/* ==========================================================================
   Checkboxes
   ========================================================================== */

.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 5px 10px;
    transition: background-color 0.2s;
    background-color: #ffffff;
}

.filter-checkbox:hover {
    background-color: #f9f9f9;
}

.filter-checkbox input[type="checkbox"] {
    width: 31px;
    height: 31px;
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    border: 1px solid #ceb49f;
    border-radius: 4px;
    background-color: #fff;
    position: relative;
    transition: all 0.3s ease;
}

.filter-checkbox input[type="checkbox"]:hover {
    border-color: #b89d7f;
}

.filter-checkbox input[type="checkbox"]:checked {
    background-color: #ceb49f;
    border-color: #ceb49f;
}

.filter-checkbox input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 10px;
    top: 5px;
    width: 8px;
    height: 14px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.filter-checkbox .checkbox-label {
    flex: 1;
    font-size: 14px;
    color: #333;
}

.filter-checkbox .filter-count {
    margin-left: 5px;
    font-size: 13px;
    color: #999;
    font-weight: 400;
}

/* Brand checkboxes with images */
.filter-checkbox--brand {
    gap: 10px;
}

.filter-checkbox--brand .brand-image {
    width: 32px;
    height: 32px;
    object-fit: contain;
    flex-shrink: 0;
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 2px;
}

/* ==========================================================================
   Category Nav Filter (from theme)
   ========================================================================== */

.cat-nav-filter { 
    width: 100%; 
}

.cat-nav-filter-list { 
    list-style: none; 
    margin: 0; 
    padding: 0; 
}

.cat-nav-item { 
    margin: 0; 
    padding: 0; 
}

.cat-nav-item a {
    display: block;
    padding: 15px 0px;
    font-size: 14px;
    color: #333 !important;
    font-weight: 600;
    text-decoration: none;
    line-height: 1.4;
    transition: color 0.15s ease;
}

.cat-nav-item a:hover { 
    color: #000; 
}

.cat-nav-item.cat-nav-current > a { 
    font-weight: 700; 
    color: #000; 
}

.cat-nav-item.cat-nav-parent > a { 
    font-weight: 600; 
    color: #555; 
    font-size: 13px; 
}

.cat-nav-item.cat-nav-parent > a:hover { 
    color: #000; 
}

.cat-nav-hr {
    border: none;
    border-top: 1px solid #e8e8e8;
    margin: 0;
}

/* ==========================================================================
   Filter Chips
   ========================================================================== */

.product-filters-chips {
    margin-bottom: 0px;
}

.filters-chips__container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    background: #F5F1F1;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: #333;
}

.filter-chip .chip-label {
    line-height: 1;
}

.filter-chip .chip-remove {
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    color: #666;
    width: 20px;
    height: 19px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.filter-chip .chip-remove:hover {
    background: #ddd;
    color: #333;
}

.filters-chips__clear-all {
    background: #F5F1F1;
    border: 1px solid #ff564f !important;
    color: #000000;
    border: none;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.filters-chips__clear-all:hover {
    background: #a4a4a4;
}

/* ==========================================================================
   Loading State (Skeleton Loader)
   ========================================================================== */

/* NOTE: Base .bde-skeleton styles are provided by unified-skeleton.css */
/* This section only contains layout-specific overrides for product filters */

/* Loading State - Make products semi-transparent during AJAX */
.products.is-loading {
    position: relative;
    opacity: 0.2;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* Skeleton Loader Container - Absolute positioned overlay (LEGACY FALLBACK) */
/* Used only when unified skeleton loader is not available */
.product-skeleton-loader {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    background: #ffffff;
    padding: 0;
    min-height: 600px;
}

.product-skeleton-loader.active {
    display: block;
}

/* Skeleton Grid - matches ul.products layout (LEGACY FALLBACK) */
.product-skeleton-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* Default 3 columns */
    gap: 30px;
    width: 100%;
}

/* Individual skeleton item (LEGACY FALLBACK) */
.product-skeleton-item {
    background: #ffffff;
    border: 0px solid #e0e0e0;
    border-radius: 5px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0;
    position: relative;
}

/* Enhanced Skeleton Components Layout (LEGACY FALLBACK) */
/* Matches EXACT jbskin.lt product HTML structure */

/* Link Wrapper */
.product-skeleton-loader .bde-skeleton-link-wrapper {
    position: relative;
    display: block;
    width: 100%;
}

/* Badge Wrapper - Absolute positioned (top-left) */
.product-skeleton-loader .bde-skeleton-badges-wrapper {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 998;
    width: 75%;
}

.product-skeleton-loader .bde-skeleton-badge {
    width: 50px;
    height: 24px;
    border-radius: 3px;
    margin-bottom: 6px;
    display: inline-block;
    margin-right: 6px;
}

/* Image Wrapper */
.product-skeleton-loader .bde-skeleton-image-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 1rem;
}

.product-skeleton-loader .bde-skeleton-image {
    width: 100%;
    aspect-ratio: 522 / 701; /* Real jbskin.lt image ratio */
}

/* Icons Wrapper - Absolute positioned (top-right) */
.product-skeleton-loader .bde-skeleton-icons-wrapper {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.product-skeleton-loader .bde-skeleton-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

/* Brand */
.product-skeleton-loader .bde-skeleton-brand {
    width: 60%;
    height: 0.875rem;
    margin-bottom: 0.5rem;
}

/* Title */
.product-skeleton-loader .bde-skeleton-title {
    width: 100%;
    height: 1.2rem;
    margin-bottom: 0.5rem;
}

/* Second line of title */
.product-skeleton-loader .bde-skeleton-title::after {
    content: '';
    display: block;
    width: 80%;
    height: 1.2rem;
    margin-top: 0.3rem;
    background: inherit;
    border-radius: inherit;
}

/* Price */
.product-skeleton-loader .bde-skeleton-price {
    width: 35%;
    height: 1.25rem;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
}

/* Footer */
.product-skeleton-loader .bde-skeleton-footer {
    min-height: 0.5rem;
}

/* Responsive grid columns */
@media (max-width: 768px) {
    .product-skeleton-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    .product-skeleton-loader .bde-skeleton-badges-wrapper {
        top: 15px;
        left: 15px;
    }
    
    .product-skeleton-loader .bde-skeleton-badge {
        width: 45px;
        height: 22px;
    }
    
    .product-skeleton-loader .bde-skeleton-icons-wrapper {
        top: 8px;
        right: 8px;
        gap: 6px;
    }
    
    .product-skeleton-loader .bde-skeleton-icon {
        width: 32px;
        height: 32px;
    }
}

@media (max-width: 480px) {
    .product-skeleton-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   No Results
   ========================================================================== */

.woocommerce-no-products-found {
    text-align: center;
    padding: 60px 20px;
    background: #f9f9f9;
    border-radius: 4px;
}

.woocommerce-no-products-found p {
    font-size: 18px;
    color: #666;
    margin-bottom: 20px;
}

.wc-no-results-clear-filters {
    display: inline-block;
}

/* ==========================================================================
   Mobile Styles - REMOVED RESPONSIVE LOGIC
   All show/hide controlled by Breakdance page builder
   ========================================================================== */

/* Mobile toggle button - always hidden, controlled by Breakdance */
.product-filters__mobile-toggle {
    display: none; /* Hidden by default, show via Breakdance */
    align-items: center;
    gap: 10px;
    width: 50%;
    padding: 12px 16px;
    background: #253473;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 0px;
    position: relative;
}


.product-filters__mobile-toggle .filter-icon {
    display: flex;
}

.product-filters__mobile-toggle .active-filters-count {
    position: absolute;
    right: 16px;
    background: #ff5722;
    color: #fff;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

/* Filter panel - default desktop mode (static positioning) */
.product-filters__panel {
    display: block;
    position: static;
    background: transparent;
    border: none;
    padding: 0;
}

/* Mobile modal mode - activate with .mobile-mode class via Breakdance */
.product-filters.mobile-mode .product-filters__panel,
body.filters-open .product-filters.mobile-mode .product-filters__panel,
body > .product-filters__panel.mobile-mode-panel {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 99999 !important;
    transform: translateY(100%) !important;
    transition: transform 0.3s ease-in-out !important;
    border: none !important;
    border-radius: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    display: flex !important;
    flex-direction: column !important;
    visibility: visible !important;
    opacity: 1 !important;
    background: #fff !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-height: 100dvh !important;
}

.product-filters.mobile-mode .product-filters__panel.is-open,
body.filters-open .product-filters.mobile-mode .product-filters__panel.is-open,
body > .product-filters__panel.mobile-mode-panel.is-open {
    transform: translateY(0) !important;
    z-index: 99999 !important;
}

/* Mobile header - hidden by default, shown in mobile mode */
.product-filters__mobile-header {
    display: none;
}

.product-filters.mobile-mode .product-filters__mobile-header,
body > .product-filters__panel.mobile-mode-panel .product-filters__mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.product-filters__mobile-header h5 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.product-filters__close {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
}

/* Mobile footer - hidden by default, shown in mobile mode */
.product-filters__mobile-footer {
    display: none;
}

.product-filters.mobile-mode .product-filters__mobile-footer,
body > .product-filters__panel.mobile-mode-panel .product-filters__mobile-footer {
    display: block;
    padding: 20px;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.product-filters__apply-button {
    width: 100%;
    padding: 14px;
    background: #000000;
    color: #fff;
    border: none;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.product-filters__apply-button:active {
    background: #555;
}

/* Overlay - hidden by default, shown in mobile mode */
.product-filters__overlay {
    display: none;
}

.product-filters.mobile-mode .product-filters__overlay {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    width: 100vw;
    height: 100vh;
}

.product-filters.mobile-mode .product-filters__overlay.is-visible {
    opacity: 1;
    visibility: visible;
    z-index: 99998;
}

/* Prevent body scroll when filters open */
body.filters-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100%;
    height: 100%;
}

/* Fix parent containers that might have overflow: hidden */
body.filters-open .product-filters {
    position: static !important;
    overflow: visible !important;
}

body.filters-open .breakdance,
body.filters-open .bde-section,
body.filters-open .bde-column,
body.filters-open [data-node-id] {
    overflow: visible !important;
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

.product-filters .hidden {
    display: none !important;
}

.product-filters .disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Ensure noUiSlider tooltips don't overflow */
.price-range-slider .noUi-target {
    position: relative;
}

/* WooCommerce compatibility */
.woocommerce .product-filters-chips {
    clear: both;
}

/* Breakdance compatibility */
.breakdance-woocommerce .product-filters-chips {
    width: 100%;
    clear: both;
}

/* ==========================================================================
   Breakdance H5 Override - Must be at end of file
   ========================================================================== */

/* Ultra-specific override for Breakdance h5 styling */
.breakdance .product-filters .filter-group h5.filter-group__title,
body .breakdance h5.filter-group__title,
.breakdance h5.filter-group__title {
    font-size: 14px !important;
    font-weight: 600 !important;
    margin: 0 !important;
    color: #333 !important;
    font-family: inherit !important;
}
