/* --- BREADCRUMBS & CATALOG HEADER --- */

.breadcrumbs {
    padding-top: 30px;
    font-size: 13px;
    color: var(--text-muted);
}
.breadcrumbs span {
    color: var(--text-main);
}
.catalog-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin: 15px 0 30px 0;
    gap: 20px;
    flex-wrap: wrap;
}
.catalog-header h1 {
    font-size: clamp(24px, 5vw, 36px);
    font-weight: 400;
    color: var(--text-main);
}
.catalog-header p {
    font-size: 14px;
    color: var(--text-muted);
}

/* --- LAYOUT & SIDEBAR --- */
.layout {
    display: flex;
    gap: 40px;
    margin-bottom: 60px;
}
aside {
    width: 240px;
    flex-shrink: 0;
    background: var(--white);
    padding: 25px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    height: fit-content;
}
.filter-block {
    margin-bottom: 30px;
}
.filter-block:last-child {
    margin-bottom: 0;
}
.filter-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 15px;
    color: var(--text-main);
}

/* --- Кнопка "Фильтры" (только на мобильных) --- */
.filter-toggle {
    display: none;
    width: 100%;
    padding: 12px 18px;
    background: var(--white);
    border: 1px solid #e0ddd7;
    border-radius: 30px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 15px;
    box-shadow: var(--shadow);
}
.filter-toggle:hover {
    background: #f8f6f2;
    border-color: #ccc;
}
.filter-toggle .arrow {
    transition: transform 0.3s ease;
}
.filter-toggle[aria-expanded="true"] .arrow {
    transform: rotate(180deg);
}

/* --- Содержимое фильтров (скрыто на мобильных, открыто по умолчанию на десктопе) --- */
.filter-content {
    display: block;
}

/* --- CUSTOM CHECKBOXES --- */
.custom-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 10px;
    transition: color 0.2s;
}
.custom-checkbox:hover {
    color: var(--text-main);
}
.custom-checkbox input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.custom-checkbox .checkmark {
    width: 16px;
    height: 16px;
    border: 1px solid #dcd9d3;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
    transition: border-color 0.2s, background 0.2s;
}
.custom-checkbox:hover .checkmark {
    border-color: var(--text-main);
}
.custom-checkbox input:checked + .checkmark {
    background: var(--accent-color);
    border-color: var(--accent-color);
}
.custom-checkbox input:checked + .checkmark::after {
    content: '✓';
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 12px;
    line-height: 1;
}
.custom-checkbox input:checked ~ span {
    color: var(--text-main);
    font-weight: 500;
}
.custom-checkbox input:checked ~ .checkmark {
    background: var(--accent-color);
    border-color: var(--accent-color);
}
.custom-checkbox input:checked ~ .checkmark::after {
    content: '✓';
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 12px;
}
.custom-checkbox input:checked ~ span:not(.checkmark) {
    color: var(--text-main);
    font-weight: 500;
}

/* --- DOUBLE RANGE SLIDER --- */
.price-slider-wrapper {
    position: relative;
    height: 20px;
    margin: 15px 0;
}
.slider-track {
    height: 2px;
    background: #dcd9d3;
    position: absolute;
    width: 100%;
    top: 50%;
    transform: translateY(-50%);
}
.slider-fill {
    position: absolute;
    height: 100%;
    background: var(--accent-color);
    width: 50%;
    left: 0%;
}
.price-range {
    position: absolute;
    width: 100%;
    top: 0;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    z-index: 2;
    height: 10px;
    outline: none;
    margin-top: 5px;
}
.price-range::-webkit-slider-thumb {
    pointer-events: all;
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--white);
    border: 2px solid var(--accent-color);
    cursor: pointer;
    z-index: 3;
    margin-top: -5px;
}
.price-range::-webkit-slider-runnable-track {
    height: 2px;
    background: transparent;
    border: none;
    border-radius: 0;
    cursor: pointer;
}
.price-range::-moz-range-thumb {
    pointer-events: all;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--white);
    border: 2px solid var(--accent-color);
    cursor: pointer;
    z-index: 3;
}
.price-range::-moz-range-track {
    height: 2px;
    background: transparent;
    border: none;
    border-radius: 0;
}
#price-max {
    z-index: 1;
}
.price-values {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 5px;
    gap: 10px;
    flex-wrap: wrap;
}

/* --- SORT SELECT --- */
.sort-select {
    width: 100%;
    padding: 10px;
    border: 1px solid #eee;
    border-radius: 6px;
    background: var(--white);
    color: var(--text-main);
    font-size: 14px;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238a8581' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}
.sort-select:focus {
    border-color: var(--accent-color);
}

/* --- PRODUCT GRID --- */
main {
    flex-grow: 1;
    min-width: 0;
}
.product-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
}
.product-card {
    background: var(--white);
    border-radius: 12px;
    overflow: hidden;
    padding: 20px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, opacity 0.3s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    cursor: pointer;
}
.product-card.hidden {
    display: none;
}
.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}

/* --- КВАДРАТНАЯ КАРТИНКА (aspect-ratio 1:1) --- */
.product-img {
    width: 100%;
    aspect-ratio: 1 / 1;        /* квадрат */
    object-fit: cover;
    border-radius: 8px;
    background-color: #f9f9f9;
    margin-bottom: 15px;
}
/* --- /КВАДРАТНАЯ КАРТИНКА --- */

.no-img {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 14px;
}
.product-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-color-main);
    line-height: 1.3;
    max-height: calc(1.3em * 2);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-wrap: break-word;
}
.product-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 15px;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    max-height: calc(1.4em * 3);
}
.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    gap: 10px;
    flex-wrap: nowrap;
}
.prices {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.price {
    font-size: 17px;
    font-weight: 500;
    white-space: nowrap;
}
.price-hidden {
    color: #888;
    text-decoration: line-through;
    font-size: 0.8em;
    white-space: nowrap;
}
.add-to-cart {
    background: var(--btn-dark);
    color: var(--white);
    border: none;
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}
.add-to-cart:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}
.add-to-cart:active {
    transform: translateY(0);
}

/* --- PAGINATION --- */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 50px;
    flex-wrap: wrap;
}
.pagination button,
.pagination div {
    width: 35px;
    height: 35px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-main);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.pagination .active-page {
    background: var(--accent-color);
    color: var(--white);
}
.pagination .arrow-btn {
    color: var(--text-muted);
}
.pagination button:hover:not(.active-page) {
    background: #f0ece7;
}

/* --- Кнопка "Применить фильтры" --- */
#apply-filters-btn {
    width: 100%;
    padding: 12px;
    background: #fffbec;
    color: #000000;
    border: none;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.2s;
    margin-top: 10px;
}
#apply-filters-btn:hover {
    background: #333;
    color: #fff;
    transform: translateY(-1px);
}
#apply-filters-btn:active {
    transform: translateY(0);
}

/* --- CATALOG MEDIA QUERIES --- */
@media (max-width: 1200px) {
    .product-grid {
        gap: 20px;
    }
}

@media (max-width: 992px) {
    .layout {
        flex-direction: column;
        gap: 30px;
    }
    aside {
        width: 100%;
        box-shadow: none;
        background: transparent;
        padding: 0;
    }
    .filter-toggle {
        display: flex;
    }
    .filter-content {
        display: none;
    }
    .filter-content.open {
        display: block;
    }
    .filter-block {
        background: var(--white);
        padding: 20px;
        border-radius: 12px;
        box-shadow: var(--shadow);
        margin-bottom: 20px;
    }
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .catalog-header {
        flex-direction: column;
        align-items: flex-start;
    }
    /* для картинок ничего не меняем – aspect-ratio сам подстроит размер */
}

/* ---- ОДНА КОЛОНКА НА ТЕЛЕФОНАХ (до 600px) ---- */
@media (max-width: 600px) {
    .product-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .product-card {
        padding: 16px;
    }
    /* картинка остаётся квадратной благодаря aspect-ratio */
    .product-title {
        font-size: 17px;
        max-height: calc(1.3em * 2);
        line-height: 1.3;
    }
    .card-footer {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }
    .prices {
        flex-direction: row;
        align-items: baseline;
        gap: 8px;
    }
    .price {
        font-size: 17px;
    }
    .add-to-cart {
        font-size: 12px;
        padding: 8px 16px;
        width: auto;
        flex-shrink: 0;
    }
    .price-hidden {
        font-size: 0.8em;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }
    .catalog-header h1 {
        font-size: 22px;
    }
    .breadcrumbs {
        padding-top: 20px;
    }
    .filter-title {
        font-size: 12px;
    }
    .sort-select {
        font-size: 13px;
        padding: 8px 30px 8px 10px;
    }
}

/* --- Улучшения для устройств с вырезом --- */
@supports (padding: max(0px)) {
    .container {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }
}

/* --- Уважение к настройкам уменьшенного движения --- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* --- Доступность: фокус --- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* --- Предотвращение горизонтальной прокрутки --- */
body {
    overflow-x: hidden;
}