/* ============================================
   COSMIC FANTASY GALLERY PAGE MOBILE
   Компактная и удобная адаптация страницы галереи для мобильных
   ============================================ */

/* ========== ФИЛЬТРЫ ГАЛЕРЕИ - АККОРДЕОН ========== */
@media (max-width: 768px) {
    /* Контейнер фильтров */
    .gallery-controls-advanced {
        padding: 12px !important;
        border-radius: 12px;
        margin-bottom: 20px;
    }
    
    /* Секции фильтров - аккордеон стиль */
    .filter-section {
        margin-bottom: 12px !important;
        background: rgba(15, 15, 25, 0.4);
        border: 1px solid rgba(139, 92, 246, 0.2);
        border-radius: 10px;
        overflow: hidden;
        transition: all 0.3s ease;
    }
    
    .filter-section:last-of-type {
        margin-bottom: 12px;
    }
    
    /* Заголовок секции фильтра - кликабельный */
    .filter-section-header {
        font-size: 12px !important;
        font-weight: 700;
        padding: 12px 14px !important;
        margin-bottom: 0 !important;
        gap: 10px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: space-between;
        user-select: none;
        transition: all 0.3s ease;
        background: rgba(139, 92, 246, 0.08);
        border-bottom: 1px solid rgba(139, 92, 246, 0.2);
        position: relative;
    }
    
    .filter-section-header:hover {
        background: rgba(139, 92, 246, 0.15);
    }
    
    .filter-section-header:active {
        background: rgba(139, 92, 246, 0.2);
    }
    
    .filter-section-header i:first-child {
        font-size: 14px !important;
        color: rgba(255, 255, 255, 0.95) !important;
        filter: drop-shadow(0 0 4px rgba(139, 92, 246, 0.6)) !important;
        flex-shrink: 0;
    }
    
    .filter-section-header span {
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        flex: 1;
        text-align: left;
        color: rgba(255, 255, 255, 0.95);
    }
    
    /* Иконка сворачивания/разворачивания */
    .filter-section-header::after {
        content: '\f078';
        font-family: 'Font Awesome 6 Free';
        font-weight: 900;
        font-size: 11px;
        color: rgba(255, 255, 255, 0.7);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        flex-shrink: 0;
        margin-left: 8px;
    }
    
    .filter-section.collapsed .filter-section-header::after {
        transform: rotate(-90deg);
    }
    
    /* Активная секция */
    .filter-section:not(.collapsed) .filter-section-header {
        background: rgba(139, 92, 246, 0.12);
        border-bottom-color: rgba(139, 92, 246, 0.3);
    }
    
    /* Контейнер тегов фильтров - многострочный с ограничением высоты */
    .filter-tags {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 6px;
        padding: 12px 14px;
        max-height: 200px;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: rgba(139, 92, 246, 0.3) transparent;
        transition: all 0.3s ease;
    }
    
    .filter-tags::-webkit-scrollbar {
        width: 4px;
    }
    
    .filter-tags::-webkit-scrollbar-thumb {
        background: rgba(139, 92, 246, 0.3);
        border-radius: 2px;
    }
    
    /* Скрываем теги при сворачивании */
    .filter-section.collapsed .filter-tags {
        max-height: 0;
        padding: 0 14px;
        overflow: hidden;
    }
    
    /* Теги фильтров - компактные чипсы */
    .filter-tag {
        padding: 6px 10px !important;
        font-size: 10px !important;
        font-weight: 600;
        border-radius: 6px;
        white-space: nowrap;
        flex-shrink: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
        transition: all 0.3s ease;
        min-width: auto;
        line-height: 1.2;
    }
    
    /* Иконки в тегах фильтров - скрываем на мобильных для компактности */
    .filter-tag i {
        display: none;
    }
    
    /* Активный тег фильтра */
    .filter-tag.active {
        background: linear-gradient(135deg, rgba(139, 92, 246, 0.3) 0%, rgba(236, 72, 153, 0.3) 100%) !important;
        border-color: rgba(139, 92, 246, 0.5) !important;
        color: rgba(255, 255, 255, 0.95) !important;
        box-shadow: 
            0 2px 6px rgba(139, 92, 246, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
    }
    
    /* Неактивный тег фильтра */
    .filter-tag:not(.active) {
        background: rgba(15, 15, 25, 0.6) !important;
        border-color: rgba(139, 92, 246, 0.2) !important;
        color: var(--text-muted) !important;
    }
    
    /* Touch эффект */
    .filter-tag:active {
        transform: scale(0.96);
        box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2) !important;
    }
    
    /* Строка с моделью и сортировкой */
    .controls-row {
        flex-direction: column !important;
        gap: 12px !important;
        margin-top: 16px;
    }
    
    /* Группа фильтров модели */
    .filter-group-compact {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    
    .filter-label-compact {
        font-size: 11px !important;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        gap: 6px;
    }
    
    .filter-label-compact i {
        font-size: 12px;
        color: rgba(255, 255, 255, 0.9);
    }
    
    /* Кнопки фильтров модели */
    .filter-buttons-compact {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .filter-btn-compact {
        padding: 6px 12px !important;
        font-size: 10px !important;
        border-radius: 6px;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    /* Группа сортировки */
    .sort-group-compact {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    
    .sort-label-compact {
        font-size: 11px !important;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    .sort-select-compact {
        width: 100%;
        padding: 8px 12px !important;
        font-size: 11px !important;
    }
}

/* Очень маленькие экраны */
@media (max-width: 480px) {
    .gallery-controls-advanced {
        padding: 10px !important;
        border-radius: 10px;
    }
    
    .filter-section {
        margin-bottom: 10px !important;
        border-radius: 8px;
    }
    
    .filter-section-header {
        font-size: 11px !important;
        padding: 10px 12px !important;
    }
    
    .filter-section-header i:first-child {
        font-size: 12px !important;
    }
    
    .filter-tags {
        gap: 5px;
        padding: 10px 12px;
        max-height: 180px;
    }
    
    .filter-tag {
        padding: 5px 8px !important;
        font-size: 9px !important;
        border-radius: 5px;
    }
    
    .controls-row {
        gap: 10px !important;
    }
    
    .filter-btn-compact {
        padding: 5px 10px !important;
        font-size: 9px !important;
    }
}

/* ========== СЕТКА ГАЛЕРЕИ - 3 В РЯД ========== */
@media (max-width: 768px) {
    /* Сетка галереи - 3 карточки в ряд */
    .gallery-grid-main,
    #galleryGrid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 10px !important;
        padding: 0 12px;
        margin-bottom: 24px;
    }
    
    /* Карточки галереи */
    .gallery-card {
        border-radius: 10px;
        overflow: hidden;
        min-height: 0;
        border-width: 1px;
    }
    
    /* Обертка изображения */
    .gallery-card-image {
        aspect-ratio: 1;
        min-height: 0;
        width: 100%;
    }
    
    .gallery-card-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }
    
    /* Скрываем overlay на мобильных для компактности */
    .gallery-card-overlay {
        display: none !important;
    }
    
    /* Скрываем текст на мобильных */
    .gallery-card-prompt,
    .gallery-card-size,
    .gallery-card-footer {
        display: none !important;
    }
    
    /* Убираем hover эффекты на мобильных */
    .gallery-card:hover {
        transform: none;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    }
    
    .gallery-card:active {
        transform: scale(0.98);
        opacity: 0.8;
    }
}

/* Очень маленькие экраны - оставляем 3 колонки, но уменьшаем gap */
@media (max-width: 480px) {
    .gallery-grid-main,
    #galleryGrid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
        padding: 0 8px;
    }
    
    .gallery-card {
        border-radius: 8px;
    }
}

/* Очень-очень маленькие экраны */
@media (max-width: 360px) {
    .gallery-grid-main,
    #galleryGrid {
        gap: 6px !important;
        padding: 0 6px;
    }
    
    .gallery-card {
        border-radius: 6px;
    }
}

/* ========== ОБЩИЕ УЛУЧШЕНИЯ ========== */
@media (max-width: 768px) {
    /* Контейнер галереи */
    .gallery-container {
        padding: 20px 12px 40px !important;
    }
    
    /* Заголовок страницы */
    .gallery-header {
        padding: 60px 16px 30px !important;
    }
    
    .gallery-title {
        font-size: 32px !important;
    }
    
    .gallery-subtitle {
        font-size: 14px !important;
    }
    
    /* Плавные анимации */
    .filter-tag,
    .filter-btn-compact,
    .gallery-card {
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    /* Улучшенная читаемость */
    .filter-section-header,
    .filter-tag,
    .filter-label-compact {
        text-rendering: optimizeLegibility;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}
