/*
 * WC Off-Canvas Filters — offcanvas-filters.css
 * -----------------------------------------------
 * CSS custom properties are populated dynamically via wp_localize_script
 * but sensible defaults are defined here so the stylesheet is standalone.
 */

/* ═══════════════════════════════════════════════════════════════
   CSS Custom Properties
   ═══════════════════════════════════════════════════════════════ */
:root {
    --wcof-accent:          #2d6a4f;
    --wcof-accent-dark:     #1b4332;
    --wcof-accent-light:    #d8f3dc;
    --wcof-text:            #1a1a2e;
    --wcof-text-muted:      #6b7280;
    --wcof-bg:              #ffffff;
    --wcof-border:          #e5e7eb;
    --wcof-shadow:          0 20px 60px rgba(0,0,0,.18);
    --wcof-drawer-width:    340px;
    --wcof-radius:          16px;
    --wcof-transition:      .35s cubic-bezier(.4,0,.2,1);
    --wcof-btn-radius:      50px;
    --wcof-z-overlay:       99998;
    --wcof-z-drawer:        99999;
}

/* ═══════════════════════════════════════════════════════════════
   Floating Filter Button  (mobile only)
   ═══════════════════════════════════════════════════════════════ */
.wcof-filter-btn {
    display: none;               /* hidden on desktop by default */
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--wcof-accent);
    color: #fff;
    border: none;
    border-radius: var(--wcof-btn-radius);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .3px;
    cursor: pointer;
    position: relative;
    box-shadow: 0 4px 20px rgba(45,106,79,.35);
    transition: background var(--wcof-transition),
                transform .15s ease,
                box-shadow var(--wcof-transition);
    z-index: 10;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.wcof-filter-btn:hover,
.wcof-filter-btn:focus-visible {
    background: var(--wcof-accent-dark);
    box-shadow: 0 6px 28px rgba(45,106,79,.45);
    outline: none;
}

.wcof-filter-btn:active {
    transform: scale(.96);
}

.wcof-filter-btn__icon {
    display: flex;
    align-items: center;
}

.wcof-filter-btn__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: #fff;
    color: var(--wcof-accent-dark);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    margin-left: 2px;
}

/* Pulse badge animation when filters are active */
.wcof-filter-btn--active .wcof-filter-btn__count {
    animation: wcof-pulse 2s ease-in-out infinite;
}

@keyframes wcof-pulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.12); }
}

/* ═══════════════════════════════════════════════════════════════
   Overlay / Backdrop
   ═══════════════════════════════════════════════════════════════ */
.wcof-overlay {
    /* display and opacity are managed entirely by JS to avoid conflicts */
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10,10,20,.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: var(--wcof-z-overlay);
    opacity: 0;
    cursor: pointer;
}

body.wcof-drawer-open .wcof-overlay {
    opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════
   Off-Canvas Drawer
   ═══════════════════════════════════════════════════════════════ */
.wcof-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--wcof-drawer-width);
    max-width: calc(100vw - 48px);
    background: var(--wcof-bg);
    z-index: var(--wcof-z-drawer);
    display: flex;
    flex-direction: column;
    transform: translateX(-110%);
    transition: transform var(--wcof-transition);
    border-radius: 0 var(--wcof-radius) var(--wcof-radius) 0;
    box-shadow: var(--wcof-shadow);
    will-change: transform;
    overscroll-behavior: contain;
}

/* Right-side drawer option */
.wcof-drawer.wcof-drawer--right {
    left: auto;
    right: 0;
    transform: translateX(110%);
    border-radius: var(--wcof-radius) 0 0 var(--wcof-radius);
}

.wcof-drawer.is-open {
    transform: translateX(0);
}

/* ── Header ── */
.wcof-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--wcof-border);
    background: linear-gradient(135deg, var(--wcof-accent) 0%, var(--wcof-accent-dark) 100%);
    border-radius: 0 var(--wcof-radius) 0 0;
    flex-shrink: 0;
}

.wcof-drawer--right .wcof-drawer__header {
    border-radius: var(--wcof-radius) 0 0 0;
}

.wcof-drawer__title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -.2px;
}

.wcof-drawer__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,.18);
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    transition: background .2s ease, transform .15s ease;
    flex-shrink: 0;
    padding: 0;
}

.wcof-drawer__close:hover {
    background: rgba(255,255,255,.32);
    transform: rotate(90deg);
}

.wcof-drawer__close:focus-visible {
    outline: 2px solid rgba(255,255,255,.8);
    outline-offset: 2px;
}

/* ── Body / Scrollable area ── */
.wcof-drawer__body {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 24px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    /* Custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--wcof-border) transparent;
    height:60vh;
}

.wcof-drawer__body::-webkit-scrollbar        { width: 4px; }
.wcof-drawer__body::-webkit-scrollbar-track  { background: transparent; }
.wcof-drawer__body::-webkit-scrollbar-thumb  { background: var(--wcof-border); border-radius: 4px; }

/* ── Footer ── */
.wcof-drawer__footer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--wcof-border);
    background: #f9fafb;
    border-radius: 0 0 var(--wcof-radius) 0;
    flex-shrink: 0;
}

.wcof-drawer--right .wcof-drawer__footer {
    border-radius: 0 0 0 var(--wcof-radius);
}

.wcof-drawer__apply {
    flex: 1;
    padding: 12px 16px;
    background: var(--wcof-accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background .2s ease, transform .12s ease;
    letter-spacing: .2px;
}

.wcof-drawer__apply:hover   { background: var(--wcof-accent-dark); }
.wcof-drawer__apply:active  { transform: scale(.97); }

.wcof-drawer__reset {
    padding: 12px 14px;
    border: 1.5px solid var(--wcof-border);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--wcof-text-muted);
    text-decoration: none;
    transition: border-color .2s ease, color .2s ease;
    white-space: nowrap;
}

.wcof-drawer__reset:hover {
    border-color: #ef4444;
    color: #ef4444;
}

/* ═══════════════════════════════════════════════════════════════
   WooCommerce Widget overrides inside the drawer
   ═══════════════════════════════════════════════════════════════ */
.wcof-drawer__body .widget {
    margin-bottom: 0;
    border-bottom: 1px solid var(--wcof-border);
    padding-bottom: 16px;
    margin-bottom: 16px;
}

.wcof-drawer__body .widget:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.wcof-drawer__body .widget-title,
.wcof-drawer__body .widgettitle {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--wcof-text-muted);
    margin-bottom: 12px;
}

/* Price slider */
.wcof-drawer__body .price_slider_wrapper {
    padding-top: 4px;
}

.wcof-drawer__body .ui-slider-horizontal {
    height: 4px;
    background: var(--wcof-border);
    border-radius: 4px;
    border: none;
    box-shadow: none;
}

.wcof-drawer__body .ui-slider .ui-slider-range {
    background: var(--wcof-accent);
}

.wcof-drawer__body .ui-slider .ui-slider-handle {
    width: 18px;
    height: 18px;
    background: var(--wcof-accent);
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
    border-radius: 50%;
    top: -7px;
    cursor: grab;
    transition: transform .15s ease;
}

.wcof-drawer__body .ui-slider .ui-slider-handle:active { cursor: grabbing; transform: scale(1.2); }

/* Checkbox & radio lists */
.wcof-drawer__body .wc-block-components-checkbox,
.wcof-drawer__body ul.woocommerce-widget-layered-nav-list li,
.wcof-drawer__body ul.product-categories li {
    margin-bottom: 8px;
}

.wcof-drawer__body ul.woocommerce-widget-layered-nav-list li a,
.wcof-drawer__body ul.product-categories li a {
    font-size: 14px;
    color: var(--wcof-text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color .15s ease;
}

.wcof-drawer__body ul.woocommerce-widget-layered-nav-list li a:hover,
.wcof-drawer__body ul.product-categories li a:hover {
    color: var(--wcof-accent);
}

/* Star ratings */
.wcof-drawer__body .woocommerce-widget-rating-filter .wc-layered-nav-rating a {
    font-size: 14px;
    color: var(--wcof-text);
}

/* ═══════════════════════════════════════════════════════════════
   Body scroll lock when drawer is open
   ═══════════════════════════════════════════════════════════════ */
body.wcof-drawer-open {
    overflow: hidden;
    touch-action: none;
}

/* ═══════════════════════════════════════════════════════════════
   Responsive — Mobile breakpoint (injected by JS, but also defined here)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 991px) {

    /* Show filter button */
    .wcof-filter-btn {
        display: inline-flex;
    }

    /* Show overlay */
    .wcof-overlay {
        display: block;
    }

    /* Hide sidebar in normal flow on mobile (it's in the drawer) */
    .woocommerce-page .col-md-3.col-sm-12:not(#wcof-drawer),
    .woocommerce-page #secondary:not(#wcof-drawer),
    .woocommerce-page aside.widget-area:not(#wcof-drawer .widget-area) {
        /* We leave the sidebar visible in the DOM but the drawer contains its copy.
           Themes vary – JS moves / clones the sidebar content. */
    }
}

/* ═══════════════════════════════════════════════════════════════
   Desktop — Drawer & button hidden; sidebar behaves normally
   ═══════════════════════════════════════════════════════════════ */
@media (min-width: 992px) {
    .wcof-filter-btn,
    .wcof-overlay {
        display: none !important;
    }

    .wcof-drawer {
        /* On desktop, render as normal sidebar widget area */
        position: static !important;
        transform: none !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        background: transparent !important;
        display: block !important;
        overflow: visible !important;
    }

    .wcof-drawer__header,
    .wcof-drawer__footer {
        display: none !important;
    }

    .wcof-drawer__body {
        overflow: visible !important;
        padding: 0 !important;
    }

    body.wcof-drawer-open {
        overflow: auto !important;
        touch-action: auto !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   Entrance animation for drawer items
   ═══════════════════════════════════════════════════════════════ */
.wcof-drawer.is-open .widget {
    animation: wcof-slide-in .3s ease forwards;
}

.wcof-drawer.is-open .widget:nth-child(1) { animation-delay: .05s; }
.wcof-drawer.is-open .widget:nth-child(2) { animation-delay: .10s; }
.wcof-drawer.is-open .widget:nth-child(3) { animation-delay: .15s; }
.wcof-drawer.is-open .widget:nth-child(4) { animation-delay: .20s; }
.wcof-drawer.is-open .widget:nth-child(5) { animation-delay: .25s; }

@keyframes wcof-slide-in {
    from { opacity: 0; transform: translateX(-16px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ── Reduced motion preference ── */
@media (prefers-reduced-motion: reduce) {
    .wcof-drawer,
    .wcof-overlay,
    .wcof-filter-btn,
    .wcof-drawer.is-open .widget {
        transition: none !important;
        animation: none !important;
    }
}

/* ── Empty state message ─────────────────────────────────────────────── */
.wcof-no-filters {
    font-size: 13px;
    color: var(--wcof-text-muted);
    padding: 20px;
    text-align: center;
    border: 2px dashed var(--wcof-border);
    border-radius: 10px;
    line-height: 1.6;
}
.wcof-no-filters a {
    color: var(--wcof-accent);
    text-decoration: underline;
}
