/* Основные стили для магазина */
.badge-new { background: linear-gradient(45deg, #10b981, #059669); }
.badge-popular { background: linear-gradient(45deg, #f59e0b, #d97706); }
.badge-discount { background: linear-gradient(45deg, #ef4444, #dc2626); }

.product-card {
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 20px;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

/* Статусы наличия */
.availability-in_stock { color: #28a745; }
.availability-out_of_stock { color: #dc3545; }
.availability-on_order { color: #ffc107; }

/* Бейдж корзины */
.cart-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-badge.hidden { display: none; }

/* Уведомления в правом нижнем углу */
.cart-notification {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 1060 !important;
    min-width: 300px;
    max-width: 400px;
    margin: 0 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    border: none;
    animation: slideInUp 0.3s ease-out;
}

@keyframes slideInUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.cart-notification.fade-out {
    animation: slideOutDown 0.3s ease-in;
}

@keyframes slideOutDown {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(100%); opacity: 0; }
}

/* ================================= */
/* ВЕРТИКАЛЬНАЯ ГАЛЕРЕЯ - УЛУЧШЕННАЯ АДАПТИВНАЯ ВЕРСИЯ */
/* ================================= */
.product-gallery-container {
    display: flex;
    gap: 12px;
    align-items: stretch;
    position: relative;
}

/* Основной контейнер изображения - соотношение 9:12 (3:4) */
.gallery-main-container {
    flex: 1;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: #f8f9fa;
    aspect-ratio: 9 / 12;
    max-height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

/* Миниатюры - полная высота основного контейнера */
.gallery-thumbs-column {
    width: 80px;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    border-radius: 10px;
    background: #f8f9fa;
    transition: width 0.3s ease;
}

/* На мобильных и планшетах в портретной ориентации - горизонтальная прокрутка */
@media (max-width: 767px) {
    .product-gallery-container {
        flex-direction: column;
        gap: 12px;
    }
    
    .gallery-thumbs-column {
        width: 100%;
        height: 80px;
        min-height: 80px;
        flex-direction: row;
        order: 2;
    }
    
    .gallery-main-container {
        order: 1;
        aspect-ratio: 9 / 12;
        max-height: 500px;
    }
    
    .gallery-nav-btn {
        width: 36px;
        height: 36px;
    }
    
    .gallery-nav-btn.prev-btn { left: 8px; }
    .gallery-nav-btn.next-btn { right: 8px; }
}

/* На планшетах и выше - вертикальная прокрутка */
@media (min-width: 768px) {
    .gallery-thumbs-column {
        width: 90px;
    }
}

/* На больших экранах */
@media (min-width: 1024px) {
    .product-detail-grid .product-gallery-container {
        height: 100%;
        align-items: stretch;
    }

    .product-detail-grid .gallery-thumbs-column {
        height: 100%;
        width: 100px;
    }

    .product-detail-grid .gallery-main-container {
        height: 100%;
    }
    
    .gallery-thumbs-column {
        width: 100px;
    }
    
    .gallery-main-container {
        max-height: 700px;
    }
}

/* Обертка для прокручиваемой области */
.gallery-thumbs-wrapper {
    flex: 1;
    overflow: hidden;
    position: relative;
    border-radius: 8px;
    background: #f8f9fa;
}

.gallery-thumbs-scroll {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 6px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

/* Горизонтальный скролл на мобильных и планшетах */
@media (max-width: 767px) {
    .gallery-thumbs-scroll {
        flex-direction: row;
        padding: 6px;
        gap: 8px;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Скрываем скроллбар на мобильных */
    .gallery-thumbs-wrapper::-webkit-scrollbar {
        display: none;
    }
    .gallery-thumbs-wrapper {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
}

/* Стили миниатюр */
.product-thumb-vertical {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    position: relative;
    flex-shrink: 0;
    background: white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    scroll-snap-align: start;
}

.product-thumb-vertical:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.product-thumb-vertical:focus:not(:focus-visible) {
    outline: none;
}

.product-thumb-vertical:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.product-thumb-vertical img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.product-thumb-vertical:hover {
    border-color: #3b82f6;
    transform: scale(1.05);
    z-index: 1;
}

.product-thumb-vertical:hover img {
    transform: scale(1.1);
}

.product-thumb-vertical.active {
    border-color: #2563eb;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    z-index: 2;
    transform: scale(1.05);
}

/* Адаптация размеров миниатюр */
@media (max-width: 640px) {
    .product-thumb-vertical {
        width: 70px;
        height: 70px;
    }
}

@media (min-width: 1024px) {
    .product-thumb-vertical {
        width: 92px;
        height: 92px;
    }
}

/* Кнопки прокрутки миниатюр */
.gallery-scroll-btn {
    width: 100%;
    height: 32px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #374151;
    transition: all 0.2s ease;
    z-index: 2;
    flex-shrink: 0;
    font-size: 0.875rem;
}

.gallery-scroll-btn:hover:not(:disabled) {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #1f2937;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.gallery-scroll-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: #f9fafb;
}

/* Навигация основного изображения */
.gallery-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(229, 231, 235, 0.8);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #374151;
    transition: all 0.2s ease;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.gallery-nav-btn:hover {
    background: white;
    border-color: #d1d5db;
    color: #1f2937;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transform: translateY(-50%) scale(1.05);
}

.gallery-nav-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.gallery-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.gallery-nav-btn.prev-btn {
    left: 12px;
}

.gallery-nav-btn.next-btn {
    right: 12px;
}

/* Мобильные стили для кнопок навигации */
@media (max-width: 767px) {
    .gallery-nav-btn {
        width: 40px;
        height: 40px;
    }
    
    .gallery-nav-btn.prev-btn {
        left: 24px;
    }
    
    .gallery-nav-btn.next-btn {
        right: 24px;
    }
    
    .gallery-nav-btn i {
        font-size: 1rem;
    }
}

/* Основное изображение */
.gallery-main-container {
    flex: 1;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: #f8f9fa;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    transition: min-height 0.3s ease;
}

@media (min-width: 768px) {
    .gallery-main-container {
        min-height: 400px;
    }
}

@media (min-width: 1024px) {
    .gallery-main-container {
        min-height: 450px;
    }
}

.gallery-main-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    transition: opacity 0.3s ease, transform 0.3s ease;
    user-select: none;
    -webkit-user-drag: none;
}

.gallery-main-image.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Заглушка при отсутствии изображения */
.gallery-main-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 9 / 12;
    max-height: 600px;
    color: #6b7280;
    font-size: 1rem;
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
}

.gallery-main-placeholder i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Адаптация заглушки на мобильных */
@media (max-width: 640px) {
    .gallery-main-placeholder {
        aspect-ratio: 9 / 12;
        max-height: 500px;
        padding: 1.5rem;
    }
    
    .gallery-main-placeholder i {
        font-size: 2rem;
    }
}

/* Индикатор количества изображений */
.gallery-count-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 5;
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    gap: 4px;
}

.gallery-count-badge .current-index {
    font-weight: 600;
}

/* Адаптация для мобильных */
@media (max-width: 767px) {
    .gallery-count-badge {
        top: 8px;
        right: 8px;
        padding: 4px 8px;
        font-size: 0.75rem;
    }
}

/* Улучшенный фокус для доступности */
.gallery-nav-btn:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Стили для загрузки изображений */
.gallery-main-image[loading="lazy"] {
    opacity: 0;
}

.gallery-main-image.loaded {
    opacity: 1;
}

/* Плавная прокрутка миниатюр */
.gallery-thumbs-scroll {
    scroll-behavior: smooth;
}

/* Мобильные улучшения */
@media (max-width: 640px) {
    .gallery-thumbs-scroll {
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }
    
    .product-thumb-vertical {
        scroll-snap-align: start;
    }
}

/* ================================= */
/* СТИЛИ ДЛЯ ГЛАВНОЙ СТРАНИЦЫ - Компактные карточки */
/* ================================= */

/* Компактные карточки товаров */
.compact-product-card {
    transition: all 0.2s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.compact-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Утилиты для ограничения текста */
.line-clamp-1,
.line-clamp-2,
.line-clamp-3 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-clamp: var(--line-clamp, 2);
    -webkit-line-clamp: var(--line-clamp, 2);
}

.line-clamp-1 {
    --line-clamp: 1;
    line-clamp: 1;
    -webkit-line-clamp: 1;
}

.line-clamp-2 {
    --line-clamp: 2;
    line-clamp: 2;
    -webkit-line-clamp: 2;
}

.line-clamp-3 {
    --line-clamp: 3;
    line-clamp: 3;
    -webkit-line-clamp: 3;
}

/* Фиксированная высота для заголовков */
.h-10 { height: 2.5rem; }

/* Соотношение сторон для изображений */
.aspect-square {
    position: relative;
    width: 100%;
    padding-bottom: 100%;
}

.aspect-square > * {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Стили для новостей на главной */
.news-item {
    transition: background-color 0.2s ease;
}

.news-item:hover {
    background-color: #f8fafc;
}

/* Отступы для разделов на главной */
.compact-products-section {
    margin-bottom: 2.5rem;
}

.compact-products-section:last-child {
    margin-bottom: 0;
}

/* Обеспечиваем совместимость с Firefox и другими браузерами */
@supports (-webkit-line-clamp: 1) {
    .line-clamp-1,
    .line-clamp-2,
    .line-clamp-3 {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

@supports not (-webkit-line-clamp: 1) {
    .line-clamp-1,
    .line-clamp-2,
    .line-clamp-3 {
        max-height: calc(var(--line-clamp, 2) * 1.5em);
        overflow: hidden;
        position: relative;
    }
    
    .line-clamp-1::after,
    .line-clamp-2::after,
    .line-clamp-3::after {
        content: '...';
        position: absolute;
        right: 0;
        bottom: 0;
        background: white;
        padding-left: 4px;
    }
}