/**
 * catalog.css — стили для каталога товаров.
 * Кастомные стили поверх Tailwind CSS.
 */

/* ============================================================
   Product Card
   ============================================================ */
.product-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.product-card:hover {
    transform: translateY(-2px);
}

.product-card .line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ============================================================
   Ленивая загрузка изображений
   ============================================================ */
.lazy-img {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lazy-img.loaded,
.lazy-img:not([data-src]) {
    opacity: 1;
}

.lazy-img[src*="data:image/svg+xml"] {
    opacity: 0.3;
}

/* ============================================================
   Бейдж корзины
   ============================================================ */
.cart-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    background: var(--color-accent, #ef4444);
    border-radius: 999px;
    line-height: 1;
}

/* ============================================================
   Bottom-sheet фильтров (мобилка)
   ============================================================ */
@media (max-width: 1023px) {
    .filter-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 50;
        max-height: 85vh;
        border-radius: 16px 16px 0 0;
        overflow-y: auto;
        background: white;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    }

    .dark .filter-panel {
        background: #1f2937;
    }

    /* Полоса захвата для bottom-sheet */
    .filter-panel::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: #d1d5db;
        border-radius: 2px;
        margin: 8px auto 0;
    }

    .dark .filter-panel::before {
        background: #4b5563;
    }
}

/* ============================================================
   Модальное окно быстрого просмотра
   ============================================================ */
.quick-view-modal {
    animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================================
   Карусель фото (страница товара)
   ============================================================ */
.product-carousel {
    position: relative;
    overflow: hidden;
}

.product-carousel .carousel-track {
    display: flex;
    transition: transform 0.3s ease;
}

.product-carousel .carousel-slide {
    min-width: 100%;
    aspect-ratio: 1;
}

.product-carousel .carousel-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-carousel .carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: background 0.2s;
    z-index: 10;
}

.product-carousel .carousel-btn:hover {
    background: white;
}

.product-carousel .carousel-btn-prev {
    left: 8px;
}

.product-carousel .carousel-btn-next {
    right: 8px;
}

/* Точки (dots) карусели */
.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 8px 0;
}

.carousel-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d1d5db;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.carousel-dots .dot.active {
    background: var(--color-accent, #ef4444);
    transform: scale(1.2);
}

/* ============================================================
   Звёзды рейтинга
   ============================================================ */
.rating-stars {
    display: inline-flex;
    gap: 2px;
}

.rating-stars svg {
    transition: transform 0.15s ease;
}

.rating-stars:hover svg {
    transform: scale(1.1);
}

/* ============================================================
   Скелетоны для загрузки
   ============================================================ */
.skeleton {
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite;
    border-radius: 4px;
}

.dark .skeleton {
    background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
    background-size: 200% 100%;
}

@keyframes skeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================================
   Toast-уведомления
   ============================================================ */
.toast-container {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: toastIn 0.3s ease;
    pointer-events: auto;
}

.toast.success {
    background: #10b981;
}

.toast.error {
    background: #ef4444;
}

.toast.info {
    background: #3b82f6;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================
   Анимации для фильтров bottom-sheet
   ============================================================ */
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@keyframes slideDown {
    from { transform: translateY(0); }
    to { transform: translateY(100%); }
}

/* ============================================================
   Стили для тёмной темы (дополнения)
   ============================================================ */
.dark .product-card {
    border-color: #374151;
}

.dark .product-card:hover {
    border-color: #4b5563;
}

/* ============================================================
   Утилиты
   ============================================================ */
/* Скрыть скроллбар для фильтров на мобилках */
.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Акцентный цвет — используем CSS-переменные из market.css (themeManager) */
:root {
    --color-accent: var(--color-btn-bg, #ef4444);
    --color-accent-hover: var(--color-btn-hover, #dc2626);
}

.btn-accent {
    background: var(--color-btn-bg, var(--color-accent));
    color: var(--color-btn-text, white);
    transition: background 0.2s ease;
}

.btn-accent:hover {
    background: var(--color-btn-hover, var(--color-accent-hover));
}

.text-accent {
    color: var(--color-primary, var(--color-accent));
}

.bg-accent {
    background: var(--color-btn-bg, var(--color-accent));
}

.ring-accent {
    --tw-ring-color: var(--color-primary, var(--color-accent));
}

.focus\:ring-accent:focus {
    --tw-ring-color: var(--color-primary, var(--color-accent));
}

/* Анимация спиннера */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* ============================================================
   Адаптация для мобильных устройств
   ============================================================ */
@media (max-width: 640px) {
    .product-card .text-lg {
        font-size: 1rem;
    }
}