/* Стили для заголовков */
h1 {
    font-size: 1.5rem; /* Уменьшаем шрифт */
    font-weight: 700;
    margin-bottom: 1rem;
}
h2 {
    font-size: 1.25rem; /* text-xl */
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Стили для секции описания */
.bg-white.rounded-xl {
    background-color: #fff;
    border-radius: 0.5rem; /* Уменьшаем радиус */
    padding: 1rem; /* Уменьшаем отступы */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
    transition: box-shadow 0.3s ease;
}
.bg-white.rounded-xl:hover {
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

/* Стили для подкатегорий и категорий */
.subcategory-grid {
    display: grid;
    gap: 0.75rem; /* Уменьшаем отступы */
    padding: 0.5rem;
}

/* Логика сетки: теперь адаптируем под мобильные */
.subcategory-grid:has(> *:nth-child(1):nth-last-child(1)) {
    grid-template-columns: repeat(1, 1fr);
}
.subcategory-grid:has(> *:nth-child(2):nth-last-child(1)) {
    grid-template-columns: repeat(2, 1fr);
}
.subcategory-grid:has(> *:nth-child(3):nth-last-child(1)) {
    grid-template-columns: repeat(2, 1fr);
}
.subcategory-grid:has(> *:nth-child(4):nth-last-child(1)) {
    grid-template-columns: repeat(2, 1fr);
}
.subcategory-grid:has(> *:nth-child(5):nth-last-child(1)) {
    grid-template-columns: repeat(2, 1fr);
}
.subcategory-grid:has(> *:nth-child(6):nth-last-child(1)) {
    grid-template-columns: repeat(2, 1fr);
}
.subcategory-grid:has(> *:nth-child(7):nth-last-child(1)) {
    grid-template-columns: repeat(2, 1fr);
}
.subcategory-grid:has(> *:nth-child(8):nth-last-child(1)) {
    grid-template-columns: repeat(2, 1fr);
}
.subcategory-grid:has(> *:nth-child(n+9)) {
    grid-template-columns: repeat(2, 1fr); /* На мобильных — максимум 2 колонки */
}

/* Улучшенные стили для подкатегорий и категорий */
.subcategory-card {
    transition: all 0.3s ease;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end; /* Текст прижмём к низу */
    min-height: 150px; /* Уменьшаем высоту */
    background-color: #fff;
    padding: 0.5rem; /* Уменьшаем отступы */
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.subcategory-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
    border-color: #d1d5db;
}

/* Фоновое изображение */
.subcategory-card img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover; /* Заполняет блок, сохраняя пропорции */
    opacity: 1;
    z-index: 0;
}

/* Белый текст с полупрозрачным тёмным фоном */
.subcategory-card .text-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 0.4rem; /* Уменьшаем отступы */
    text-align: center;
    border-radius: 0.25rem;
    margin: 0.25rem; /* Уменьшаем внешний отступ */
    z-index: 10;
    overflow: hidden; /* Не даём тексту выходить за границы */
}

.subcategory-card .text-overlay p {
    font-weight: 600;
    margin-bottom: 0.1rem;
    font-size: 0.875rem; /* Уменьшаем шрифт */
    color: white !important;
    white-space: nowrap; /* Не переносим текст */
    overflow: hidden;
    text-overflow: ellipsis; /* Обрезаем, если текст длинный */
}

.subcategory-card .text-overlay small {
    font-size: 0.75rem; /* Уменьшаем шрифт */
    opacity: 0.8;
    color: white !important;
    display: block; /* Отдельная строка */
}

/* Анимация появления */
.subcategory-card {
    opacity: 0;
    animation: fadeInUp 0.5s ease forwards;
}

.subcategory-card:nth-child(1) { animation-delay: 0.1s; }
.subcategory-card:nth-child(2) { animation-delay: 0.2s; }
.subcategory-card:nth-child(3) { animation-delay: 0.3s; }
.subcategory-card:nth-child(4) { animation-delay: 0.4s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Стили для фильтров */
aside#filters {
    background-color: #fff;
    padding: 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease;
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh; /* На мобильных — весь экран */
    z-index: 60; /* Выше других элементов */
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto; /* Добавляем прокрутку */
}
aside#filters:hover {
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

/* На мобильных фильтры скрыты */
@media (max-width: 767px) {
    aside#filters {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 100%;
        z-index: 60;
        transform: translateX(-100%);
    }
    aside#filters.show {
        transform: translateX(0);
    }
}

@media (min-width: 768px) {
    aside#filters {
        position: static;
        transform: none;
        width: 25%;
    }
}
aside#filters.show {
    transform: translateX(0);
}
aside#filters button#close-sidebar {
    display: block;
    margin-bottom: 1rem;
    font-size: 1.25rem;
}
@media (min-width: 768px) {
    aside#filters button#close-sidebar {
        display: none;
    }
}

/* Уменьшаем шрифты и отступы в фильтрах */
aside#filters h2 {
    font-size: 1.125rem; /* Уменьшаем шрифт */
    margin-bottom: 0.75rem;
}
aside#filters ul li a {
    font-size: 0.875rem; /* Уменьшаем шрифт */
    padding: 0.5rem 0;
    display: block;
}
aside#filters ul li a:hover {
    color: #dc2626;
}
aside#filters input,
aside#filters select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #e5e5e5;
    border-radius: 0.25rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem; /* Уменьшаем шрифт */
}

/* Стили для кнопки открытия фильтров */
button#open-sidebar {
    background-color: #4b5563; /* bg-gray-600 */
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    display: block;
    width: 100%;
    text-align: center;
}
@media (min-width: 768px) {
    button#open-sidebar {
        display: none;
    }
}

/* Стили для сортировки */
select#sort {
    padding: 0.5rem;
    border: 1px solid #e5e5e5;
    border-radius: 0.25rem;
    width: 100%;
    margin-bottom: 1rem;
}

/* Стили для сетки продуктов */
#productGrid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr)); /* 1 колонка на мобильных */
    gap: 1rem;
}
@media (min-width: 640px) {
    #productGrid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (min-width: 1024px) {
    #productGrid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
@media (min-width: 1280px) {
    #productGrid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.product-card {
    background-color: #fff;
    border-radius: 0.75rem;
    padding: 0.75rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-align: center;
    transition: all 0.3s ease;
}
.product-card:hover {
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
    transform: scale(1.05);
}
.product-card img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
}
.product-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
}
.product-card p {
    color: #4b5563;
    font-size: 0.875rem;
}
.product-card p.text-red-600 {
    color: #dc2626;
}
.product-card .card-buttons {
    opacity: 0;
    transition: opacity 0.3s ease;
}
.product-card:hover .card-buttons {
    opacity: 1;
}
.product-card button.add-to-cart,
.product-card button.add-to-favorites,
.product-card button.quick-view {
    width: 100%;
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
    font-size: 0.875rem;
}
.product-card button.add-to-cart {
    background-color: #dc2626;
    color: white;
}
.product-card button.add-to-cart:hover {
    background-color: #b91c1c;
}
.product-card button.add-to-favorites,
.product-card button.quick-view {
    background-color: #e5e7eb;
    color: #1f2937;
}
.product-card button.add-to-favorites:hover,
.product-card button.quick-view:hover {
    background-color: #d1d5db;
}

/* Стили для пагинации */
.flex.justify-center.mt-6 a {
    padding: 0.5rem 0.75rem;
    margin: 0 0.25rem;
    color: #374151;
    text-decoration: none;
    font-size: 0.875rem;
}
.flex.justify-center.mt-6 a:hover {
    color: #dc2626;
}
.flex.justify-center.mt-6 a.font-bold {
    color: #dc2626;
    font-weight: bold;
}

/* Стили для секции "Почему выбирают наш каталог?" */
section.bg-white.rounded-xl.mt-12 {
    background-color: #fff;
    border-radius: 0.75rem;
    padding: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease;
    margin-top: 2rem;
}
section.bg-white.rounded-xl.mt-12:hover {
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}
section.bg-white.rounded-xl.mt-12 .grid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 1rem;
}
@media (min-width: 768px) {
    section.bg-white.rounded-xl.mt-12 .grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
section.bg-white.rounded-xl.mt-12 .grid div {
    text-align: center;
}
section.bg-white.rounded-xl.mt-12 .grid svg {
    width: 2.5rem;
    height: 2.5rem;
    color: #dc2626;
    margin: 0 auto 0.5rem;
}
section.bg-white.rounded-xl.mt-12 .grid h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
}
section.bg-white.rounded-xl.mt-12 .grid p {
    color: #4b5563;
    font-size: 0.875rem;
}

/* Улучшенные стили для модального окна (быстрый просмотр) */
.fixed.inset-0 {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}
.fixed.inset-0 .bg-white {
    background-color: #fff;
    border-radius: 0.75rem;
    padding: 1rem;
    max-width: 95%;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease;
}
.fixed.inset-0 .bg-white:hover {
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}
.fixed.inset-0 .close-modal {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    color: #4b5563;
    font-size: 1.25rem;
}
.fixed.inset-0 .close-modal:hover {
    color: #1f2937;
}
.fixed.inset-0 img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
}
.fixed.inset-0 h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.5rem;
}
.fixed.inset-0 p {
    color: #4b5563;
    margin-bottom: 0.5rem;
    line-height: 1.4;
    font-size: 0.875rem;
}
.fixed.inset-0 button.add-to-cart {
    width: 100%;
    background-color: #dc2626;
    color: white;
    padding: 0.5rem;
    border-radius: 0.25rem;
    transition: background-color 0.3s ease;
    font-size: 0.875rem;
}
.fixed.inset-0 button.add-to-cart:hover {
    background-color: #b91c1c;
}
.fixed.inset-0 button.add-to-favorites {
    width: 100%;
    background-color: #e5e7eb;
    color: #1f2937;
    padding: 0.5rem;
    border-radius: 0.25rem;
    margin-top: 0.5rem;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
}
.fixed.inset-0 button.add-to-favorites:hover {
    background-color: #d1d5db;
}
.fixed.inset-0 button.add-to-favorites svg {
    margin-right: 0.25rem;
    width: 1rem;
    height: 1rem;
}

/* Стили для анимации */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Стили для счетчика товаров */
h1 span {
    padding: 0.25rem 0.5rem;
    font-size: 1rem !important;
    font-family: Arial, sans-serif !important;
    min-width: 1.5rem;
    height: 1.5rem;
    line-height: 1.5rem;
    border-radius: 9999px;
}

/* === НОВОЕ: Гарантируем белый цвет текста в подкатегориях === */
.subcategory-card p,
.subcategory-card small {
    color: white !important;
}