/* Враппер: категории + кнопка поиска */
.category-bar-wrapper {
    position: fixed;
    z-index: 1000;
    top: 90px;
    left: 50%;
    transform: translateX(-50%);
    max-width: calc(100% - 30px);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Панель категорий */
.category-buttons {
    position: relative;
    display: flex;
    gap: 4px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.13), 0 1px 4px rgba(0,0,0,0.07);
    padding: 5px;
    min-width: 0;
}
.category-buttons::-webkit-scrollbar {
    display: none;
}

/* Скользящий зелёный фон между кнопками */
.category-pill {
    position: absolute;
    top: 5px;
    left: 0;
    background: #64805A;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(100, 128, 90, 0.40);
    pointer-events: none;
    z-index: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.category-scroll {
    position: relative;
    z-index: 1;
    padding: 7px 22px;
    font-size: 17px;
    font-family: 'Oswald', sans-serif;
    font-weight: 400;
    letter-spacing: 0.4px;
    color: #444;
    border: none;
    border-radius: 10px;
    background-color: transparent;
    cursor: pointer;
    transition: color 0.22s;
    flex-shrink: 0;
}

.category-scroll.active {
    color: #fff;
}

.category-scroll:hover:not(.active) {
    background-color: rgba(100, 128, 90, 0.12);
    color: #3a5232;
}

/* Каталог — вертикальная колонка секций */
.catalog {
    display: block;
    max-width: 1220px;
    margin: 0 auto;
    padding: 140px 15px 15px;
}

/* Заголовок категории */
.category-title {
    font-size: 32px;
    margin: 0 0 12px;
    text-align: left;
    scroll-margin-top: 145px;
}

/* Сетка карточек — авто-заполнение, минимум 160px на карточку */
.category-products {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 32px;
}

/* Карточка — fluid, растягивается по ячейке грида */
.product {
    position: relative;
    background-color: #fff;
    border-radius: 20px;
    box-sizing: border-box;
    padding: 12px;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.10), 0 1px 4px rgba(0,0,0,0.07);
}

.product-seasonal-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 18px;
    line-height: 1;
    z-index: 2;
    pointer-events: none;
}


/* Изображение — квадратное, адаптивное */
.product-img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    border-radius: 12px;
    background-color: #fff;
    display: block;
}

/* Подпись карточки — flex-колонка, растягивается */
.product figcaption {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.product-name {
    font-size: 15px;
    line-height: 1.35;
    padding: 6px 0 2px;
    width: 100%;
    overflow: hidden;
    color: #1a1a1a;
}

.product-name b {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    overflow-wrap: break-word;
    word-break: break-word;
}

.product-price {
    font-size: 18px;
    font-weight: 700;
    color: #A1312B;
    padding-bottom: 1px;
    letter-spacing: -0.3px;
}

.product-weight {
    font-size: 12px;
    color: #aaa;
    margin: 4px 0 0;
}

/* Блок кнопок — прижат к низу карточки через margin-top: auto */
.product-button-container {
    margin-top: auto;
    padding-top: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.product-button-container > form {
    display: contents;
}

.product-button-delete {
    display: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid #e8e8e8;
    cursor: pointer;
    background-color: #f5f5f5;
    font-size: 20px;
    color: #666;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}

.product-button-delete:hover {
    background-color: #ffe5e5;
    border-color: #e88;
    color: #c00;
}

.product-cart-info {
    display: none;
    flex-direction: column;
    align-items: center;
    flex: 1;
    line-height: 1.2;
}

.product-cart-price {
    font-size: 14px;
    font-weight: 700;
    color: #A1312B;
}

.product-cart-qty {
    font-size: 11px;
    color: #999;
}

.product-button-add {
    height: 36px;
    border-radius: 18px;
    border: none;
    cursor: pointer;
    background-color: #A1312B;
    color: white;
    font-size: 22px;
    font-weight: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s, transform 0.1s;
    flex: 1;
    padding: 0 0 2px;
    line-height: 1;
}

.product-button-add.fixed {
    flex: 0 0 auto;
    width: 36px;
    border-radius: 50%;
}

.product-button-add:hover {
    background-color: #c0392b;
}

.product-button-add:active {
    transform: scale(0.94);
}

.product--out-of-stock .product-img {
    opacity: 0.45;
    filter: grayscale(40%);
}

.product-out-of-stock {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 36px;
    border-radius: 18px;
    background-color: #f0f0f0;
    color: #aaa;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.1px;
    cursor: default;
    user-select: none;
}

/* Мобильная версия */
@media (max-width: 880px) {
    .category-bar-wrapper {
        top: 62px;
        left: 0;
        right: 0;
        transform: none;
        max-width: none;
        gap: 4px;
        padding: 0 8px;
        box-sizing: border-box;
    }
    .category-buttons {
        flex: 1;
        min-width: 0;
        gap: 3px;
        border-radius: 12px;
        padding: 4px;
    }
    .category-search-btn {
        width: 40px;
        height: 40px;
        flex-shrink: 0;
        border-radius: 12px;
    }
    .category-scroll {
        padding: 6px 14px;
        font-size: 16px;
        border-radius: 8px;
    }
    .category-title {
        margin: 0 0 10px;
        font-size: 24px;
        scroll-margin-top: 120px;
    }
    .catalog {
        padding: 120px 10px 100px;
    }
    .category-products {
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .category-products {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 6px;
    }
    .catalog {
        padding-left: 6px;
        padding-right: 6px;
    }
    .product {
        padding: 10px;
    }
    .product-name {
        font-size: 13px;
    }
    .product-price {
        font-size: 16px;
    }
    .product-button-delete,
    .product-button-add {
        height: 38px;
        font-size: 22px;
    }
    .product-button-delete {
        width: 38px;
    }
    .product-button-add {
        border-radius: 19px;
    }
    .product-button-add.fixed {
        width: 38px;
        border-radius: 50%;
    }
    .product-out-of-stock {
        height: 38px;
        border-radius: 19px;
        font-size: 12px;
    }
}

@media (max-width: 340px) {
    .category-products {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
    .product-name {
        font-size: 12px;
    }
    .product-button-delete,
    .product-button-add {
        height: 34px;
        font-size: 20px;
    }
    .product-button-delete {
        width: 34px;
    }
    .product-button-add {
        border-radius: 17px;
    }
    .product-button-add.fixed {
        width: 34px;
    }
    .product-out-of-stock {
        height: 34px;
        border-radius: 17px;
        font-size: 11px;
    }
}

/* ===== ПОИСК ===== */

.category-search-btn {
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    padding: 0;
    border: none;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.13), 0 1px 4px rgba(0,0,0,0.07);
    color: #444;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.22s, color 0.22s, box-shadow 0.22s;
}

.category-search-btn:hover {
    background-color: #eef2ec;
    color: #3a5232;
}

.category-search-btn.active {
    background-color: #64805A;
    color: #fff;
    box-shadow: 0 2px 10px rgba(100, 128, 90, 0.40);
}

.search-panel {
    position: fixed;
    z-index: 999;
    top: 148px;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    width: min(480px, calc(100% - 30px));
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.13), 0 1px 4px rgba(0,0,0,0.07);
    padding: 8px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
}

.search-panel--open {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 16px;
    font-size: 16px;
    font-family: inherit;
    border: 1.5px solid #e8e8e8;
    border-radius: 10px;
    outline: none;
    color: #1a1a1a;
    background: #fff;
    transition: border-color 0.15s;
}

.search-input:focus {
    border-color: #64805A;
}

@media (max-width: 880px) {
    .search-panel {
        top: 112px;
    }
}
