/* ========================================================================= */
/* ===         05_RESPONSIVE.CSS - АДАПТИВНОСТЬ ДЛЯ МОБИЛЬНЫХ           ===  */
/* ========================================================================= */
/* Этот файл содержит все стили, которые применяются только на               */
/* устройствах с шириной экрана 992px и меньше. Он переопределяет            */
/* десктопные стили для корректного отображения на мобильных.                */
/* ========================================================================= */

@media (max-width: 992px) {

    /* ================================================================= */
    /* ===     ЛОГИКА ДЛЯ ОСНОВНОГО ПРИЛОЖЕНИЯ (MAIN APP)            === */
    /* ================================================================= */

    /* --- ГЛОБАЛЬНЫЕ ИЗМЕНЕНИЯ --- */
    body.is-logged-in {
        overflow-y: auto; /* Разрешаем прокрутку для всей страницы */
    }
    body.is-logged-in.chat-is-active {
        overflow: hidden; /* Когда открыт чат, запрещаем прокрутку */
    }
    
    /* --- ОСНОВНАЯ СТРУКТУРА (LAYOUT) --- */
    .main-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        padding: 0 0.5rem;
        gap: 0;
    }
    body.chat-is-active .main-container {
        height: 100vh;
        padding: 0;
    }
    
    .panel {
        flex-basis: auto;
        width: 100%;
        max-height: none;
        overflow-y: visible;
        border: none;
    }

    /* --- ПАНЕЛИ И ИНТЕРФЕЙС --- */
    .controls-panel {
        order: 1;
        position: relative;
        z-index: 2;
    }
    .controls-panel .panel-logo,
    .controls-panel .logo-text {
        display: none;
    }

    .generation-space {
        order: 2;
        position: relative;
        z-index: 1;
        background-color: transparent;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        flex-grow: 1;
        min-height: 0;
        padding: 0;
    }

    #results-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 0.5rem;
        padding-right: 0;
    }
    .result-card:hover {
        transform: none;
    }

    /* --- ВЫДВИЖНАЯ ПАНЕЛЬ РЕЖИМОВ (СЛЕВА) --- */
    .modes-panel {
        position: fixed;
        top: 0; 
        left: 0; 
        height: 100%;
        z-index: 1045;
        
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        box-shadow: 4px 0 15px rgba(0,0,0,0.4);
        
        overflow-y: auto;
        padding: 1.5rem;
        background-color: var(--bg-panel);

        /* === ВОТ ЭТИ СТРОКИ ИСПРАВЯТ СИТУАЦИЮ === */
        flex: none !important;        /* Отключаем влияние flex-родителя */
        min-width: 0 !important;      /* Убиваем "min-width: 350px" из десктопа */
        width: 80% !important;        /* Ставим 80% вместо 100% от класса .panel */
        max-width: 320px !important;  /* Ограничиваем, чтобы не было слишком широко */
    }
    .modes-panel.is-open {
        transform: translateX(0);
    }
    .modes-panel h5 {
        display: block;
        padding: 0.5rem 0;
    }
    #modes-menu {
        display: flex;
        flex-direction: column;
        padding-bottom: 0;
        gap: 0.5rem;
    }
    .mode-button {
        font-size: 1rem;
        padding: 1rem;
    }

    /* --- ЧАТ --- */
    #chat-participants-view {
        display: none !important; /* Полностью скрываем десктопный список участников */
    }

    #mobile-participants-counter {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        position: absolute;
        top: 1rem;
        right: 1rem;
        z-index: 10;
        background-color: rgba(0, 0, 0, 0.3);
        backdrop-filter: blur(5px);
        padding: 0.25rem 0.75rem;
        border-radius: 2rem;
        font-size: 0.8rem;
        color: var(--text-secondary);
        font-weight: 500;
    }
    #mobile-participants-counter strong {
        color: var(--text-primary);
    }
    
    /* --- РАДИО-ПЛЕЕР (в выдвижном меню) --- */
    #radio-player-container {
        margin-top: 1rem;
        display: none;
    }
    .modes-panel.radio-active #radio-player-container {
        display: block;
    }
    #radio-player-container .player-track-info {
        padding: 0.5rem;
        border-top: none;
        background-color: var(--background-tertiary);
        border-radius: 0.5rem;
    }
    #radio-player-container .player-controls {
        padding: 0.5rem 1rem 0 1rem;
        justify-content: space-between;
    }
    #radio-player-container .volume-control-container {
        display: flex;
    }
    #radio-player-container .volume-slider {
        width: 70px;
        opacity: 1;
    }
    
    /* --- ПРОЧЕЕ --- */
    .gallery-nav-btn { 
        display: none; /* Прячем стрелки в галерее, т.к. на мобильных будет свайп */
    }

    #profile-view .history-header {
        margin-top: 1.5rem;
    }

    #control-form {
        height: auto !important;       /* Пусть растягивается по контенту */
        overflow: visible !important;  /* Разрешаем контенту выходить за границы */
    }

    /* Разрешаем обертке контента тоже растягиваться */
    #control-form .form-content-wrapper {
        flex-grow: 0 !important;       /* Не нужно занимать всё место, только сколько есть */
        overflow: visible !important;  /* Скроллит body, а не этот блок */
        height: auto !important;
        margin-bottom: 0 !important;
    }

    /* Кнопка генерации просто идет следом в потоке */
    #control-form .mt-auto {
        margin-top: 20px !important;   /* Отступ от полей до кнопки */
        position: static !important;   /* Обычное позиционирование */
    }
    
} /* Конец главного медиа-запроса @media (max-width: 992px) */