/* Page — archive-product.php Shop page, product category/tag archives, and product-scoped search results all share this one template and this one… */

/* Same top/bottom breathing room every other listing page gets from its
   own wrapping section (e.g. .blog-section on index.php) — archive-product.php
   had no equivalent, so the title/filters/grid sat flush against the header. */
.shop-section { padding: var(--sp-7) 0; }

.shop__header { text-align: center; }
.shop__count { font-size: var(--fs-sm); color: var(--color-text-light); }

/* Sits below the product grid now (SEO copy, not something shoppers need
   before they can see products) — a top divider + max-width keeps it
   readable instead of running the full grid width. */
.term-description {
    margin-top: var(--sp-7);
    padding-top: var(--sp-6);
    border-top: 1px solid var(--color-border);
    color: var(--color-text-light);
}

/* ── Layout: sidebar + content ─────────────────────────────────────────── */
.shop__layout { display: flex; align-items: flex-start; gap: var(--sp-6); }
.shop__sidebar { width: 300px; flex-shrink: 0; }
.shop__content { flex: 1; min-width: 0; }
.shop__content.is-loading { opacity: .45; pointer-events: none; transition: opacity .15s ease; }

.shop__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--sp-3);
    margin-bottom: var(--sp-5);
}
.shop__toolbar-actions { display: flex; align-items: center; gap: var(--sp-3); }

.shop__filters-btn {
    display: none;
    align-items: center;
    gap: var(--sp-2);
    height: var(--control-height-sm);
    padding: 0 var(--sp-4);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--color-text);
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color var(--transition);
}
.shop__filters-btn:hover { border-color: var(--color-primary); }

/* WooCommerce core ships .woocommerce-ordering with its own margin (meant for it sitting alone above the loop) — dead weight now that it's a flex child… */
.woocommerce .woocommerce-ordering { margin: 0; }

.woocommerce-ordering select {
    min-height: var(--control-height-sm);
    padding: 0 36px 0 var(--sp-4);
    font-size: var(--fs-sm);
    color: var(--color-text);
    background: var(--color-bg);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%231b2530' stroke-width='2'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
}
.woocommerce-ordering select:hover { border-color: var(--color-primary-light); }
.woocommerce-ordering select:focus { border-color: var(--color-primary); box-shadow: var(--focus-ring); outline: none; }

/* .shop__grid base rule lives in main.css — shared with single-product.php's related-products section. */

.shop__empty {
    padding: var(--sp-7) 0;
    color: var(--color-text-light);
    text-align: center;
}

/* ── Shop filters sidebar ───────────────────────────────────────────────── BEM component shared by every filter group (price, each pa_* attribute):… */

.shop-filters__popup-header,
.shop-filters__popup-footer { display: none; }

.shop-filters__active {
    padding: var(--sp-4) 0;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: var(--sp-1);
}
.shop-filters__active-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-3); }
.shop-filters__active-title { font-size: var(--fs-sm); font-weight: 600; color: var(--color-text); }
.shop-filters__active-clear { font-size: var(--fs-sm); color: var(--color-primary); transition: opacity var(--transition); }
.shop-filters__active-clear:hover { opacity: .7; }

.shop-filters__active-pills { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.shop-filters__active-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-1) var(--sp-3);
    background: var(--color-bg-alt);
    border-radius: var(--radius);
    font-size: var(--fs-xs);
    color: var(--color-text);
    transition: background var(--transition);
}
.shop-filters__active-pill:hover { background: var(--color-border); }

.shop-filters__group { border-bottom: 1px solid var(--color-border); }
.shop-filters__group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 50px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: var(--fs-base);
    font-weight: 600;
    color: var(--color-text);
    text-align: left;
}
.shop-filters__group-arrow { flex-shrink: 0; transition: transform var(--transition); }
.shop-filters__group.is-open .shop-filters__group-arrow { transform: rotate(180deg); }

.shop-filters__group-body { overflow: hidden; max-height: 0; transition: max-height .25s ease; }
.shop-filters__group.is-open .shop-filters__group-body { max-height: 320px; overflow-y: auto; }

.shop-filters__item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) 0;
    color: var(--color-text);
    transition: color var(--transition);
}
.shop-filters__item:hover { color: var(--color-primary); }
.shop-filters__item:last-child { margin-bottom: var(--sp-3); }

.shop-filters__checkbox {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    transition: background var(--transition), border-color var(--transition);
}
.shop-filters__item.is-active .shop-filters__checkbox { background: var(--color-primary); border-color: var(--color-primary); }

.shop-filters__item-label { flex: 1; font-size: var(--fs-sm); }
.shop-filters__item-count { flex-shrink: 0; font-size: var(--fs-xs); color: var(--color-muted); }

/* ── Price range slider ───────────────────────────────────────────────── */
.shop-filters__price-form { padding: var(--sp-3) 0 var(--sp-5); }
.shop-filters__price-header { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--color-text); margin-bottom: var(--sp-4); }

.shop-filters__price-slider { position: relative; height: 24px; margin-bottom: var(--sp-4); }
.shop-filters__price-track {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 4px;
    transform: translateY(-50%);
    background: var(--color-border);
    border-radius: var(--radius-pill);
}
.shop-filters__price-fill { position: absolute; height: 100%; background: var(--color-accent); border-radius: var(--radius-pill); }

.shop-filters__range {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    pointer-events: none;
    margin: 0;
}
.shop-filters__range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: var(--radius-pill);
    background: var(--color-accent);
    border: 2px solid var(--color-bg);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    pointer-events: all;
    position: relative;
}
.shop-filters__range::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: var(--radius-pill);
    background: var(--color-accent);
    border: 2px solid var(--color-bg);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    pointer-events: all;
}
.shop-filters__range::-moz-range-track { background: transparent; border: none; }

.shop-filters__price-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--control-height-sm);
    padding: 0 var(--sp-5);
    background: var(--color-primary);
    border: none;
    border-radius: var(--radius);
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--color-on-dark);
    cursor: pointer;
    transition: background var(--transition);
}
.shop-filters__price-submit:hover { background: var(--color-primary-light); }

/* ── Mobile drawer backdrop ───────────────────────────────────────────── */
.shop-filters-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(27, 37, 48, .45);
    z-index: var(--z-backdrop);
    cursor: pointer;
}
.shop-filters-overlay.is-active { display: block; }

/* The grid sits next to a 300px sidebar down to 767px (below that the sidebar becomes a drawer), so its real available width is much narrower than the… */
@media (max-width: 1365px) {
    .shop__grid, .shop__categories { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1023px) {
    .shop__grid, .shop__categories { grid-template-columns: repeat(2, 1fr); }
    .shop__sidebar { width: 275px; }
}

@media (max-width: 767px) {
    .shop__grid, .shop__categories { grid-template-columns: repeat(2, 1fr); gap: var(--sp-4); }

    /* Below 767px the count text + "Фильтры" + sort select no longer reliably fit on one line — depending on exact width they'd wrap with the count alone… */
    .shop__toolbar { flex-direction: column; align-items: stretch; }
    .shop__toolbar-actions { width: 100%; }

    .shop__filters-btn { display: inline-flex; flex: 1 1 0; justify-content: center; }
    .woocommerce-ordering { flex: 1 1 0; }
    .woocommerce-ordering select { width: 100%; }

    /* Sidebar becomes a fixed off-canvas drawer, opened via .shop__filters-btn */
    .shop__sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        z-index: var(--z-modal);
        background: var(--color-bg);
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform .3s ease;
        box-shadow: var(--shadow-lg);
        display: flex;
        flex-direction: column;
    }
    .shop__sidebar.is-open { transform: translateX(0); }

    .shop-filters__popup-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-shrink: 0;
        padding: var(--sp-4) var(--sp-5);
        border-bottom: 1px solid var(--color-border);
    }
    .shop-filters__popup-title { font-size: var(--fs-h4); font-weight: 700; color: var(--color-text); }
    .shop-filters__popup-close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border: none;
        background: none;
        cursor: pointer;
        color: var(--color-text);
        padding: 0;
    }

    .shop-filters { flex: 1; overflow-y: auto; padding: 0 var(--sp-5); }

    .shop-filters__popup-footer {
        display: flex;
        gap: var(--sp-3);
        padding: var(--sp-4) var(--sp-5);
        border-top: 1px solid var(--color-border);
        flex-shrink: 0;
        background: var(--color-bg);
    }
    .shop-filters__popup-apply {
        flex: 1;
        height: var(--control-height);
        border: none;
        border-radius: var(--radius);
        background: var(--color-accent);
        font-size: var(--fs-base);
        font-weight: 600;
        color: var(--color-primary);
        cursor: pointer;
        transition: background var(--transition);
    }
    .shop-filters__popup-apply:hover { background: var(--color-accent-hover); }
    .shop-filters__popup-clear {
        flex: 1;
        height: var(--control-height);
        border: 1px solid var(--color-border);
        border-radius: var(--radius);
        background: var(--color-bg);
        font-size: var(--fs-base);
        font-weight: 600;
        color: var(--color-text);
        cursor: pointer;
        transition: border-color var(--transition);
    }
    .shop-filters__popup-clear:hover { border-color: var(--color-primary); }
}
