/* Catalog redesign — scoped to .catalog-page */
.catalog-page {
    --catalog-brand: #585e92;
    --catalog-brand-hover: #484e80;
    --catalog-accent: #858fdf;
    --catalog-page-bg: #faf9f7;
    --catalog-surface: #ffffff;
    --catalog-text: #24242a;
    --catalog-muted: #6d6d75;
    --catalog-border: #e7e5e2;
    --catalog-success: #2f7d32;
    --catalog-sale: #d94848;
    background: var(--catalog-page-bg);
}

.catalog-page .catalog-container,
.catalog-page .catalog-content > .container,
.catalog-page .wc-page {
    max-width: 1400px;
}

.catalog-page .main-content {
    background: transparent;
}

/* Hide legacy FAB */
.catalog-page .fab-filters {
    display: none !important;
}

.catalog-page .catalog-header h1 {
    font-family: "Playfair Display", Georgia, serif;
    color: var(--catalog-text);
}

.catalog-page .catalog-lead {
    margin: 8px 0 14px;
    color: var(--catalog-muted);
    font-size: 0.98rem;
    line-height: 1.45;
    max-width: 42rem;
}

.catalog-search {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 0 0 14px;
    position: relative;
}

.catalog-search__input {
    flex: 1;
    min-height: 44px;
    border: 1px solid var(--catalog-border);
    border-radius: 12px;
    padding: 10px 40px 10px 14px;
    font-size: 16px;
    background: var(--catalog-surface);
    color: var(--catalog-text);
}

.catalog-search__clear {
    position: absolute;
    right: 104px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: var(--catalog-muted);
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
}

.catalog-search__btn {
    min-height: 44px;
    min-width: 88px;
    border: none;
    border-radius: 12px;
    background: var(--catalog-brand);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    padding: 0 14px;
}

.catalog-search__btn:hover {
    background: var(--catalog-brand-hover);
}

/* Toolbar */
.catalog-toolbar {
    display: none;
}

@media (max-width: 900px) {
    .catalog-page .filters-mobile-bar {
        display: none !important;
    }

    .catalog-toolbar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        position: sticky;
        top: 0;
        z-index: 30;
        padding: 8px 0;
        background: rgba(250, 249, 247, 0.96);
        backdrop-filter: blur(6px);
        margin-bottom: 10px;
    }

    .catalog-toolbar__btn {
        min-height: 44px;
        border: 1px solid var(--catalog-border);
        border-radius: 12px;
        background: var(--catalog-surface);
        color: var(--catalog-text);
        font-weight: 600;
        font-size: 0.9rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        cursor: pointer;
        padding: 0 10px;
    }

    .catalog-toolbar__btn svg {
        flex-shrink: 0;
    }

    .catalog-toolbar__badge {
        display: inline-flex;
        min-width: 20px;
        height: 20px;
        padding: 0 6px;
        border-radius: 999px;
        background: var(--catalog-brand);
        color: #fff;
        font-size: 0.75rem;
        align-items: center;
        justify-content: center;
    }

    .catalog-toolbar__badge:empty,
    .catalog-toolbar__badge[hidden] {
        display: none;
    }
}

/* Categories */
.catalog-page .category-carousel .carousel-item,
.catalog-page .carousel-item {
    min-width: 148px;
    height: 68px;
}

.catalog-page .carousel-item.is-active,
.catalog-page .carousel-item.active {
    background: rgba(88, 94, 146, 0.1);
    border-color: var(--catalog-brand);
}

/* Chips */
.catalog-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin: 0 0 14px;
    padding: 2px 0;
}

.catalog-chips::-webkit-scrollbar {
    display: none;
}

.catalog-chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid var(--catalog-border);
    background: var(--catalog-surface);
    color: var(--catalog-text);
    font-size: 0.85rem;
    text-decoration: none;
    white-space: nowrap;
}

.catalog-chip__x {
    color: var(--catalog-muted);
    font-weight: 700;
}

.catalog-chip--clear {
    border-color: transparent;
    background: rgba(88, 94, 146, 0.1);
    color: var(--catalog-brand);
    font-weight: 600;
}

/* Grid */
.catalog-page .products-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 18px;
}

@media (max-width: 768px) {
    .catalog-page .products-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }
}

/* Product card */
.catalog-page .product-card {
    display: flex;
    flex-direction: column;
    background: var(--catalog-surface);
    border: 1px solid var(--catalog-border);
    border-radius: 16px;
    overflow: hidden;
    height: 100%;
    box-shadow: none;
}

/* Старые стили каталога вешали display:flex;height:100% на любые <a> внутри карточки —
   из‑за этого title-link растягивался и наезжал на размер / pet-safe. */
.catalog-page .product-card > a {
    display: contents;
}

.catalog-page .product-card a.product-card__image-link {
    display: block !important;
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: auto !important;
    flex: none !important;
    flex-direction: unset !important;
    text-decoration: none;
    color: inherit;
    z-index: 1;
}

.catalog-page .product-card a.product-card__title-link {
    display: block !important;
    position: static !important;
    width: 100% !important;
    height: auto !important;
    flex: 0 0 auto !important;
    flex-direction: unset !important;
    text-decoration: none;
    color: inherit;
}

.catalog-page .product-card__media {
    position: relative;
    aspect-ratio: 1 / 1;
    background: #f1f0ee;
    flex-shrink: 0;
}

.catalog-page .product-card__media img,
.catalog-page .product-card .product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.catalog-page .product-card .product-image {
    position: relative;
    aspect-ratio: 1 / 1;
    margin: 0;
    overflow: hidden;
    background: #f1f0ee;
    padding-bottom: 0 !important;
    height: auto !important;
}

.catalog-page .product-size-badge {
    display: none !important;
}

.catalog-page .product-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    background: var(--catalog-sale);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 999px;
}

.catalog-page .product-card .pc-actions {
    top: 8px;
    right: 8px;
    left: auto;
    z-index: 3;
}

.catalog-page .product-card .pc-action {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
}

@media (min-width: 769px) {
    .catalog-page .product-card .pc-action {
        width: 36px;
        height: 36px;
    }
}

.catalog-page .product-card__body,
.catalog-page .product-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    flex: 1 1 auto;
    min-height: 0;
    position: static !important;
    box-sizing: border-box;
}

.catalog-page .product-card__meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 2.75rem;
}

.catalog-page .product-title {
    font-family: Inter, system-ui, sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.25;
    color: var(--catalog-text);
    margin: 0;
    min-height: 2.5em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (min-width: 769px) {
    .catalog-page .product-title {
        font-size: 1rem;
    }
}

.catalog-page .product-card__size {
    font-size: 0.78rem;
    color: var(--catalog-muted);
    line-height: 1.35;
    margin: 0;
}

.catalog-page .catalog-product-pet-safe {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin: 0;
    color: var(--catalog-success);
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.3;
    max-width: 100%;
}

.catalog-page .catalog-product-pet-safe__icon {
    width: 18px;
    height: 14px;
    flex-shrink: 0;
    margin-top: 1px;
    object-fit: contain;
    display: block;
}

.catalog-page .catalog-product-pet-safe__text {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
}

.catalog-page .product-category {
    display: none;
}

.catalog-page.catalog-section-all .product-category {
    display: block;
    font-size: 0.78rem;
    color: var(--catalog-muted);
    margin: 0;
}

.catalog-page .product-prices {
    margin-top: auto;
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 2px;
}

.catalog-page .product-price {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--catalog-brand);
}

@media (min-width: 769px) {
    .catalog-page .product-price {
        font-size: 1.3rem;
    }
}

.catalog-page .product-old-price {
    font-size: 0.85rem;
    color: var(--catalog-muted);
    text-decoration: line-through;
}

.catalog-page .product-price.is-sale,
.catalog-page .product-card.has-sale .product-price {
    color: var(--catalog-sale);
}

.catalog-page .add-to-cart-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    position: static !important;
    width: 100% !important;
    min-height: 40px;
    height: auto !important;
    margin-top: 4px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    border: none;
    border-radius: 12px;
    background: var(--catalog-brand) !important;
    color: #fff !important;
    font-weight: 600;
    line-height: 1.2 !important;
    box-shadow: none !important;
    cursor: pointer;
    flex-shrink: 0;
}

.catalog-page .add-to-cart-btn:hover {
    background: var(--catalog-brand-hover) !important;
}

.catalog-page .add-to-cart-btn.is-added {
    background: var(--catalog-success) !important;
}

@media (min-width: 769px) {
    .catalog-page .add-to-cart-btn {
        min-height: 42px;
    }
}

/* Desktop filters */
@media (min-width: 901px) {
    .catalog-page .catalog-filters {
        width: 276px;
        border: 1px solid var(--catalog-border);
        border-radius: 16px;
        background: var(--catalog-surface);
        padding: 18px;
        position: sticky;
        top: 88px;
        max-height: calc(100vh - 110px);
        overflow: auto;
        box-shadow: none;
    }

    .catalog-page .filter-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        margin-bottom: 12px;
    }

    .catalog-page .filter-header h3 {
        margin: 0;
        font-size: 1.05rem;
    }

    .catalog-page .filter-header .btn {
        border: none;
        background: transparent;
        color: var(--catalog-brand);
        padding: 0;
        min-height: auto;
        text-decoration: underline;
    }

    .catalog-page .price-range {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
        gap: 8px;
        align-items: center;
    }

    .catalog-page .price-presets {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        margin-top: 10px;
    }

    .catalog-page .price-preset {
        border: 1px solid var(--catalog-border);
        background: #fff;
        border-radius: 999px;
        padding: 6px 10px;
        font-size: 0.78rem;
        cursor: pointer;
        color: var(--catalog-text);
    }
}

.catalog-page .filter-title {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    cursor: pointer;
    font-weight: 600;
}

.catalog-page .filter-option {
    min-height: 44px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
}

.catalog-page .filter-option input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    flex-shrink: 0;
}

.catalog-page .filter-option__count {
    color: var(--catalog-muted);
    font-size: 0.85rem;
    margin-left: auto;
}

.catalog-page .filter-swatch {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.12);
    flex-shrink: 0;
    margin-top: 4px;
}

.catalog-page .filter-more-btn {
    margin-top: 6px;
    border: none;
    background: transparent;
    color: var(--catalog-brand);
    font-weight: 600;
    cursor: pointer;
    min-height: 40px;
}

/* Mobile fullscreen filters */
@media (max-width: 900px) {
    .catalog-page .catalog-filters {
        position: fixed;
        inset: 0;
        z-index: 1400;
        width: 100% !important;
        max-width: none !important;
        height: 100%;
        border-radius: 0;
        transform: translateY(110%);
        transition: transform 0.28s ease;
        display: flex;
        flex-direction: column;
        padding: 0;
        background: #fff;
    }

    .catalog-page .catalog-filters.active {
        transform: translateY(0);
    }

    .catalog-page body.filters-open,
    body.filters-open {
        overflow: hidden;
    }

    body.filters-open .bottom-nav,
    body.filters-open .wb-cart-bar,
    body.filters-open .compare-sticky-bar,
    body.filters-open .favorites-fab {
        visibility: hidden !important;
        pointer-events: none !important;
    }

    .catalog-page .catalog-filters .filter-header {
        position: sticky;
        top: 0;
        z-index: 2;
        display: flex;
        align-items: center;
        gap: 8px;
        min-height: calc(56px + env(safe-area-inset-top, 0px));
        padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
        border-bottom: 1px solid var(--catalog-border);
        background: #fff;
        margin: 0;
    }

    .catalog-page .catalog-filters .filter-header h3 {
        flex: 1;
        margin: 0;
    }

    .catalog-filters__close {
        width: 44px;
        height: 44px;
        border: none;
        background: transparent;
        font-size: 1.5rem;
        cursor: pointer;
        color: var(--catalog-text);
    }

    .catalog-page #filterForm {
        flex: 1;
        overflow: auto;
        padding: 8px 16px 120px;
        -webkit-overflow-scrolling: touch;
    }

    .catalog-filters__footer {
        position: sticky;
        bottom: 0;
        z-index: 2;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
        background: #fff;
        border-top: 1px solid var(--catalog-border);
    }

    .catalog-filters__apply {
        width: 100%;
        min-height: 48px;
        border: none;
        border-radius: 12px;
        background: var(--catalog-brand);
        color: #fff;
        font-weight: 700;
        font-size: 1rem;
        cursor: pointer;
    }

    .catalog-page .filters-backdrop.show {
        position: fixed;
        inset: 0;
        z-index: 1390;
        background: rgba(20, 20, 28, 0.45);
    }
}

.catalog-page .no-results {
    text-align: center;
    padding: 40px 16px;
    background: var(--catalog-surface);
    border-radius: 16px;
    border: 1px solid var(--catalog-border);
}

.catalog-page .results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.catalog-page .results-count {
    color: var(--catalog-muted);
    font-size: 0.95rem;
}

@media (max-width: 900px) {
    .catalog-page .results-header .sort-select-wrap {
        display: none;
    }
}

.catalog-sort-sheet {
    display: none;
}

@media (max-width: 900px) {
    .catalog-sort-sheet.is-open {
        display: block;
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        z-index: 1450;
        background: #fff;
        border-radius: 16px;
        border: 1px solid var(--catalog-border);
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
        padding: 12px;
    }

    .catalog-sort-sheet button {
        display: block;
        width: 100%;
        min-height: 44px;
        border: none;
        background: transparent;
        text-align: left;
        padding: 0 12px;
        border-radius: 10px;
        font-size: 0.95rem;
        cursor: pointer;
    }

    .catalog-sort-sheet button.is-active {
        background: rgba(88, 94, 146, 0.1);
        color: var(--catalog-brand);
        font-weight: 600;
    }
}

.catalog-page .visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0);
    white-space: nowrap; border: 0;
}

@media (max-width: 768px) {
    .catalog-page .product-card .product-info {
        position: static !important;
        padding-bottom: 12px !important;
        gap: 8px;
    }
    .catalog-page .product-card .add-to-cart-btn {
        position: static !important;
        display: flex !important;
        width: 100% !important;
        right: auto !important;
        bottom: auto !important;
        left: auto !important;
        height: 40px !important;
        line-height: 1.2 !important;
        background: var(--catalog-brand) !important;
        color: #fff !important;
        box-shadow: none !important;
        margin-top: 6px !important;
    }
    .catalog-page .product-card__meta {
        min-height: 2.9rem;
    }
    .catalog-page .product-title {
        font-size: 0.88rem;
        min-height: 2.4em;
    }
    .catalog-page .catalog-product-pet-safe {
        font-size: 0.68rem;
    }
}
