/* static/css/styles.css */

/* Базовые стили для адаптивности */
body {
    font-family: 'Lato', Arial, sans-serif;
    /* Основной шрифт */
}

/* Стили для фильтров */
.filter-sidebar {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    margin-bottom: 1.5rem;
}

.filter-sidebar .form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #495057;
    font-size: 0.95rem;
}

.filter-sidebar .accordion-button {
    font-size: 1rem;
    font-weight: 500;
    padding: 0.75rem 1.25rem;
}

.filter-sidebar .accordion-body {
    padding: 1rem 1.25rem;
}

.filter-sidebar .form-control,
.filter-sidebar .form-select {
    border-radius: 6px;
    border: 1px solid #ced4da;
    font-size: 0.9rem;
}

.filter-sidebar .price-range-input {
    width: 80px;
    display: inline-block;
    margin: 0 5px;
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    /* Меньше padding */
}

.filter-sidebar .attribute-filter {
    margin-bottom: 1rem;
}

.filter-sidebar .form-check {
    margin-bottom: 0.25rem;
}

.filter-sidebar .form-check-label {
    font-size: 0.9rem;
    color: #495057;
}

.filter-sidebar .btn {
    border-radius: 6px;
    font-size: 0.9rem;
    padding: 0.375rem 0.75rem;
    /* Меньше padding */
}

/* Стили для карточек товаров */
.furniture-card {
    transition: all 0.2s ease-in-out;
    height: 100%;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
    background-color: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.furniture-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #dee2e6;
}

.furniture-image {
    height: 200px;
    object-fit: cover;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.card-title {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
    font-weight: 500;
    color: #212529;
}

.card-text.text-muted {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    color: #6c757d !important;
}

/* Стили для кнопок */
.btn-primary {
    border-radius: 6px;
    padding: 0.375rem 0.75rem;
    font-size: 0.9rem;
    background-color: #212529;
    /* Темный цвет для премиальности */
    border-color: #212529;
}

.btn-primary:hover {
    background-color: #000;
    border-color: #000;
}

/* Стили для пагинации */
.pagination {
    justify-content: center;
    margin-top: 2rem;
    margin-bottom: 2rem;
}

.page-link {
    color: #212529;
}

.page-item.active .page-link {
    background-color: #212529;
    border-color: #212529;
}

/* Стили для заголовков */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Playfair Display', Georgia, 'Times New Roman', Times, serif;
    /* Премиальный шрифт для заголовков */
}

/* Стили для загрузки */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-request.htmx-indicator {
    display: inline-block;
}

/* Адаптивная галерея изображений */
.furniture-gallery {
    margin: 1rem 0;
}

.main-image-container {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 75%;
    /* 4:3 соотношение сторон */
    overflow: hidden;
    border-radius: 8px;
    background-color: #f8f9fa;
    margin-bottom: 1rem;
}

.main-image-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Сохраняем пропорции изображения */
    background-color: white;
    cursor: pointer;
}

.thumbnail-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 0.5rem;
    margin-top: 1rem;
}

.thumbnail-item {
    aspect-ratio: 1;
    /* Квадратные превью */
    overflow: hidden;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    background-color: #f8f9fa;
}

.thumbnail-item:hover {
    border-color: #007bff;
    transform: scale(1.05);
}

.thumbnail-item.active {
    border-color: #007bff;
    box-shadow: 0 0 0 2px #007bff;
}

.thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Обрезаем изображение до квадрата */
}

/* Модальное окно для полноэкранного просмотра */
.modal-image-viewer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.modal-image-content {
    max-width: 90vw;
    max-height: 90vh;
    position: relative;
}

.modal-image-content img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10001;
    background: none;
    border: none;
}

/* Навигация в модальном окне */
.modal-navigation {
    position: absolute;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    box-sizing: border-box;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10001;
}

.modal-nav-btn {
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    padding: 15px;
    font-size: 24px;
    cursor: pointer;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.modal-nav-btn:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

/* Кнопка "Назад" */
.back-button {
    margin-bottom: 20px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
}

.back-button:hover {
    background-color: #e9ecef;
    border-color: #ced4da;
}

/* Стили для страницы деталей товара */
.product-gallery {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.gallery-image-wrapper {
    width: 90px;
    height: 90px;
    flex-shrink: 0;
    border: 1px solid transparent;
    border-radius: 3px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: #f8f9fa;
}

.gallery-image-wrapper:hover {
    border-color: #adb5bd;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.gallery-image-wrapper.active {
    border-color: #8B0000;
    box-shadow: 0 0 0 2px rgba(139, 0, 0, 0.2);
}

.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

/* Адаптивность */
@media (max-width: 767.98px) {
    .filter-sidebar {
        margin-bottom: 1rem;
        padding: 0.75rem;
    }

    .furniture-card {
        margin-bottom: 1rem;
    }

    .furniture-image {
        height: 150px;
        /* Меньше высота на мобильных */
    }

    .card-title {
        font-size: 1rem;
    }

    /* Возможно, скрыть некоторые элементы на очень маленьких экранах */
    .card-text.text-muted.small {
        font-size: 0.8rem;
    }

    /* Адаптивность галереи */
    .thumbnail-gallery {
        grid-template-columns: repeat(5, 1fr);
        gap: 0.25rem;
    }

    .thumbnail-item {
        border-radius: 2px;
    }

    .main-image-container {
        padding-bottom: 100%;
        /* Квадрат на мобильных */
        margin-bottom: 0.5rem;
    }

    .gallery-image-wrapper {
        width: 70px;
        height: 70px;
    }
}

@media (max-width: 480px) {
    .thumbnail-gallery {
        grid-template-columns: repeat(4, 1fr);
    }

    .modal-image-content {
        max-width: 95vw;
        max-height: 85vh;
    }

    .gallery-image-wrapper {
        width: 60px;
        height: 60px;
    }
}

/* Горизонтальная прокрутка на очень маленьких экранах */
@media (max-width: 360px) {
    .thumbnail-gallery {
        grid-template-columns: repeat(6, 45px);
        gap: 0.2rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .gallery-image-wrapper {
        width: 50px;
        height: 50px;
    }
}

/* Для очень маленьких экранов */
@media (max-width: 575.98px) {
    .filter-sidebar .accordion-button {
        padding: 0.5rem 1rem;
        font-size: 0.95rem;
    }

    .filter-sidebar .accordion-body {
        padding: 0.75rem 1rem;
    }

    .filter-sidebar .form-label {
        font-size: 0.9rem;
    }

    .filter-sidebar .form-check-label {
        font-size: 0.85rem;
    }

    /* Стили для кликабельных карточек товаров */
    .furniture-card {
        position: relative;
        transition: all 0.2s ease-in-out;
    }

    .furniture-card::after {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1;
    }

    .furniture-card:hover {
        transform: translateY(-5px);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    }

    /* Убедимся, что кнопка "Подробнее" остается над псевдоэлементом */
    .furniture-card .btn {
        position: relative;
        z-index: 2;
    }

    /* Улучшим визуальный отклик при наведении */
    .furniture-card:hover .card-title {
        color: #007bff;
    }

    /* Анимация для плавного изменения цвета */
    .furniture-card .card-title {
        transition: color 0.2s ease;
    }
}