/**
 * Product Archive Filter Styles
 *
 * @package VividUltimate
 * @since 3.5.196
 */

/* ==========================================================================
   Layout
   ========================================================================== */

.vae-archive-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 30px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
}

.vae-archive-container * {
    box-sizing: border-box;
}

.vae-archive-full-width {
    grid-column: 1 / -1;
}

/* ==========================================================================
   Filter Sidebar
   ========================================================================== */

.vae-archive-filters {
    position: sticky;
    top: 100px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    scrollbar-width: thin;
    scrollbar-color: #ddd #f5f5f5;
}

.vae-archive-filters::-webkit-scrollbar {
    width: 6px;
}

.vae-archive-filters::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 3px;
}

.vae-archive-filters::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

.vae-filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.vae-filter-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #1d2327;
}

.vae-clear-filters {
    background: none;
    border: none;
    color: #6252a3;
    cursor: pointer;
    font-size: 0.875rem;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.vae-clear-filters:hover:not(:disabled) {
    background: #f0edf7;
}

.vae-clear-filters:disabled {
    color: #ccc;
    cursor: not-allowed;
}

/* Filter Groups */
.vae-filter-group {
    margin-bottom: 20px;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 15px;
}

.vae-filter-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.vae-filter-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 10px 0;
    background: none;
    border: none;
    font-weight: 600;
    font-size: 0.95rem;
    color: #1d2327;
    cursor: pointer;
    text-align: left;
}

.vae-filter-toggle::after {
    content: '−';
    font-size: 1.3rem;
    font-weight: 400;
    color: #666;
    line-height: 1;
}

.vae-filter-toggle[aria-expanded="false"]::after {
    content: '+';
}

.vae-filter-count {
    font-weight: normal;
    color: #666;
    font-size: 0.85rem;
    margin-left: 8px;
}

.vae-filter-options {
    padding: 5px 0;
}

.vae-filter-toggle[aria-expanded="false"] + .vae-filter-options {
    display: none;
}

/* Checkbox List */
.vae-checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.vae-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 4px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.15s;
}

.vae-checkbox-label:hover {
    background: #f8f8f8;
}

.vae-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    accent-color: #6252a3;
}

.vae-checkbox-text {
    flex: 1;
    font-size: 0.9rem;
    color: #333;
}

.vae-checkbox-count {
    font-size: 0.8rem;
    color: #999;
}

/* Range Slider */
.vae-range-container {
    padding: 10px 5px;
}

.vae-range-slider {
    position: relative;
    height: 6px;
    margin: 25px 0 15px;
    background: #e0e0e0;
    border-radius: 3px;
}

.vae-range-track {
    position: absolute;
    width: 100%;
    height: 100%;
    background: #e0e0e0;
    border-radius: 3px;
}

.vae-range-progress {
    position: absolute;
    height: 100%;
    background: #6252a3;
    border-radius: 3px;
    left: 0;
    width: 100%;
}

.vae-range-slider input[type="range"] {
    position: absolute;
    width: 100%;
    height: 6px;
    top: 0;
    pointer-events: none;
    appearance: none;
    background: transparent;
    margin: 0;
}

.vae-range-slider input[type="range"]::-webkit-slider-thumb {
    pointer-events: auto;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #6252a3;
    border: 3px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    margin-top: -7px;
}

.vae-range-slider input[type="range"]::-moz-range-thumb {
    pointer-events: auto;
    width: 20px;
    height: 20px;
    background: #6252a3;
    border: 3px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.vae-range-values {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: #333;
}

.vae-range-separator {
    color: #999;
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */

.vae-archive-main {
    position: relative;
    min-height: 400px;
}

/* Header */
.vae-archive-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.vae-result-info {
    flex: 1;
}

.vae-result-count {
    font-size: 0.95rem;
    color: #666;
}

.vae-sort-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.vae-sort-select {
    padding: 8px 32px 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    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='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 10px center;
    appearance: none;
    font-size: 0.9rem;
    cursor: pointer;
}

.vae-sort-select:focus {
    outline: none;
    border-color: #6252a3;
    box-shadow: 0 0 0 2px rgba(98, 82, 163, 0.2);
}

.vae-filter-toggle-mobile {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
}

/* Active Filters */
.vae-active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.vae-filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #f0edf7;
    border-radius: 20px;
    font-size: 0.85rem;
    color: #5a4a8a;
}

.vae-filter-pill-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    color: #5a4a8a;
    transition: background-color 0.15s;
}

.vae-filter-pill-remove:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   Product Grid
   ========================================================================== */

.vae-archive-grid {
    display: grid;
    grid-template-columns: repeat(var(--vae-columns, 3), 1fr);
    gap: 20px;
    transition: opacity 0.2s;
}

.vae-archive-grid.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Product Card */
.vae-archive-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}

.vae-archive-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

.vae-card-link {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    flex: 1;
}

.vae-card-image {
    position: relative;
    padding-top: 75%;
    background: #f8f8f8;
    overflow: hidden;
}

.vae-card-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 15px;
}

.vae-card-no-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
}

.vae-card-content {
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.vae-card-brand {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    margin-bottom: 5px;
}

.vae-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1d2327;
    margin: 0 0 10px 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.vae-card-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 10px;
}

.vae-star {
    font-size: 0.9rem;
}

.vae-star-full {
    color: #f5a623;
}

.vae-star-half {
    color: #f5a623;
    opacity: 0.6;
}

.vae-star-empty {
    color: #ddd;
}

.vae-rating-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: #333;
    margin-left: 4px;
}

.vae-rating-count {
    font-size: 0.8rem;
    color: #999;
}

.vae-card-specs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.vae-product-spec {
    font-size: 0.75rem;
    padding: 3px 8px;
    background: #f5f5f5;
    border-radius: 4px;
    color: #666;
}

.vae-card-excerpt {
    font-size: 0.85rem;
    color: #666;
    line-height: 1.5;
    margin: 0 0 12px 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.vae-card-price {
    font-size: 1.25rem;
    font-weight: 700;
    color: #6252a3;
    margin-top: auto;
}

.vae-card-btn {
    display: block;
    padding: 12px;
    text-align: center;
    background: #6252a3;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.vae-card-btn:hover {
    background: #5a4a9a;
    color: #fff;
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.vae-archive-empty {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.vae-archive-empty[hidden] {
    display: none !important;
}

.vae-archive-empty svg {
    color: #ddd;
    margin-bottom: 20px;
}

.vae-archive-empty h3 {
    margin: 0 0 10px 0;
    font-size: 1.25rem;
    color: #333;
}

.vae-archive-empty p {
    margin: 0 0 20px 0;
}

.vae-clear-filters-btn {
    padding: 10px 24px;
    background: #6252a3;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.vae-clear-filters-btn:hover {
    background: #5a4a9a;
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.vae-archive-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 40px;
    flex-wrap: wrap;
}

.vae-page-numbers {
    display: flex;
    gap: 4px;
}

.vae-page-btn {
    padding: 10px 16px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #1e293b;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.vae-page-btn:hover {
    border-color: #6252a3;
    color: #6252a3;
}

.vae-page-active {
    background: #6252a3;
    border-color: #6252a3;
    color: #fff;
}

.vae-page-active:hover {
    background: #5a4a9a;
    border-color: #5a4a9a;
    color: #fff;
}

.vae-page-ellipsis {
    padding: 10px 8px;
    color: #64748b;
}

.vae-page-prev,
.vae-page-next {
    font-weight: 500;
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.vae-archive-loading {
    position: absolute;
    top: 80px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    z-index: 10;
    border-radius: 12px;
}

.vae-archive-loading[hidden] {
    display: none !important;
}

.vae-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f0f0f0;
    border-top-color: #6252a3;
    border-radius: 50%;
    animation: vae-spin 0.8s linear infinite;
}

@keyframes vae-spin {
    to {
        transform: rotate(360deg);
    }
}

.vae-archive-loading span {
    font-size: 0.9rem;
    color: #666;
}

/* ==========================================================================
   Skeleton Loading Cards (prevent FOUC)
   ========================================================================== */

.vae-skeleton-card {
    pointer-events: none;
}

.vae-skeleton-pulse {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: vae-skeleton-shimmer 1.5s ease-in-out infinite;
}

.vae-skeleton-line {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: vae-skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
    margin-bottom: 10px;
}

@keyframes vae-skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==========================================================================
   Error State
   ========================================================================== */

.vae-archive-error {
    text-align: center;
    padding: 40px;
    background: #fff5f5;
    border-radius: 8px;
    color: #c53030;
}

.vae-archive-error button {
    margin-top: 15px;
    padding: 8px 20px;
    background: #c53030;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

/* ==========================================================================
   Mobile Styles
   ========================================================================== */

@media (max-width: 1024px) {
    .vae-archive-container {
        grid-template-columns: 250px 1fr;
        gap: 20px;
    }

    .vae-archive-grid {
        --vae-columns: 2 !important;
    }
}

@media (max-width: 768px) {
    .vae-archive-container {
        grid-template-columns: 1fr;
        padding: 12px;
    }

    /* Hide sidebar by default on mobile — flex layout for fixed footer button */
    .vae-archive-filters {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100vh;
        height: 100dvh;
        max-height: 100vh;
        max-height: 100dvh;
        z-index: 9999999;
        border-radius: 0;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        padding: 0;
        padding-top: env(safe-area-inset-top, 0px);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .vae-archive-filters.open {
        transform: translateY(0);
    }

    /* Drag handle on mobile filter sheet */
    .vae-archive-filters::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: #ddd;
        border-radius: 2px;
        margin: 15px auto 0;
        flex-shrink: 0;
    }

    /* Filter header stays at top */
    .vae-archive-filters .vae-filter-header {
        flex-shrink: 0;
        padding: 15px 20px;
        margin-bottom: 0;
    }

    /* Filter groups scroll independently */
    .vae-archive-filters .vae-filter-groups {
        flex: 1;
        overflow-y: auto;
        padding: 0 20px 20px;
        -webkit-overflow-scrolling: touch;
    }

    /* Mobile filter overlay */
    .vae-filter-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9999998;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s, visibility 0.3s;
    }

    .vae-filter-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Show mobile filter toggle */
    .vae-filter-toggle-mobile {
        display: flex;
        padding: 10px 18px;
        font-weight: 500;
    }

    /* Mobile apply button — flex child at bottom, clear browser controls */
    .vae-filter-apply-mobile {
        flex-shrink: 0;
        padding: 15px 20px;
        padding-bottom: max(20px, env(safe-area-inset-bottom, 20px));
        background: #fff;
        border-top: 1px solid #eee;
        box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.1);
    }

    .vae-apply-filters {
        width: 100%;
        padding: 16px;
        background: #6252a3;
        color: #fff;
        border: none;
        border-radius: 10px;
        font-weight: 600;
        font-size: 1rem;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .vae-apply-filters:active {
        background: #5a4a9a;
    }

    /* Grid adjustments */
    .vae-archive-grid {
        --vae-columns: 2 !important;
        gap: 12px;
    }

    /* Card adjustments for mobile */
    .vae-archive-card {
        border-radius: 10px;
    }

    .vae-card-content {
        padding: 12px;
    }

    .vae-card-title {
        font-size: 0.9rem;
        -webkit-line-clamp: 2;
    }

    .vae-card-price {
        font-size: 1.1rem;
    }

    .vae-card-excerpt {
        display: none;
    }

    .vae-card-btn {
        padding: 10px;
        font-size: 0.85rem;
        border-radius: 0 0 10px 10px;
    }

    /* Checkbox labels bigger tap target */
    .vae-checkbox-label {
        padding: 12px 8px;
        min-height: 44px;
    }

    /* Header adjustments */
    .vae-archive-header {
        gap: 10px;
    }

    .vae-result-count {
        font-size: 0.85rem;
    }

    .vae-sort-select {
        font-size: 0.85rem;
        padding: 10px 32px 10px 12px;
    }

    /* Pagination */
    .vae-archive-pagination {
        margin-top: 30px;
    }

    .vae-page-btn {
        padding: 10px 14px;
        min-height: 44px;
    }

    .vae-page-num {
        min-width: 44px;
        padding: 10px;
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    .vae-archive-grid {
        --vae-columns: 1 !important;
    }

    .vae-archive-card {
        flex-direction: row;
    }

    .vae-card-link {
        flex-direction: row;
    }

    .vae-card-image {
        width: 110px;
        min-width: 110px;
        padding-top: 0;
        height: 110px;
    }

    .vae-card-content {
        padding: 10px 12px;
    }

    .vae-card-btn {
        display: none;
    }

    /* Skeleton adjustments for horizontal card layout */
    .vae-skeleton-card .vae-card-link {
        flex-direction: row;
    }
    .vae-skeleton-card .vae-card-image {
        width: 110px;
        min-width: 110px;
        padding-top: 0;
        height: 110px;
    }
}

/* Body class when filters open */
body.vae-filters-open {
    overflow: hidden;
}

/* Desktop: hide mobile-only elements and reset flex layout */
@media (min-width: 769px) {
    .vae-filter-apply-mobile {
        display: none;
    }

    .vae-filter-overlay {
        display: none;
    }

    .vae-archive-filters {
        display: block;
    }
}
