﻿/* ========== Переменные темы ========== */
:root {
    --ps-accent: #1F839F;
    --ps-accent-600: #176A81;
    --ps-text: #333;
    --ps-muted: #888;
    --ps-border: #ececec;
    --ps-bg: #fff;
    --ps-shadow: 0 2px 10px rgba(0,0,0,.06);
    --ps-shadow-hover: 0 8px 24px rgba(0,0,0,.10);
}

/* ========== Сайдбар категорий ========== */
.category-sidebar {
    background: var(--ps-bg);
    border-radius: 12px;
    box-shadow: var(--ps-shadow);
    font-size: .95rem;
    padding: 1rem;
    position: sticky;
    top: 1rem;
}

    .category-sidebar h5 {
        font-weight: 700;
        margin-bottom: 1rem;
    }

/* Элементы категорий */
.category-item {
    margin-bottom: .5rem;
}

.category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .55rem .65rem;
    background: #f9f9f9;
    border-radius: 8px;
    transition: background-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

    .category-header:hover {
        background: #f3f3f3;
        box-shadow: 0 4px 10px rgba(0,0,0,.06);
        transform: translateY(-1px);
    }

.category-link {
    flex: 1;
    text-decoration: none;
    color: var(--ps-text);
    font-weight: 600;
    letter-spacing: .1px;
    transition: color .2s ease;
}

    .category-link:hover {
        color: var(--ps-accent);
    }

/* Активная категория */
.category-item.active > .category-header {
    background: linear-gradient(0deg, rgba(31,131,159,.10), rgba(31,131,159,.10)), #f5fbfd;
    border: 1px solid rgba(31,131,159,.25);
}

    .category-item.active > .category-header .category-link {
        color: var(--ps-accent) !important;
        font-weight: 700;
    }

/* Подкатегории */
.category-item ul {
    margin-top: .35rem;
}

    .category-item ul li {
        margin: .3rem 0;
    }

        .category-item ul li a {
            display: block;
            padding: .25rem .4rem;
            border-radius: 6px;
            text-decoration: none;
            color: var(--ps-text);
            transition: color .2s ease, background-color .2s ease;
        }

            .category-item ul li a:hover {
                color: var(--ps-accent);
                background: #f7f7f7;
            }

        .category-item ul li.active > a {
            background: var(--ps-accent);
            color: #fff;
        }

/* Кнопка-стрелка (раскрытие) */
.toggle-btn {
    background: none;
    border: none;
    color: var(--ps-muted);
    cursor: pointer;
    padding: 0 .15rem;
    font-size: .95rem;
    display: flex;
    align-items: center;
    transition: transform .3s ease, color .2s ease;
}

    .toggle-btn:hover {
        color: var(--ps-accent);
    }

    .toggle-btn i {
        transition: transform .3s ease;
    }

    .toggle-btn.open i {
        transform: rotate(90deg);
    }

/* Карточки категорий (если используешь) */
.category-card {
    transition: box-shadow .2s ease, transform .2s ease;
}

    .category-card:hover {
        box-shadow: var(--ps-shadow-hover);
        transform: translateY(-2px);
    }

.category-title {
    font-size: 1.06rem;
    transition: color .2s ease;
}

    .category-title:hover {
        color: var(--ps-accent);
    }

.category-sublist a, .category-subsublist a {
    transition: color .2s ease;
}

    .category-sublist a:hover, .category-subsublist a:hover {
        color: var(--ps-accent);
    }

.category-sublist li {
    line-height: 1.4;
    font-size: .95rem;
}

.category-subsublist {
    font-size: .86rem;
    color: var(--ps-muted);
}

/* ========== Карточка товара ========== */
.product-card {
    background: var(--ps-bg);
    border-radius: 14px;
    padding: 10px; /* компактнее */
    text-align: left; /* читабельнее */
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    box-shadow: var(--ps-shadow);
    outline: 2px solid transparent;
    outline-offset: -2px;
    transition: outline-color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

    .product-card:hover {
        box-shadow: var(--ps-shadow-hover);
        border-color: rgba(51,51,51,.22);
        outline-color: rgba(31,131,159,.35);
        transform: translateY(-1px);
    }

/* Медиа-блок */
.product-media-wrap {
    position: relative;
}

.product-media {
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
}

    .product-media img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

/* Бейджи — ВСЕГДА над фото */
.product-badges {
    position: absolute;
    inset: auto auto auto auto;
    top: .5rem;
    left: .5rem;
    display: flex;
    gap: .35rem;
    z-index: 3;
    pointer-events: none;
}

    .product-badges .badge {
        pointer-events: auto;
        border-radius: 999px;
        padding: .25rem .5rem;
        font-weight: 700;
        font-size: .75rem;
    }

/* Совместимость с твоими классами product-badge */
.product-card .product-badge {
    position: absolute;
    top: 12px;
    padding: 4px 8px;
    font-size: .75rem;
    font-weight: 700;
    border-radius: 999px;
    color: #fff;
    z-index: 5;
    animation: fadeInBadge .5s ease;
    white-space: nowrap;
}

.product-card .position-left {
    left: 12px;
}

.product-card .position-right {
    right: 12px;
}

.product-card .badge-discount {
    background: #e74c3c;
}

.product-card .badge-new {
    background: #27ae60;
}

.product-card .badge-hit {
    background: #3498db;
}

.product-card .badge-limited {
    background: #e67e22;
}

@keyframes fadeInBadge {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Титул — 2 строки, без «лесенки» */
.product-card a {
    font-size: .97rem;
    font-weight: 700;
    color: var(--ps-text);
    text-decoration: none;
    display: block;
    margin: .4rem 0 .2rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color .18s ease;
}

    .product-card a:hover {
        color: var(--ps-accent);
    }

/* Цена — компактнее */
.product-card p.price {
    font-size: 1rem;
    font-weight: 800;
    margin: .1rem 0 .35rem;
    color: var(--ps-accent);
}

/* Наличие с точкой */
.product-stock {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-weight: 600;
}

.stock-dot {
    width: .5rem;
    height: .5rem;
    border-radius: 50%;
    display: inline-block;
}

    .stock-dot.success {
        background: #28a745;
    }

    .stock-dot.danger {
        background: #dc3545;
    }

/* Кнопка «В корзину» */
.product-card .add-to-cart {
    background: var(--ps-accent);
    color: #fff;
    border-radius: 10px;
    padding: .5rem .75rem;
    font-weight: 700;
    transition: transform .12s ease, box-shadow .18s ease, background .18s ease;
}

    .product-card .add-to-cart:hover {
        background: #0f2f38;
        border-color: #0f2f38;
        transform: translateY(-1px);
        box-shadow: 0 8px 18px rgba(31,131,159,.25);
    }

/* Обёртка количества — компакт */
.qty-control {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 6px;
}

.btn-qty {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--ps-accent-600);
    background: #fff;
    color: var(--ps-text);
    font-size: 1.05rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color .2s ease, color .2s ease, border-color .2s ease, transform .12s ease, box-shadow .15s ease;
}

    .btn-qty:hover {
        background: var(--ps-accent-600);
        color: #fff;
        border-color: #333;
        box-shadow: 0 3px 8px rgba(0,0,0,.18);
        transform: translateY(-1px);
    }

    .btn-qty:active {
        transform: translateY(0);
        box-shadow: none;
    }

.qty-input {
    width: 54px;
    height: 30px;
    text-align: center;
    border-radius: 8px;
    border: 1px solid var(--ps-accent-600);
    font-size: .95rem;
    color: var(--ps-text);
}

    .qty-input:focus {
        border-color: #333;
        outline: none;
        box-shadow: 0 0 0 2px rgba(77,77,77,.14);
    }

/* Пагинация */
.pagination .page-link {
    color: var(--ps-accent);
    border-radius: 6px;
    margin: 0 3px;
    transition: background-color .2s ease, color .2s ease, box-shadow .2s ease, transform .12s ease;
}

.pagination .page-item.active .page-link {
    background: var(--ps-accent);
    border-color: var(--ps-accent);
    color: #fff;
    box-shadow: 0 6px 14px rgba(31,131,159,.25);
}

.pagination .page-link:hover {
    background: #f3f3f3;
    border-color: var(--ps-accent);
    transform: translateY(-1px);
}

/* ========== Мелкие утилиты и совместимость ========== */
/* Списки в левой колонке аккуратные */
ul.list-unstyled li + li {
    padding-top: .4rem;
    margin-top: .4rem;
}

ul.list-unstyled {
    padding-left: .5rem;
}

/* Соотношение сторон фото: 4:3 — карточка ниже, чем 1:1 */
.ratio-4x3 {
    aspect-ratio: 4/3;
}

/* ========== Адаптив ========== */
@media (max-width: 1199.98px) {
    .product-card {
        padding: 9px;
    }
}

@media (max-width: 991.98px) {
    .category-sidebar {
        margin-bottom: 1.5rem;
        position: static;
    }

    .product-card p.sku {
        display: none;
    }

    .product-card a {
        font-size: .95rem;
    }

    .product-card p.price {
        font-size: .98rem;
    }
}

@media (max-width: 575.98px) {
    .product-card {
        padding: 8px;
    }

    .btn-qty {
        width: 28px;
        height: 28px;
    }

    .qty-input {
        height: 28px;
        width: 50px;
    }
}

/* ===== Дополнительно: если будешь использовать line-clamp на названии, чтобы высота выравнивалась ===== */
.product-title-fixed {
    min-height: 2.6em;
    line-height: 1.3;
}
/* ================= ULTRA-COMPACT ================= */
/* Можно применить глобально ИЛИ завернуть грид в .shop-compact — оба селектора учтены */
.shop-compact .product-card,
.product-card {
    padding: 8px; /* было 10–12 */
    border-radius: 12px;
}

/* Медиа — делаем ниже за счёт 16:9 (ещё короче, чем 4:3) */
.shop-compact .ratio-4x3,
.ratio-4x3 {
    aspect-ratio: 16 / 9;
}

/* Бейджи — меньше, плотнее */
.shop-compact .product-badges .badge,
.product-badges .badge {
    font-size: .7rem;
    padding: .2rem .45rem;
}

/* Заголовок — компактнее, 2 строки на десктопе, 1 на мобиле */
.shop-compact .product-card a,
.product-card a {
    font-size: .92rem;
    margin: .3rem 0 .15rem;
    -webkit-line-clamp: 2;
    line-height: 1.25;
}

@media (max-width: 575.98px) {
    .shop-compact .product-card a,
    .product-card a {
        -webkit-line-clamp: 1;
        min-height: 1.25em; /* фикс высоты */
    }
}

/* Цена — чуть меньше и плотнее к заголовку */
.shop-compact .product-card p.price,
.product-card p.price {
    font-size: .95rem;
    margin: .05rem 0 .25rem;
    font-weight: 800;
}

/* Блок наличия — оставляем только точку на мобиле; текст — на md+ */
.shop-compact .product-stock,
.product-stock {
    gap: .35rem;
    font-size: .86rem;
}

@media (max-width: 767.98px) {
    .shop-compact .product-stock,
    .product-stock {
        font-size: 0; /* прячем текст, оставим только точку */
    }

        .shop-compact .product-stock .stock-dot,
        .product-stock .stock-dot {
            width: .5rem;
            height: .5rem;
            display: inline-block;
        }
}

/* Кол-во — ещё компактнее */
.shop-compact .qty-control,
.qty-control {
    gap: 4px;
}

.shop-compact .btn-qty,
.btn-qty {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    font-size: 1rem;
}

.shop-compact .qty-input,
.qty-input {
    height: 26px;
    width: 46px;
    font-size: .9rem;
    border-radius: 6px;
}

/* Кнопка «В корзину» — small и плотные отступы */
.shop-compact .product-card .add-to-cart,
.product-card .add-to-cart {
    padding: .4rem .6rem;
    font-size: .9rem;
    border-radius: 8px;
}

/* Ужимаем тени/ховер, чтобы карточки «не прыгали» */
.shop-compact .product-card:hover,
.product-card:hover {
    transform: translateY(-0.5px);
    box-shadow: 0 6px 18px rgba(0,0,0,.08);
}

/* Сайдбар — ещё компактнее отступы списков */
.shop-compact .category-header,
.category-header {
    padding: .45rem .55rem;
}

.shop-compact .category-item ul li a,
.category-item ul li a {
    padding: .2rem .35rem;
    font-size: .92rem;
}

/* Пагинация — ниже и легче */
.shop-compact .pagination .page-link,
.pagination .page-link {
    padding: .35rem .6rem;
    font-size: .92rem;
    border-radius: 6px;
}

/* Мобилка — общее уплотнение */
@media (max-width: 575.98px) {
    .shop-compact .product-card,
    .product-card {
        padding: 7px;
        border-radius: 10px;
    }

    .shop-compact .product-badges,
    .product-badges {
        top: .35rem;
        left: .35rem;
        gap: .25rem;
    }

        .shop-compact .product-badges .badge,
        .product-badges .badge {
            font-size: .68rem;
            padding: .18rem .4rem;
        }
}


/* ===== Masonry для списков категорий (корень и "верхний уровень") ===== */
.masonry {
    column-gap: 1.5rem; /* визуально как g-4 */
}

@media (max-width: 575.98px) {
    .masonry {
        column-count: 1;
    }
}

@media (min-width: 576px) and (max-width: 991.98px) {
    .masonry {
        column-count: 2;
    }
}

@media (min-width: 992px) {
    .masonry {
        column-count: 3;
    }
}

/* Каждая карточка категории — независимый блок */
.masonry-item {
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
    display: block;
    margin: 0 0 1.5rem; /* вертикальный отступ как g-4 */
}

/* Легкая карточка категории (заголовок + список) */
.cat-card {
    display: block;
}

    .cat-card h5 {
        margin-bottom: .5rem;
    }

/* Список подкатегорий — аккуратный и компактный */
.cat-list {
    list-style: none;
    margin: 0;
    padding-left: 1rem;
}

    .cat-list li {
        margin: .25rem 0;
    }

    .cat-list a {
        display: block;
        text-decoration: none;
        color: var(--ps-text);
        font-size: .92rem;
        transition: color .2s ease, background-color .2s ease;
        padding: .15rem .2rem;
        border-radius: 6px;
    }

        .cat-list a:hover {
            color: var(--ps-accent);
            background: #f7f7f7;
        }
.masonry-item .cat-card {
    border-bottom: 1px solid rgba(0,0,0,.08);
}