/**
 * COL323 WooCommerce Extensions — Frontend Styles
 * v0.7.0 — Sidebar filter layout (motionrc.com style)
 *
 * Uses CSS custom properties from Col323 Commerce theme:
 *   --col323-primary, --col323-primary-dark, --col323-heading,
 *   --col323-text, --col323-border, --col323-white
 * Falls back to sensible defaults when theme vars are not set.
 */

/* =========================================================================
   Wrapper — sidebar + content
   ========================================================================= */

.wc-filter-sidebar-layout {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    width: 100%;
    margin: 20px 0;
}

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

.wc-filter-sidebar {
    width: 240px;
    min-width: 240px;
    flex-shrink: 0;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    border: 1px solid var(--col323-border, #e0e0e0);
    border-radius: 6px;
    background: var(--col323-white, #fff);
}

.wc-filter-sidebar.wc-position-left {
    order: 1;
}

.wc-filter-sidebar.wc-position-right {
    order: 3;
}

.wc-filter-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--col323-border, #e0e0e0);
}

.wc-filter-sidebar-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--col323-heading, #333);
}

.wc-filter-clear-all {
    background: none !important;
    border: none !important;
    color: var(--col323-primary, #0073aa) !important;
    font-size: 12px !important;
    cursor: pointer;
    padding: 0 !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
}

.wc-filter-clear-all:hover {
    text-decoration: underline;
    background: none !important;
}

/* Custom scrollbar */
.wc-filter-sidebar::-webkit-scrollbar {
    width: 6px;
}
.wc-filter-sidebar::-webkit-scrollbar-track {
    background: #f5f5f5;
}
.wc-filter-sidebar::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

/* =========================================================================
   Sections — collapsible
   ========================================================================= */

.wc-filter-section {
    border-bottom: 1px solid var(--col323-border, #e0e0e0);
}

.wc-filter-section:last-child {
    border-bottom: none;
}

.wc-filter-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.wc-filter-section-header:hover {
    background: #f8f8f8;
}

.wc-filter-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--col323-primary, #0073aa);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wc-filter-section-toggle {
    font-size: 18px;
    line-height: 1;
    color: var(--col323-primary, #0073aa);
    font-weight: 400;
    width: 20px;
    text-align: center;
}

.wc-filter-section-body {
    padding: 0 16px 12px;
}

/* Collapsed */
.wc-filter-section--collapsed .wc-filter-section-body {
    display: none;
}

/* =========================================================================
   Checkbox rows
   ========================================================================= */

.wc-filter-checkbox-row {
    display: flex;
    align-items: center;
    padding: 4px 0;
    cursor: pointer;
    font-size: 13px;
    color: var(--col323-text, #444);
    gap: 6px;
    font-weight: normal !important;
    margin-bottom: 0 !important;
}

.wc-filter-checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    min-width: 16px;
    margin: 0;
    padding: 0;
    flex-shrink: 0;
    accent-color: var(--col323-primary, #0073aa);
    cursor: pointer;
}

.wc-filter-label {
    flex: 1;
    line-height: 1.3;
}

.wc-filter-count {
    color: #999;
    font-size: 12px;
    flex-shrink: 0;
}

/* =========================================================================
   Category tree (inside sidebar section)
   ========================================================================= */

.wc-category-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.wc-category-list .wc-category-list {
    margin-left: 16px;
    margin-top: 2px;
    padding-left: 8px;
    border-left: 2px solid var(--col323-border, #e0e0e0);
}

.wc-category-item {
    margin: 2px 0;
}

/* =========================================================================
   Price range — v0.8.0 dual range sliders
   ========================================================================= */

.wc-filter-price-labels {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    color: var(--col323-heading, #333);
    margin-bottom: 8px;
}

.wc-filter-price-sliders {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wc-price-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--col323-border, #e0e0e0);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.wc-price-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--col323-primary, #0073aa);
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: transform 0.15s;
}

.wc-price-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.wc-price-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--col323-primary, #0073aa);
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: transform 0.15s;
}

.wc-price-slider::-moz-range-thumb:hover {
    transform: scale(1.15);
}

.wc-price-slider::-moz-range-track {
    height: 6px;
    background: var(--col323-border, #e0e0e0);
    border-radius: 3px;
    border: none;
}

/* =========================================================================
   Content area
   ========================================================================= */

.wc-filter-content {
    flex: 1;
    min-width: 0;
    order: 2;
}

/* Top bar */
.wc-filter-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--col323-border, #e0e0e0);
}

.wc-filter-results-count {
    margin: 0;
    padding: 0;
    background: none;
    border-radius: 0;
}

.wc-filter-results-count .results-text {
    font-size: 15px;
    font-weight: 600;
    color: var(--col323-heading, #333);
}

.wc-filter-sort-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.wc-filter-sort-wrap label {
    font-size: 13px;
    color: #666;
    font-weight: normal;
    margin: 0;
    white-space: nowrap;
}

.wc-filter-sort {
    width: auto;
    min-width: 160px;
    padding: 6px 10px;
    font-size: 13px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
}

/* =========================================================================
   Product grid — uses WC template parts (ul.products)
   v0.7.1 — Professional card layout with borders
   ========================================================================= */

.wc-filter-results-grid ul.products {
    margin: 0;
    padding: 0;
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 16px !important;
}

/* Product cards inside filter — ensure borders and consistent images */
.wc-filter-results-grid ul.products li.product {
    border: 1px solid var(--col323-border, #e0e0e0) !important;
    border-radius: 6px !important;
    background: var(--col323-white, #fff) !important;
    overflow: hidden !important;
    transition: box-shadow 0.2s ease, border-color 0.2s ease !important;
}

.wc-filter-results-grid ul.products li.product:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
    border-color: var(--col323-primary, #0073aa) !important;
}

/* Product images — always complete, never cropped */
.wc-filter-results-grid ul.products li.product img {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 1 / 1 !important;
    object-fit: contain !important;
    background: #f8f8f8 !important;
    padding: 10px !important;
    box-sizing: border-box !important;
}

/* No results */
.wc-no-products {
    text-align: center;
    padding: 60px 20px;
    background: #f9f9f9;
    border-radius: 8px;
}

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

/* =========================================================================
   Loading / Error
   ========================================================================= */

.wc-filter-loading {
    text-align: center;
    padding: 60px 20px;
}

.wc-spinner {
    width: 36px;
    height: 36px;
    margin: 0 auto 16px;
    border: 3px solid var(--col323-border, #e0e0e0);
    border-top-color: var(--col323-primary, #0073aa);
    border-radius: 50%;
    animation: wc-spin 0.7s linear infinite;
}

@keyframes wc-spin {
    to { transform: rotate(360deg); }
}

.wc-filter-results-grid.wc-filter-loading-overlay {
    position: relative;
    min-height: 200px;
}

.wc-filter-results-grid.wc-filter-loading-overlay::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    z-index: 10;
}

.wc-filter-error {
    text-align: center;
    padding: 40px 20px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
}

.wc-filter-error p {
    color: #856404;
    margin: 0;
}

/* =========================================================================
   Pagination
   ========================================================================= */

.wc-filter-pagination {
    padding: 20px 0;
    text-align: center;
}

.wc-filter-pagination-inner {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.wc-page-btn,
.wc-page-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 4px 10px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    color: #333;
    cursor: pointer;
    transition: all 0.15s;
}

.wc-page-btn:hover {
    background: #f5f5f5;
    border-color: var(--col323-primary, #0073aa);
    color: var(--col323-primary, #0073aa);
}

.wc-page-number.active {
    background: var(--col323-primary, #0073aa);
    border-color: var(--col323-primary, #0073aa);
    color: #fff;
    cursor: default;
}

.wc-page-ellipsis {
    padding: 0 4px;
    color: #999;
}

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

/* Desktop — 3 columns when sidebar is present and space is limited */
@media (max-width: 1200px) {
    .wc-filter-results-grid ul.products {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

@media (max-width: 992px) {
    .wc-filter-sidebar-layout {
        flex-direction: column;
        gap: 16px;
    }

    .wc-filter-sidebar {
        width: 100% !important;
        min-width: 0;
        position: static;
        max-height: none;
        order: 1 !important;
    }

    .wc-filter-content {
        order: 2 !important;
    }

    /* Full width — back to 4 columns when sidebar stacks */
    .wc-filter-results-grid ul.products {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

@media (max-width: 768px) {
    .wc-filter-topbar {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .wc-filter-sort {
        width: 100%;
    }

    .wc-filter-sort-wrap {
        width: 100%;
    }

    .wc-filter-sort-wrap select {
        flex: 1;
    }

    /* Tablet — 3 columns */
    .wc-filter-results-grid ul.products {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

@media (max-width: 576px) {
    /* Mobile — 2 columns */
    .wc-filter-results-grid ul.products {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
}

/* =========================================================================
   Legacy support — hide old top bar / form elements if still in DOM
   ========================================================================= */

.wc-filter-sidebar-layout .wc-filter-top-bar,
.wc-filter-sidebar-layout #wc-product-filter-form,
.wc-filter-sidebar-layout .wc-filter-main-content {
    display: none;
}
