/**
 * HDTheme Shop Filters — Offcanvas, badges, filter bar, category links
 *
 * @package HDTheme
 */

/* ── Body lock when offcanvas open ──────────────────────────────────────── */
body.hd-offcanvas-open {
    overflow: hidden;
}

/* ── Backdrop ───────────────────────────────────────────────────────────── */
.hd-offcanvas-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s ease, visibility 0.28s ease;
}
.hd-offcanvas-backdrop.is-visible {
    opacity: 1;
    visibility: visible;
}

/* ── Offcanvas panel ────────────────────────────────────────────────────── */
.hd-filter-offcanvas {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 340px;
    max-width: 90vw;
    background: #fff;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
    overflow: hidden;
}
.hd-filter-offcanvas.is-open {
    transform: translateX(0);
}

/* ── Offcanvas header ───────────────────────────────────────────────────── */
.hd-offcanvas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--hd-color-border, #e8e4de);
    flex-shrink: 0;
}
.hd-offcanvas-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
    color: var(--hd-color-text, #1a1a1a);
    margin: 0;
}
.hd-offcanvas-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.hd-offcanvas-clear {
    background: none;
    border: none;
    padding: 0;
    font-size: 13px;
    color: var(--hd-color-text-dim, #888);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.2s;
}
.hd-offcanvas-clear:hover {
    color: var(--hd-color-text, #1a1a1a);
}
.hd-offcanvas-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    border-radius: var(--hd-radius-sm, 6px);
    cursor: pointer;
    color: var(--hd-color-text, #1a1a1a);
    transition: background 0.2s;
    padding: 0;
}
.hd-offcanvas-close:hover {
    background: var(--hd-color-bg-subtle, #f5f2ee);
}

/* ── Offcanvas body ─────────────────────────────────────────────────────── */
.hd-offcanvas-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    -webkit-overflow-scrolling: touch;
}

/* ── Filter group (accordion) ───────────────────────────────────────────── */
.hd-filter-group {
    border-bottom: 1px solid var(--hd-color-border, #e8e4de);
}
.hd-filter-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--hd-color-text, #1a1a1a);
    text-align: left;
    transition: background 0.15s;
}
.hd-filter-group-toggle:hover {
    background: var(--hd-color-bg-subtle, #f5f2ee);
}
.hd-fg-chevron {
    color: var(--hd-color-text-dim, #888);
    transition: transform 0.22s ease;
    flex-shrink: 0;
}
.hd-filter-group-toggle[aria-expanded="false"] .hd-fg-chevron {
    transform: rotate(180deg);
}
.hd-filter-group-body {
    padding: 4px 20px 16px;
    transition: none;
}
.hd-filter-group-body.is-collapsed {
    display: none;
}

/* ── Checkbox options ───────────────────────────────────────────────────── */
.hd-filter-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    cursor: pointer;
}
.hd-filter-option:hover .hd-filter-option-label {
    color: var(--hd-color-accent, #c9a96e);
}
.hd-filter-checkbox {
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--hd-color-border, #e8e4de);
    border-radius: 3px;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
    background: #fff;
    transition: background 0.15s, border-color 0.15s;
}
.hd-filter-checkbox:checked {
    background: var(--hd-color-accent, #c9a96e);
    border-color: var(--hd-color-accent, #c9a96e);
}
.hd-filter-checkbox:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 5px;
    width: 4px;
    height: 8px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
}
.hd-filter-option-label {
    font-size: 13px;
    color: var(--hd-color-text, #1a1a1a);
    line-height: 1.4;
    transition: color 0.15s;
}

/* ── Price range inputs ─────────────────────────────────────────────────── */
.hd-price-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
}
.hd-price-input-wrap {
    display: flex;
    align-items: center;
    border: 1.5px solid var(--hd-color-border, #e8e4de);
    border-radius: var(--hd-radius-sm, 6px);
    padding: 0 10px;
    gap: 4px;
    flex: 1;
    transition: border-color 0.2s;
}
.hd-price-input-wrap:focus-within {
    border-color: var(--hd-color-accent, #c9a96e);
}
.hd-price-symbol {
    font-size: 12px;
    color: var(--hd-color-text-dim, #888);
    flex-shrink: 0;
}
.hd-price-input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 13px;
    color: var(--hd-color-text, #1a1a1a);
    width: 100%;
    padding: 8px 0;
    -moz-appearance: textfield;
}
.hd-price-input::-webkit-outer-spin-button,
.hd-price-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
}
.hd-price-sep {
    font-size: 13px;
    color: var(--hd-color-text-dim, #888);
    flex-shrink: 0;
}

/* ── Offcanvas footer ───────────────────────────────────────────────────── */
.hd-offcanvas-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--hd-color-border, #e8e4de);
    flex-shrink: 0;
}
.hd-offcanvas-apply {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 13px 20px;
    background: var(--hd-color-text, #1a1a1a);
    color: #fff;
    border: none;
    border-radius: var(--hd-radius-md, 8px);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.hd-offcanvas-apply:hover {
    background: var(--hd-color-accent, #c9a96e);
}
.hd-offcanvas-apply-count {
    font-weight: 400;
    opacity: 0.8;
}

/* ── Shop filter bar ────────────────────────────────────────────────────── */
.hd-shop-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-top: 1px solid var(--hd-color-border, #e8e4de);
    border-bottom: 1px solid var(--hd-color-border, #e8e4de);
    margin-bottom: 28px;
    gap: 12px;
}
.hd-shop-bar-left,
.hd-shop-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Filter trigger button */
.hd-filter-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: none;
    border: 1.5px solid var(--hd-color-border, #e8e4de);
    border-radius: var(--hd-radius-full, 999px);
    font-size: 13px;
    font-weight: 600;
    color: var(--hd-color-text, #1a1a1a);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    position: relative;
}
.hd-filter-trigger:hover,
.hd-filter-trigger[aria-expanded="true"] {
    border-color: var(--hd-color-text, #1a1a1a);
    background: var(--hd-color-bg-subtle, #f5f2ee);
}
.hd-filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    background: var(--hd-color-accent, #c9a96e);
    color: #fff;
    border-radius: var(--hd-radius-full, 999px);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

/* Product count */
.hd-product-count {
    font-size: 13px;
    color: var(--hd-color-text-dim, #888);
}

/* Sort select */
.hd-shop-sort-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.hd-shop-sort-select {
    appearance: none;
    -webkit-appearance: none;
    background: none;
    border: 1.5px solid var(--hd-color-border, #e8e4de);
    border-radius: var(--hd-radius-full, 999px);
    padding: 8px 36px 8px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--hd-color-text, #1a1a1a);
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}
.hd-shop-sort-select:hover,
.hd-shop-sort-select:focus {
    border-color: var(--hd-color-text, #1a1a1a);
}
.hd-sort-chevron {
    position: absolute;
    right: 12px;
    pointer-events: none;
    color: var(--hd-color-text-dim, #888);
}

/* ── Category quick-link buttons ────────────────────────────────────────── */
.hd-shop-cat-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 20px 0;
}
.hd-shop-cat-link {
    display: inline-flex;
    align-items: center;
    padding: 7px 16px;
    background: var(--hd-color-bg-subtle, #f5f2ee);
    border: 1.5px solid transparent;
    border-radius: var(--hd-radius-full, 999px);
    font-size: 13px;
    font-weight: 500;
    color: var(--hd-color-text, #1a1a1a);
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    white-space: nowrap;
}
.hd-shop-cat-link:hover {
    background: #fff;
    border-color: var(--hd-color-border, #e8e4de);
    color: var(--hd-color-accent, #c9a96e);
}
.hd-shop-cat-link.is-active {
    background: var(--hd-color-text, #1a1a1a);
    color: #fff;
    border-color: var(--hd-color-text, #1a1a1a);
}

/* ── Active filter badges row ───────────────────────────────────────────── */
.hd-active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 0 18px;
}
.hd-active-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--hd-color-bg-subtle, #f5f2ee);
    border: 1.5px solid var(--hd-color-border, #e8e4de);
    border-radius: var(--hd-radius-full, 999px);
    font-size: 12px;
    font-weight: 500;
    color: var(--hd-color-text, #1a1a1a);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.hd-active-badge:hover {
    background: #fff;
    border-color: var(--hd-color-text, #1a1a1a);
}
.hd-active-badge-clear {
    background: none;
    border-color: transparent;
    color: var(--hd-color-text-dim, #888);
    text-decoration: underline;
    text-underline-offset: 2px;
    padding-left: 4px;
    padding-right: 4px;
}
.hd-active-badge-clear:hover {
    color: var(--hd-color-text, #1a1a1a);
    background: none;
    border-color: transparent;
}

/* ── Grid loading state ─────────────────────────────────────────────────── */
#hd-shop-grid.hd-loading {
    opacity: 0.45;
    pointer-events: none;
    transition: opacity 0.2s;
}

/* ── No products message ────────────────────────────────────────────────── */
.hd-no-products {
    text-align: center;
    padding: 60px 20px;
    color: var(--hd-color-text-dim, #888);
    font-size: 15px;
    grid-column: 1 / -1;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 575px) {
    .hd-filter-offcanvas {
        width: 100%;
        max-width: 100%;
    }

    .hd-shop-bar {
        flex-wrap: wrap;
        gap: 10px;
    }

    .hd-shop-bar-right {
        width: 100%;
        justify-content: space-between;
    }

    .hd-product-count {
        font-size: 12px;
    }

    .hd-shop-sort-select {
        font-size: 12px;
        padding: 7px 30px 7px 12px;
    }

    .hd-shop-cat-links {
        gap: 6px;
    }

    .hd-shop-cat-link {
        font-size: 12px;
        padding: 6px 12px;
    }
}
