/**
 * AJAX Product Filters - Styles
 */

/* ========================================
   Latvian Font Support - UTF-8 Compatible
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

* {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Ensure Latvian characters render correctly with proper case transformation */
.apf-sidebar,
.apf-filter-title,
.apf-category-label,
.apf-size-label {
    font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif !important;
    text-rendering: optimizeLegibility;
    font-feature-settings: "liga" 1, "calt" 1;
    -webkit-font-feature-settings: "liga" 1, "calt" 1;
    -moz-font-feature-settings: "liga" 1, "calt" 1;
}

/* ========================================
   Dynamic Title Section - COMPACT
   ======================================== */

.apf-dynamic-title {
    margin: 0 0 12px 0;
    padding: 0 0 12px 0;
    border-bottom: 2px solid #e0e0e0;
}

.apf-page-title {
    font-size: 22px;
    font-weight: 700;
    text-transform: uppercase;
    color: #2c3e50;
    margin: 0;
    padding: 0;
    line-height: 1.2;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
}

/* Category subtitle when filter is active */
.apf-page-title .apf-category-subtitle {
    display: block;
    font-size: 18px;
    font-weight: 400;
    color: #7f8c8d;
    margin-top: 8px;
    text-transform: none;
    letter-spacing: 0;
}

/* ========================================
   Shop Container Layout
   ======================================== */

.apf-shop-container {
    display: flex;
    gap: 20px;
    padding: 15px;
    max-width: 100%;
    margin: 0 auto;
    width: 100%;
}

/* ========================================
   Sidebar
   ======================================== */

.apf-sidebar {
    position: relative;
    width: 260px;
    flex-shrink: 0;
}

.apf-sidebar-inner {
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Custom scrollbar for sidebar */
.apf-sidebar-inner::-webkit-scrollbar {
    width: 8px;
}

.apf-sidebar-inner::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.apf-sidebar-inner::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.apf-sidebar-inner::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.apf-filters-wrapper {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 20px;
}

/* Disabled/unavailable filter styles */
.apf-filter-unavailable {
    opacity: 0.4;
    pointer-events: none;
}

.apf-filter-unavailable .apf-category-label,
.apf-filter-unavailable .apf-size-label {
    text-decoration: line-through;
    color: #ccc !important;
}

.apf-category-option.apf-has-products {
    opacity: 1;
}

.apf-category-option.apf-no-products {
    opacity: 0.4;
}

.apf-category-option.apf-no-products .apf-category-label {
    color: #ccc !important;
}

.apf-category-option.apf-no-products input {
    cursor: not-allowed;
}

.apf-filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.apf-filters-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.apf-clear-btn {
    background: none;
    border: none;
    color: #666;
    font-size: 8px;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    transition: color 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    white-space: nowrap;
    flex-shrink: 0;
    display: inline;
    font-family: inherit;
}

.apf-clear-btn:hover {
    color: #333;
    text-decoration: underline;
}

/* ========================================
   Filter Groups
   ======================================== */

.apf-filter-group {
    margin-bottom: 25px;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 20px;
}

.apf-filter-group:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.apf-filter-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 0 15px;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    user-select: none;
}

.apf-toggle-arrow {
    transition: transform 0.3s ease;
    font-size: 12px;
    color: #999;
}

.apf-toggle-arrow.rotated {
    transform: rotate(-180deg);
}

.apf-filter-content {
    overflow: hidden;
}

/* ========================================
   Size Filter (under Apavi category)
   ======================================== */

.apf-size-filter-section {
    margin: 8px 0 8px 24px;
    padding: 8px 10px;
    background: #f9f9f9;
    border-radius: 4px;
    display: none; /* Hidden by default */
}

.apf-size-filter-section.active {
    display: block;
}

.apf-size-filter-header {
    font-size: 12px;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.apf-size-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.apf-size-option {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    flex: 0 0 calc(25% - 3px);
}

.apf-size-option input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.apf-size-label {
    display: block;
    width: 100%;
    padding: 5px 2px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 500;
    transition: all 0.15s ease;
    background: #fff;
}

.apf-size-option input:checked ~ .apf-size-label {
    background: #333;
    color: #fff;
    border-color: #333;
}

.apf-size-option:hover .apf-size-label {
    border-color: #999;
}

/* Removed grayed out styles - we don't show unavailable sizes anymore */

/* Size Accordion - appears under checked shoe categories */
.apf-size-accordion {
    margin: 6px 0 6px 0;
    padding: 8px;
    background: #f9f9f9;
    border-radius: 4px;
}

.apf-category-child-wrapper {
    margin-bottom: 3px;
}

.apf-size-accordion .apf-size-filter-header {
    font-size: 11px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.apf-size-accordion .apf-size-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.apf-size-accordion .apf-size-option {
    flex: 0 0 calc(33.33% - 4px);
}

.apf-size-accordion .apf-size-label {
    padding: 6px 8px;
    font-size: 11px;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: #fff;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.apf-size-accordion .apf-size-option input:checked ~ .apf-size-label {
    background: #333;
    color: #fff;
    border-color: #333;
}

.apf-size-accordion .apf-size-option:hover .apf-size-label {
    border-color: #999;
}

/* ========================================
   Category Filter
   ======================================== */

.apf-category-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Parent category container */
.apf-category-parent {
    margin-bottom: 12px;
}

.apf-category-parent:last-child {
    margin-bottom: 0;
}

/* Parent category label (APAVI) */
.apf-parent-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 8px 0;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 8px;
}

.apf-parent-label .apf-category-label {
    font-size: 15px;
    color: #333;
}

.apf-parent-label .apf-category-label strong {
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    font-family: 'Inter', sans-serif !important;
}

/* Child categories container */
.apf-category-children {
    padding-left: 24px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Child category labels */
.apf-child-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 4px 0;
}

.apf-child-label .apf-category-label {
    font-size: 13px;
    color: #666;
}

/* Checkbox styling */
.apf-category-option input[type="checkbox"] {
    margin: 0 10px 0 0;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Category label */
.apf-category-label {
    display: flex;
    justify-content: space-between;
    width: 100%;
    font-size: 14px;
    color: #555;
}

.apf-category-option input[type="checkbox"]:checked + .apf-category-label,
.apf-category-option input[type="checkbox"]:checked + .apf-category-label strong {
    color: #80bef3;
}

.apf-category-count {
    color: #999;
    font-size: 12px;
    font-weight: normal;
}

/* Hover effects */
.apf-parent-label:hover .apf-category-label {
    color: #000;
}

.apf-child-label:hover .apf-category-label {
    color: #333;
}

/* ========================================
   Price Filter
   ======================================== */

.apf-price-range {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.apf-price-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}

.apf-price-inputs input[type="number"] {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    width: 100%;
}

.apf-price-separator {
    color: #999;
}

.apf-apply-price-btn {
    width: 100%;
    padding: 10px;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.apf-apply-price-btn:hover {
    background: #555;
}

.apf-price-display {
    text-align: center;
    font-size: 13px;
    color: #666;
    padding: 8px;
    background: #f9f9f9;
    border-radius: 4px;
}

.apf-currency {
    font-weight: 600;
}

/* ========================================
   Main Content Area
   ======================================== */

.apf-main-content {
    position: relative;
    flex: 1;
}

.apf-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 12px 15px;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.apf-result-count {
    font-size: 14px;
    color: #666;
}

.apf-ordering select {
    padding: 12px 35px 12px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.6;
    height: auto;
    min-height: 46px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E") no-repeat right 10px center;
    background-size: 12px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

/* ========================================
   Loading State
   ======================================== */

.apf-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    display: none;
    will-change: opacity; /* GPU acceleration */
}

.apf-loading.active {
    display: block;
    animation: apf-fade-in 0.15s ease-in;
}

.apf-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #333;
    border-radius: 50%;
    animation: apf-spin 0.6s linear infinite;
    will-change: transform; /* GPU acceleration */
}

@keyframes apf-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes apf-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ========================================
   Products Grid
   ======================================== */

.apf-products-grid {
    transition: opacity 0.3s ease;
}

.apf-no-products {
    text-align: center;
    padding: 60px 20px;
    background: #f9f9f9;
    border-radius: 8px;
}

.apf-no-products p {
    font-size: 16px;
    color: #666;
    margin: 0;
}

/* ========================================
   Mobile Toggle
   ======================================== */

.apf-mobile-toggle {
    display: none;
    width: 100%;
    max-width: 100%;
    padding: 10px 16px;
    background: transparent;
    color: #80BEF3;
    border: 2px solid #80BEF3;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin: 0 auto 12px auto;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    transition: all 0.2s ease;
}

.apf-toggle-icon {
    font-size: 16px;
}

.apf-mobile-toggle:hover {
    background: rgba(128, 190, 243, 0.1);
}

.apf-mobile-toggle.active {
    background: #80BEF3;
    color: #fff;
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 1024px) {
    .apf-shop-container {
        gap: 15px;
    }
    
    .apf-sidebar {
        width: 220px;
    }
}

@media (max-width: 768px) {
    .apf-shop-container {
        flex-direction: column;
        gap: 0;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .apf-sidebar {
        width: 100%;
        padding: 10px;
        margin: 0;
    }
    
    .apf-sidebar-inner {
        position: relative;
        top: 0;
        width: 100%;
        max-height: none;
        padding: 0;
    }
    
    .apf-mobile-toggle {
        display: flex;
        margin: 20px 0 12px 0;
        font-size: 13px;
        padding: 8px 14px;
    }
    
    /* Hide theme page title on mobile */
    .page-title {
        display: none !important;
    }
    
    /* Hide category filter row on mobile */
    .category-filter-row {
        display: none !important;
    }
    
    .apf-main-content {
        padding: 0 10px;
        margin: 0;
    }
    
    .apf-filters-wrapper {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 90%;
        max-width: 350px;
        height: 100vh;
        z-index: 9999;
        overflow-y: auto;
        border-radius: 0;
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.3);
        background: #fff;
    }
    
    .apf-filters-wrapper.active {
        display: block;
        animation: apf-slide-in 0.3s ease;
    }
    
    @keyframes apf-slide-in {
        from {
            transform: translateX(-100%);
        }
        to {
            transform: translateX(0);
        }
    }
    
    /* Dynamic Title - CONSISTENT 12px SPACING */
    .apf-dynamic-title {
        margin: 0 0 12px 0;
        padding: 0 0 12px 0;
    }
    
    .apf-page-title {
        font-size: 17px;
        margin: 0;
        padding: 0;
    }
    
    .apf-title-wrapper {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 12px;
    }
    
    .apf-search-wrapper {
        width: 100%;
    }
    
    /* Toolbar - CONSISTENT 12px SPACING */
    .apf-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 8px;
        margin-bottom: 12px;
    }
    
    .apf-result-count {
        text-align: center;
        font-size: 12px;
        margin: 0;
        padding: 0;
    }
    
    .apf-ordering {
        width: 100%;
    }
    
    .apf-ordering select {
        width: 100%;
        font-size: 13px;
        padding: 9px 35px 9px 10px;
        min-height: 40px;
        line-height: 1.5;
    }
    
    /* Brand Accordion - Mobile - SMALLER FONTS */
    .apf-brand-accordion {
        margin: 10px 0 10px 10px;
        padding: 12px;
    }
    
    .apf-brand-filter-header {
        font-size: 10px;
        margin-bottom: 8px;
    }
    
    .apf-brand-grid {
        max-height: 250px;
        width: 100%;
    }
    
    .apf-brand-section,
    .apf-brand-list {
        width: 100%;
    }
    
    .apf-brand-option {
        padding: 6px 4px;
        width: 100%;
    }
    
    .apf-brand-option input[type="checkbox"] {
        width: 14px;
        height: 14px;
        margin-right: 6px;
    }
    
    .apf-brand-label {
        font-size: 11px;
        line-height: 1.3;
    }
    
    .apf-brand-count {
        font-size: 9px;
        margin-left: 4px;
    }
    
    /* Size Accordion - Mobile */
    .apf-size-accordion {
        margin: 10px 0 10px 10px;
        padding: 12px;
    }
    
    .apf-size-filter-header {
        font-size: 12px;
        margin-bottom: 10px;
    }
    
    .apf-size-grid {
        gap: 6px;
    }
    
    .apf-size-option {
        min-width: 60px;
    }
    
    .apf-size-label {
        font-size: 12px;
        padding: 8px 6px;
    }
    
    /* Category Labels - Mobile */
    .apf-category-label {
        font-size: 14px;
    }
    
    .apf-category-option {
        padding: 10px 8px;
    }
}

@media (max-width: 480px) {
    .apf-size-label {
        padding: 6px 2px;
        font-size: 11px;
    }
    
    /* Even smaller fonts on small phones */
    .apf-brand-label {
        font-size: 10px;
    }
    
    .apf-brand-count {
        font-size: 8px;
    }
    
    .apf-brand-filter-header {
        font-size: 9px;
    }
    
    .apf-category-label {
        font-size: 12px;
    }
}

/* ========================================
   Brand Filter Accordion - PROGRESSIVE FILTERING
   ======================================== */

.apf-brand-accordion {
    display: none;
    background: transparent;
    border-radius: 0;
    padding: 0;
    margin: 8px 0 8px 0;
    border-left: none;
}

.apf-brand-filter-header {
    font-size: 12px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-left: 0;
}

.apf-brand-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-height: 350px;
    overflow-y: auto;
    padding-right: 8px;
    width: 100%;
}

.apf-brand-section {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.apf-brand-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
}

/* Custom scrollbar for brand grid */
.apf-brand-grid::-webkit-scrollbar {
    width: 6px;
}

.apf-brand-grid::-webkit-scrollbar-track {
    background: #e9ecef;
    border-radius: 3px;
}

.apf-brand-grid::-webkit-scrollbar-thumb {
    background: #80BEF3;
    border-radius: 3px;
}

.apf-brand-grid::-webkit-scrollbar-thumb:hover {
    background: #5fa8e3;
}

.apf-brand-option {
    display: flex;
    align-items: center;
    padding: 5px 0;
    background: transparent;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    border-left: 2px solid transparent;
    margin: 0;
    width: 100%;
    flex-wrap: nowrap;
}

.apf-brand-option:hover .apf-brand-label {
    color: #80BEF3;
}

.apf-brand-option input[type="checkbox"]:checked {
    border-color: #80BEF3;
}

.apf-brand-option input[type="checkbox"]:checked ~ * {
    border-left-color: #80BEF3;
}

.apf-brand-option:has(input[type="checkbox"]:checked) {
    border-left: 2px solid #80BEF3;
    padding-left: 4px;
}

.apf-brand-option input[type="checkbox"] {
    margin: 0 8px 0 0;
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

.apf-brand-label {
    flex: 1;
    font-size: 11px;
    font-weight: 400;
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
    transition: color 0.2s ease;
}

.apf-brand-count {
    font-size: 10px;
    color: #999;
    margin-left: 6px;
    font-weight: 400;
    flex-shrink: 0;
}

.apf-brand-option input[type="checkbox"]:checked + .apf-brand-label {
    color: #80BEF3;
    font-weight: 500;
}

.apf-brand-option.apf-no-products {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* ========================================
   Hide Theme Filter Button (We have our own)
   ======================================== */

/* Permanently hide Flatsome theme filter button */
.filter-button,
a.filter-button,
.shop-page-title .filter-button,
[data-open="#shop-sidebar"] {
    display: none !important;
}

/* Hide native WooCommerce search */
#woocommerce-product-search-field-0,
input[id^="woocommerce-product-search-field"],
.woocommerce-product-search,
.woocommerce-product-search .icon-search,
.icon-search,
i.icon-search {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* ========================================
   Dynamic Brand Filter Styling
   ======================================== */

.apf-filter-brand .apf-brand-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
}

.apf-brand-option {
    display: flex;
    align-items: center;
    padding: 8px 0;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    flex-wrap: nowrap;
}

.apf-brand-option input[type="checkbox"] {
    margin-right: 10px;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.apf-brand-option input[type="checkbox"]:checked + .apf-brand-label {
    color: #80BEF3;
    font-weight: 500;
}

.apf-brand-label {
    font-size: 14px;
    color: #555;
    cursor: pointer;
    transition: color 0.2s ease;
    flex: 1;
}

.apf-brand-count {
    font-size: 12px;
    color: #999;
    margin-left: 5px;
}

.apf-brand-option:hover .apf-brand-label {
    color: #80BEF3;
}

/* ========================================
   Season Filter - Uses Category Styles
   ======================================== */

/* Season filter uses the same CSS classes as categories (apf-category-parent, apf-category-children, etc.)
   No custom styling needed - it inherits all category styles */

/* ========================================
   Integration with WooCommerce & Flatsome
   ======================================== */

/* Grid layout is now handled by Flatsome theme */
/* No grid overrides - theme controls product layout */

