/* ============================================
   COMPONENTS — кнопки, карточки, badge, toast
   ============================================ */

/* -------- КНОПКИ -------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 13px 26px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover { background: var(--accent-2); transform: translateY(-2px); }

.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-ghost:hover { background: var(--accent-glow); border-color: var(--border-hover); }

/* -------- СЕТКА ТОВАРОВ (общая — для каталога) -------- */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 18px;
    align-items: stretch;
}

/* Каталог — 5-6 в ряд на широких экранах */
.catalog-page .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 16px;
}

/* -------- СЕТКА ДЛЯ ХИТОВ/НОВИНОК — 4-5 в ряд на десктопе -------- */
.products-grid-fixed {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 18px;
    align-items: stretch;
    max-width: 1400px;
    margin: 0 auto;
}

/* Планшет — 4 карточки */
@media (max-width: 1200px) {
    .products-grid-fixed {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 16px;
    }
}

/* Маленький планшет — 3 карточки */
@media (max-width: 992px) {
    .products-grid-fixed {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 14px;
    }
}

/* -------- МОБИЛКА — 3 карточки + горизонтальный скролл -------- */
@media (max-width: 768px) {
    .products-grid-fixed {
        display: flex !important;
        flex-wrap: nowrap;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        gap: 12px;
        padding-bottom: 12px;
        margin-right: -16px;
        padding-right: 16px;
        scrollbar-width: none;
        max-width: none;
    }

    .products-grid-fixed::-webkit-scrollbar {
        display: none;
    }

    .products-grid-fixed .product-card {
        flex: 0 0 calc((100% - 24px) / 3); /* 3 карточки видно */
        min-width: 140px;
        scroll-snap-align: start;
    }
}

/* Очень маленькие экраны — 2 карточки */
@media (max-width: 420px) {
    .products-grid-fixed .product-card {
        flex: 0 0 calc((100% - 12px) / 2);
        min-width: 130px;
    }
}

.loading {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-muted);
    padding: 60px 0;
}

/* -------- КАРТОЧКА ТОВАРА -------- */
.product-card {
    position: relative;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    height: 100%;
    opacity: 0;
    animation: cardFadeIn 0.5s ease forwards;
}

@keyframes cardFadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.product-card:nth-child(1) { animation-delay: 0.05s; }
.product-card:nth-child(2) { animation-delay: 0.10s; }
.product-card:nth-child(3) { animation-delay: 0.15s; }
.product-card:nth-child(4) { animation-delay: 0.20s; }
.product-card:nth-child(5) { animation-delay: 0.25s; }
.product-card:nth-child(6) { animation-delay: 0.30s; }
.product-card:nth-child(7) { animation-delay: 0.35s; }
.product-card:nth-child(8) { animation-delay: 0.40s; }

.product-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-card-hover);
}

/* -------- ИЗОБРАЖЕНИЕ ТОВАРА -------- */
.product-image-wrap {
    width: 100%;
    height: 200px;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 12px;
}

.product-image-wrap svg {
    width: 64px;
    height: 64px;
    color: var(--accent);
    opacity: 0.7;
    transition: transform 0.4s ease;
}

.product-card:hover .product-image-wrap svg { transform: scale(1.1); }

/* Реальная картинка */
.product-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transition: transform 0.4s ease;
}

.product-card:hover .product-image { transform: scale(1.05); }

.product-body {
    padding: 18px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.product-name {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
    line-height: 1.4;
    color: var(--text);
}

.product-brand {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 14px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
}

.product-price {
    font-size: 20px;
    font-weight: 700;
    margin-top: auto;
    margin-bottom: 14px;
    letter-spacing: -0.02em;
}

.product-price::after {
    content: ' ₽';
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    margin-left: 2px;
}

.product-btn {
    display: block;
    width: 100%;
    padding: 11px;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.product-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Бейдж ХИТ / NEW */
.product-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 4px 10px;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    border-radius: 6px;
    z-index: 2;
}

/* -------- ФИЛЬТРЫ (для главной) -------- */
.filters {
    margin-bottom: 40px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.filters-row { display: flex; gap: 12px; flex-wrap: wrap; }

.search-box {
    flex: 1;
    min-width: 240px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: border-color 0.2s;
}

.search-box:focus-within { border-color: var(--border-hover); }
.search-box svg { color: var(--text-muted); flex-shrink: 0; }

.search-box input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    padding: 13px 0;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
}

.search-box input::placeholder { color: var(--text-muted); }

.sort-select {
    padding: 13px 40px 13px 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6b7e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
}

.sort-select:hover { border-color: var(--border-hover); }

.filters-categories { display: flex; flex-wrap: wrap; gap: 8px; }

.category-btn {
    padding: 8px 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.category-btn:hover { color: var(--text); border-color: var(--border-hover); }

.category-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
}

/* -------- НИЧЕГО НЕ НАЙДЕНО -------- */
.no-results {
    text-align: center;
    padding: 60px 20px;
}

.no-results p {
    font-size: 18px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.no-results button {
    padding: 11px 24px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

/* -------- ТОСТ -------- */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 20px;
    background: var(--accent);
    color: #fff;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 8px 32px rgba(124, 92, 245, 0.4);
    z-index: 1000;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
}

.toast-show { opacity: 1; transform: translateY(0); }
