/* ===== Фиксированная сетка категорий 4 колонки ===== */

/* НОВАЯ ПРОСТАЯ КНОПКА SALE */
.new-sale-banner {
    width: calc(100% - 16px);
    margin: 8px;
    padding: 20px;
    background: linear-gradient(135deg, #FF4444 0%, #FF6B35 50%, #FF8E53 100%);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 68, 68, 0.3);
    transition: all 0.3s ease;
    min-height: 80px;
    box-sizing: border-box;
}

.new-sale-banner:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 68, 68, 0.4);
}

.new-sale-icon {
    font-size: 40px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.new-sale-text {
    flex: 1;
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    letter-spacing: 1px;
}

.new-sale-arrow {
    font-size: 28px;
    color: white;
    opacity: 0.9;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* Адаптивные стили для новой кнопки */
@media (max-width: 480px) {
    .new-sale-banner {
        min-height: 70px;
        padding: 16px;
    }
    
    .new-sale-text {
        font-size: 20px;
    }
    
    .new-sale-icon {
        font-size: 32px;
    }
    
    .new-sale-arrow {
        font-size: 24px;
    }
}

@media (max-width: 360px) {
    .new-sale-banner {
        min-height: 60px;
        padding: 14px;
    }
    
    .new-sale-text {
        font-size: 18px;
    }
    
    .new-sale-icon {
        font-size: 28px;
    }
    
    .new-sale-arrow {
        font-size: 20px;
    }
}

/* Большая кнопка SALE - УЛУЧШЕННАЯ */
.sale-banner {
    width: calc(100% - 16px) !important;  /* Увеличиваем ширину */
    max-width: 100% !important;
    margin: 8px !important;  /* Уменьшаем отступы */
    padding: 24px 20px !important;  /* Увеличиваем внутренние отступы */
    background: linear-gradient(135deg, #FF4444 0%, #FF6B35 50%, #FF8E53 100%) !important;  /* Более яркий градиент */
    border-radius: 24px !important;  /* Более округлые углы */
    display: flex !important;
    align-items: center !important;  /* Центрируем все по вертикали */
    justify-content: space-between !important;  /* Распределяем элементы */
    cursor: pointer !important;
    box-shadow: 0 6px 20px rgba(255, 68, 68, 0.4) !important;  /* Более яркая тень */
    transition: all 0.3s ease !important;
    position: relative !important;
    overflow: hidden !important;
    min-height: 100px !important;  /* Увеличиваем высоту */
    box-sizing: border-box !important;
    border: 2px solid rgba(255, 255, 255, 0.2) !important;  /* Добавляем рамку */
}

.sale-banner::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

.sale-banner:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.4) !important;
}


.sale-banner-icon {
    font-size: 48px !important;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)) !important;
    flex-shrink: 0 !important;
}

.sale-banner-text {
    display: grid !important;  /* Используем GRID для лучшего центрирования */
    place-items: center !important;  /* Центрируем все элементы */
    grid-template-rows: auto auto !important;  /* Две строки для заголовка и подзаголовка */
    gap: 2px !important;  /* Минимальный отступ между строками */
    text-align: center !important;
    margin: 0 !important;
    padding: 0 !important;
    flex: 1 !important;  /* Занимаем все доступное пространство */
    height: 100% !important;  /* Занимаем всю высоту */
    min-height: 50px !important;  /* Минимальная высота */
    align-content: center !important;  /* Центрируем содержимое по вертикали */
    justify-content: center !important;  /* Центрируем содержимое по горизонтали */
}

.sale-banner-title {
    font-size: 32px !important;
    font-weight: 800 !important;
    color: white !important;
    text-shadow: 0 3px 6px rgba(0,0,0,0.4) !important;
    letter-spacing: 2px !important;
    line-height: 1 !important;
    text-align: center !important;
    margin: 0 !important;
    padding: 0 !important;
}

.sale-banner-subtitle {
    font-size: 22px !important;
    color: rgba(255,255,255,0.95) !important;
    font-weight: 700 !important;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3) !important;
    text-align: center !important;
    letter-spacing: 1px !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1 !important;
    margin-top: 0 !important;  /* Принудительно убираем отступ сверху */
    margin-bottom: 0 !important;  /* Принудительно убираем отступ снизу */
    padding-top: 0 !important;  /* Принудительно убираем отступ сверху */
    padding-bottom: 0 !important;  /* Принудительно убираем отступ снизу */
}



/* ПРИНУДИТЕЛЬНЫЙ СБРОС всех браузерных стилей */
.sale-banner *,
.sale-banner-content *,
.sale-banner-text *,
.sale-banner .sale-banner-title,
.sale-banner .sale-banner-subtitle {
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    outline: 0 !important;
    box-sizing: border-box !important;
    vertical-align: baseline !important;
    line-height: 1 !important;
    font-size: inherit !important;
    font-weight: inherit !important;
}

/* Восстанавливаем нужные стили после сброса */
.sale-banner-title {
    font-size: 32px !important;
    font-weight: 800 !important;
}

.sale-banner-subtitle {
    font-size: 22px !important;
    font-weight: 700 !important;
}
.sale-banner .sale-banner-icon,
.sale-banner .sale-banner-text,
.sale-banner .sale-banner-arrow {
    position: static !important;
    transform: none !important;
}


/* Правильная структура баннера */
.sale-banner-content {
    display: flex !important;
    align-items: center !important;  /* Центрируем по вертикали */
    justify-content: center !important;  /* ЦЕНТРИРУЕМ содержимое */
    gap: 20px !important;  /* Расстояние между огнем и текстом */
    z-index: 1 !important;
    position: relative !important;
    flex: 1 !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: 80px !important;  /* Минимальная высота для центрирования */
}

/* Стрелка отдельно справа */
.sale-banner-arrow {
    position: absolute !important;
    right: 30px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    font-size: 32px !important;
    color: white !important;
    opacity: 0.9 !important;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)) !important;
}
h2, .section-title {
    text-align: center !important;
    margin: 20px 0 16px 0 !important;
    font-size: 24px !important;
    font-weight: 700 !important;
    color: var(--text-color) !important;
}
#cafe-categories.cafe-section-horizontal {
    width: 100% !important;
    padding: 12px !important;
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;  /* Всегда 4 колонки */
    gap: 10px !important;
    overflow: visible !important;
    box-sizing: border-box !important;
}

/* Карточки категорий - АДАПТИВНЫЕ */
#cafe-categories .cafe-category-container {
    width: 100% !important;
    aspect-ratio: 1 / 1 !important;  /* Квадратные */
    min-width: 0 !important;  /* Позволяем сжиматься */
    padding: 0 !important;
    border-radius: 16px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-end !important;
    position: relative !important;
    background-size: cover !important;
    background-position: center !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    overflow: hidden !important;
    background-color: var(--popover-bg-color) !important;
}

/* Градиентный оверлей */
#cafe-categories .cafe-category-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        transparent 40%,
        rgba(0, 0, 0, 0.7) 100%
    );
    z-index: 1;
}

#cafe-categories .cafe-category-container:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15) !important;
}

#cafe-categories .cafe-category-container:active {
    transform: translateY(-1px);
}

/* Название категории - ПОЛНОСТЬЮ ЦЕНТРИРОВАН */
#cafe-categories .cafe-category-name {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    margin: 0 auto !important;  /* Центрируем блок */
    font-size: 11px !important;
    font-weight: 600 !important;
    text-align: center !important;
    line-height: 1.4 !important;
    color: white !important;
    background: rgba(0, 0, 0, 0.75) !important;
    padding: 6px 2px !important;  /* Уменьшаем горизонтальные отступы */
    text-overflow: ellipsis !important;
    overflow: hidden !important;
    white-space: nowrap !important;
    backdrop-filter: blur(8px) !important;
    z-index: 2 !important;
    border-radius: 0 0 16px 16px !important;
    box-sizing: border-box !important;
    display: block !important;  /* Блочный элемент для правильного центрирования текста */
    transform: translateX(0) !important;  /* Сбрасываем любые трансформации */
}

/* Для категорий без изображения */
#cafe-categories .cafe-category-container:not([style*="background-image"]) {
    background: linear-gradient(135deg, var(--accent-color) 0%, rgba(var(--accent-rgb), 0.7) 100%) !important;
}

/* ===== Мобильные устройства - 3 колонки ===== */
@media (max-width: 480px) {
    #cafe-categories.cafe-section-horizontal {
        grid-template-columns: repeat(3, 1fr) !important;  /* 3 колонки на мобильных */
        gap: 8px !important;
        padding: 10px !important;
    }
    
    #cafe-categories .cafe-category-name {
        font-size: 10px !important;
        padding: 4px 1px !important;
        width: 100% !important;  /* Занимаем всю ширину */
        left: 0 !important;
        right: 0 !important;
        margin: 0 auto !important;
        text-align: center !important;
        display: block !important;
        transform: translateX(0) !important;
    }
    
    .sale-banner {
        margin: 8px !important;
        min-height: 90px !important;
        padding: 20px 16px !important;
    }
    
    .sale-banner .sale-banner-icon {
        left: 16px !important;
        font-size: 36px !important;
    }
    
    .sale-banner .sale-banner-arrow {
        right: 24px !important;
        font-size: 28px !important;
    }
    
    .sale-banner-title {
        font-size: 28px !important;
        letter-spacing: 1.5px !important;
    }
    
    .sale-banner-subtitle {
        font-size: 18px !important;
        letter-spacing: 0.5px !important;
    }
    
    .sale-banner-icon {
        font-size: 36px !important;
    }
    
    .sale-banner-arrow {
        font-size: 28px !important;
    }
}

/* ===== Очень маленькие экраны - 3 колонки ===== */
@media (max-width: 360px) {
    #cafe-categories.cafe-section-horizontal {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 6px !important;
        padding: 8px !important;
    }
    
    #cafe-categories .cafe-category-name {
        font-size: 9px !important;
        padding: 3px 1px !important;
        width: 100% !important;
        text-align: center !important;
        display: block !important;
        margin: 0 auto !important;
        transform: translateX(0) !important;
    }
    
    .sale-banner {
        min-height: 80px !important;
        padding: 18px 14px !important;
    }
    
    .sale-banner .sale-banner-icon {
        left: 14px !important;
        font-size: 32px !important;
    }
    
    .sale-banner .sale-banner-arrow {
        right: 20px !important;
        font-size: 24px !important;
    }
    
    .sale-banner-title {
        font-size: 24px !important;
        letter-spacing: 1px !important;
    }
    
    .sale-banner-subtitle {
        font-size: 16px !important;
        letter-spacing: 0.5px !important;
    }
    
    .sale-banner-icon {
        font-size: 32px !important;
    }
    
    .sale-banner-arrow {
        font-size: 24px !important;
    }
}

/* ===== Планшеты - 5 колонок ===== */
@media (min-width: 768px) {
    #cafe-categories.cafe-section-horizontal {
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 12px !important;
        padding: 16px !important;
    }
    
    #cafe-categories .cafe-category-container {
        border-radius: 18px !important;
    }
    
    #cafe-categories .cafe-category-name {
        font-size: 11px !important;
        padding: 6px 4px !important;
        border-radius: 0 0 18px 18px !important;
    }
    
    .sale-banner {
        margin: 16px !important;
        min-height: 90px !important;
    }
}

/* ===== Большие экраны - 6 колонок ===== */
@media (min-width: 1024px) {
    #cafe-categories.cafe-section-horizontal {
        grid-template-columns: repeat(6, 1fr) !important;
        gap: 16px !important;
        padding: 20px !important;
        max-width: 1200px !important;
        margin: 0 auto !important;
    }
    
    #cafe-categories .cafe-category-container {
        border-radius: 20px !important;
    }
    
    #cafe-categories .cafe-category-name {
        font-size: 12px !important;
        padding: 8px 6px !important;
        border-radius: 0 0 20px 20px !important;
    }
    
    .sale-banner {
        max-width: 1160px !important;
        margin: 20px auto !important;
        min-height: 100px !important;
    }
    
    .sale-banner-title {
        font-size: 28px !important;
    }
}

/* ===== Очень широкие экраны - 8 колонок ===== */
@media (min-width: 1920px) {
    #cafe-categories.cafe-section-horizontal {
        grid-template-columns: repeat(8, 1fr) !important;
        gap: 20px !important;
        max-width: 1600px !important;
    }
    
    #cafe-categories .cafe-category-name {
        font-size: 13px !important;
        padding: 10px 8px !important;
    }
    
    .sale-banner {
        max-width: 1560px !important;
    }
}

/* ===== Состояние шиммера ===== */
#cafe-categories .cafe-category-container.shimmer {
    background-color: var(--shimmer-color-1) !important;
    background-image: none !important;
    box-shadow: none !important;
}

#cafe-categories .cafe-category-container.shimmer::before {
    display: none;
}

/* ===== Анимация появления ===== */
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

#cafe-categories .cafe-category-container:not(.shimmer) {
    animation: fadeInScale 0.4s ease forwards;
    opacity: 0;
}

#cafe-categories .cafe-category-container:nth-child(1) { animation-delay: 0.05s; }
#cafe-categories .cafe-category-container:nth-child(2) { animation-delay: 0.1s; }
#cafe-categories .cafe-category-container:nth-child(3) { animation-delay: 0.15s; }
#cafe-categories .cafe-category-container:nth-child(4) { animation-delay: 0.2s; }
#cafe-categories .cafe-category-container:nth-child(5) { animation-delay: 0.25s; }
#cafe-categories .cafe-category-container:nth-child(6) { animation-delay: 0.3s; }
#cafe-categories .cafe-category-container:nth-child(7) { animation-delay: 0.35s; }
#cafe-categories .cafe-category-container:nth-child(8) { animation-delay: 0.4s; }

/* ===== Темная тема ===== */
:root.dark #cafe-categories .cafe-category-container {
    background-color: var(--popover-bg-color) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

:root.dark #cafe-categories .cafe-category-name {
    background: rgba(0, 0, 0, 0.8) !important;
}

:root.dark .sale-banner {
    background: linear-gradient(135deg, #E63946 0%, #F77F00 100%) !important;
}

/* Темная тема - улучшение контрастности для секций */
:root.dark .cafe-section-title {
    color: rgba(255, 255, 255, 0.95) !important;
}

:root.dark #cafe-section-sale .cafe-item-container,
:root.dark #cafe-section-popular .cafe-item-container {
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 8px;
}

/* ===== Скидочные товары ===== */

#cafe-section-sale.cafe-section-horizontal {
    width: 100% !important;
    padding: 12px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    white-space: nowrap !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 10px !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    box-sizing: border-box !important;
}

#cafe-section-sale.cafe-section-horizontal::-webkit-scrollbar {
    display: none !important;
}

#cafe-section-sale .cafe-item-container {
    min-width: 150px !important;
    max-width: 150px !important;
    flex-shrink: 0 !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    transition: all 0.3s ease !important;
}

#cafe-section-sale .cafe-item-container:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

#cafe-section-sale .cafe-item-image {
    width: 100% !important;
    height: 110px !important;
    object-fit: cover !important;
}

/* ===== Популярные товары ===== */

#cafe-section-popular.cafe-section-horizontal {
    width: 100% !important;
    padding: 12px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    white-space: nowrap !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 10px !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    box-sizing: border-box !important;
}

#cafe-section-popular.cafe-section-horizontal::-webkit-scrollbar {
    display: none !important;
}

#cafe-section-popular .cafe-item-container {
    min-width: 140px !important;
    max-width: 140px !important;
    flex-shrink: 0 !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    transition: all 0.3s ease !important;
}

#cafe-section-popular .cafe-item-container:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

#cafe-section-popular .cafe-item-image {
    width: 100% !important;
    height: 100px !important;
    object-fit: cover !important;
}