:root {
    --bg-dark: #121212;
    --bg-panel: #1e1e1e;
    --bg-input: #2d2d2d;
    --accent: #6366f1; /* Стильный фиолетово-синий */
    --accent-hover: #4f46e5;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    height: 100vh;
    overflow-x: hidden;
}

/* Левая панель */
.sidebar {
    background-color: var(--bg-panel);
    border-right: 1px solid #2d2d2d;
    height: 100vh;
    overflow-y: auto;
    position: sticky;
    top: 0;
}

/* Формы */
.custom-input, .custom-select, .custom-file {
    background-color: var(--bg-input) !important;
    color: var(--text-main) !important;
    border: 1px solid #3f3f46 !important;
    border-radius: 8px;
}
.custom-input:focus, .custom-select:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 0.25rem rgba(99, 102, 241, 0.25) !important;
}
.generate-btn {
    background-color: var(--accent);
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    transition: 0.3s;
}
.generate-btn:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
}

/* Рабочая область и Вкладки */
.main-content {
    height: 100vh;
    overflow-y: auto;
}
/* Делаем контейнер вкладок в одну линию */
.filter-tabs {
    display: flex;
    flex-wrap: nowrap; /* Жестко запрещаем перенос на вторую строку */
    overflow-x: auto; /* Включаем плавный скролл, если экран слишком узкий */
    scrollbar-width: none; /* Прячем ползунок (Firefox) */
    padding-bottom: 5px; 
}
.filter-tabs::-webkit-scrollbar {
    display: none; /* Прячем ползунок (Chrome/Safari) */
}

/* Сами кнопки делаем компактнее */
.filter-tabs .nav-link {
    color: var(--text-muted);
    border-radius: 20px;
    margin-right: 5px; /* Уменьшили отступ между кнопками */
    padding: 6px 14px; /* Уменьшили размер самой кнопки */
    font-size: 0.9rem; /* Чуть аккуратнее шрифт */
    white-space: nowrap; /* Запрещаем тексту внутри кнопки ломаться на 2 строки */
    transition: 0.3s;
}

/* Сетка Галереи (Grid) */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

/* Карточка генерации */
.media-card {
    background-color: var(--bg-panel);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    border: 1px solid #2d2d2d;
    aspect-ratio: 4/5;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.media-card:hover {
    transform: scale(1.02);
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
    border-color: #4b5563;
}
.media-card video, .media-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.media-overlay {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
    padding: 20px 15px 10px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}
.badge-mode {
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(5px);
}
.play-icon {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    color: rgba(255,255,255,0.7);
    transition: 0.2s;
}
.media-card:hover .play-icon {
    color: white;
    transform: translate(-50%, -50%) scale(1.1);
}
.status-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
}

/* Модальное окно плеера */
.custom-modal .modal-content {
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.7);
}
#modalMediaContainer video, #modalMediaContainer img {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 8px;
}

/* --- СТРЕЛКИ НАВИГАЦИИ (ПК) --- */
.gallery-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0.4);
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1050;
    transition: background-color 0.2s, opacity 0.2s, transform 0.2s;
    opacity: 0.6;
    font-size: 1.2rem;
}
.gallery-nav-arrow:hover {
    background-color: rgba(0, 0, 0, 0.8);
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
}
.gallery-nav-arrow.prev {
    left: 15px;
}
.gallery-nav-arrow.next {
    right: 15px;
}
/* ------------------------------ */

/* Мобильная адаптация */
@media (max-width: 991px) {
    .sidebar { height: auto; position: relative; border-right: none; border-bottom: 1px solid #2d2d2d; }
    .main-content { height: auto; overflow-y: visible; }
}

/* Верхний бар и Аватарки */
.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.1rem;
    text-transform: uppercase;
    transition: transform 0.2s;
}
.profile-toggle:hover .user-avatar {
    transform: scale(1.05);
}
.profile-toggle::after {
    margin-left: 0.5rem; /* Отступ для стрелочки */
}
/* Цвета статусов */
.avatar-user { background: linear-gradient(135deg, #6366f1, #4f46e5); color: white; }
.avatar-guest { background: #4b5563; color: #d1d5db; }

/* Анимация и стили для сердечка (Лайков) */
.heart-icon {
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.2s;
    cursor: pointer;
}
.heart-icon:hover {
    transform: scale(1.2);
}
.scale-up {
    animation: heartBeat 0.3s forwards;
}
@keyframes heartBeat {
    0% { transform: scale(1); }
    50% { transform: scale(1.4); }
    100% { transform: scale(1); }
}
.btn-link {
    text-decoration: none !important;
}

/* Анимация маленькой корзины на карточках */
.delete-icon-btn i {
    transition: color 0.2s, transform 0.2s;
}
.delete-icon-btn:hover i {
    color: #dc3545 !important; /* Красный цвет */
    transform: scale(1.1);
}

/* Кнопка лайка в правом верхнем углу */
.favorite-btn-top {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    transition: background 0.2s;
}
.favorite-btn-top:hover {
    background: rgba(0, 0, 0, 0.7);
}
.favorite-btn-top .heart-icon {
    font-size: 1.2rem !important;
}

#galleryTabs::-webkit-scrollbar { display: none; }
#galleryTabs { scrollbar-width: none; }

/* =========================================
   📱 МОБИЛЬНАЯ АДАПТАЦИЯ (Телефоны до 768px) - PRO ВЕРСИЯ
   ========================================= */
@media (max-width: 768px) {
    
    /* 1. СЕТКА: 2 аккуратные колонки без пустых дыр */
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
        gap: 12px;
    }

    /* 2. НАВИГАЦИЯ: "Прилипает" к верху при скролле (App-like UX) */
    .top-header {
        position: sticky;
        top: 0;
        z-index: 1040;
        background-color: rgba(18, 18, 18, 0.95); /* Полупрозрачный темный фон */
        backdrop-filter: blur(10px); /* Эффект матового стекла как на iPhone */
        padding: 12px 15px 8px !important;
        margin: 0 -15px 15px !important; /* Компенсируем отступы контейнера */
        border-bottom: 1px solid #2d2d2d !important;
        box-shadow: 0 5px 15px rgba(0,0,0,0.4);
    }
    
    /* Плавный скролл вкладок пальцем */
    .filter-tabs {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 5px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .filter-tabs::-webkit-scrollbar { display: none; }
    .filter-tabs .nav-link {
        white-space: nowrap;
        padding: 6px 14px;
        font-size: 0.85rem;
    }

    /* 3. КАРТОЧКИ: Компактный режим (Убираем кашу из иконок) */
    .media-card { border-radius: 10px; }
    .media-overlay { padding: 30px 6px 6px; } /* Чуть больше градиента сверху, меньше по бокам */

    /* Скрываем текстовый бейджик "IMAGE/LIVE", оставляем только иконку */
    .badge-mode {
        font-size: 0 !important; 
        padding: 0 !important;
        width: 24px;
        height: 24px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(255,255,255,0.2);
    }
    .badge-mode i { font-size: 0.75rem; margin: 0 !important; }

    /* Сжимаем правый нижний угол (Кнопки Редактора/Видео/Микрофона) */
    .media-overlay .gap-2 { gap: 4px !important; }
    .project-btn {
        width: 26px !important;
        height: 26px !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
    .project-btn i { font-size: 0.8rem; }

    /* Сжимаем кнопки удаления и глазика */
    .delete-icon-btn, .private-icon-btn {
        width: 22px !important;
        height: 22px !important;
    }
    .delete-icon-btn i, .private-icon-btn i { font-size: 0.7rem !important; }
    .media-overlay .text-white-50.small { font-size: 0.65rem !important; } /* ID номер */

    /* Сжимаем левый верхний угол (Бейджик группировки и Вход в студию) */
    .media-card > .position-absolute.d-flex {
        top: 6px !important;
        left: 6px !important;
        gap: 4px !important;
    }
    .media-card > .position-absolute.d-flex > div {
        height: 24px !important;
        padding: 0 6px !important;
    }
    .media-card > .position-absolute.d-flex > div span { font-size: 0.65rem !important; }
    .media-card > .position-absolute.d-flex > button {
        width: 24px !important;
        height: 24px !important;
    }
    .media-card > .position-absolute.d-flex > button i { font-size: 0.8rem; }

    /* Сжимаем Сердечко (Лайк) */
    .favorite-btn-top {
        width: 32px;
        height: 32px;
        top: 6px;
        right: 6px;
    }
    .favorite-btn-top .heart-icon { font-size: 1.1rem !important; }

    /* 4. ЛЕВАЯ ПАНЕЛЬ (Теперь это выезжающая шторка) */
    .sidebar {
        position: fixed !important;
        top: 0;
        right: -100%; /* Прячем за правым краем экрана */
        width: 85vw !important; /* Занимает 85% экрана */
        max-width: 400px;
        height: 100vh !important;
        max-height: 100vh;
        overflow-y: auto;
        z-index: 1060;
        background: rgba(25, 25, 25, 0.95) !important;
        backdrop-filter: blur(20px); /* Эффект стекла */
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-left: 1px solid rgba(255,255,255,0.1);
        border-bottom: none !important;
        padding: 20px 20px 100px !important; /* Отступ снизу, чтобы форма не перекрывалась */
        box-shadow: -10px 0 30px rgba(0,0,0,0.8);
    }

    /* Класс, который JS будет добавлять для открытия */
    .sidebar.open { right: 0; }

    /* Кнопка вызова (Магическая палочка справа) */
    .mobile-gen-trigger {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 60%;
        right: 0;
        transform: translateY(-50%);
        background: linear-gradient(270deg, rgba(99, 102, 241, 0.9) 0%, rgba(79, 70, 229, 0.6) 100%);
        backdrop-filter: blur(8px);
        color: white;
        border: 1px solid rgba(255,255,255,0.3);
        border-right: none;
        border-radius: 16px 0 0 16px;
        padding: 18px 10px 18px 14px;
        z-index: 1045;
        cursor: pointer;
        transition: 0.2s;
    }
    .mobile-gen-trigger i { font-size: 1.5rem; text-shadow: 0 0 10px rgba(255,255,255,0.5); }
    .mobile-gen-trigger:active { padding-right: 6px; background: var(--accent); }

    /* Затемнение фона при открытой шторке */
    .sidebar-backdrop {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.7);
        backdrop-filter: blur(3px);
        z-index: 1055;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    .sidebar-backdrop.show { opacity: 1; }

    /* Жирная кнопка генерации со свечением */
    .generate-btn {
        padding: 16px;
        font-size: 1.15rem;
        border-radius: 12px;
        box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5); 
    }
    
    /* Увеличиваем ползунок "Фантазии", чтобы пальцем было легко попасть */
    input[type=range]::-webkit-slider-thumb {
        width: 22px !important;
        height: 22px !important;
    }

    /* Модалки под мобилку (убираем лишние отступы) */
    .custom-modal .modal-dialog { margin: 10px; }
    #modalMediaContainer video, #modalMediaContainer img { max-height: 75vh; }
}

/* =========================================
   СТИЛИ ДЛЯ ЛИЧНОГО ПРОФИЛЯ
   ========================================= */

/* Легкая косметика для левого меню профиля */
.custom-pills .nav-link { 
    color: var(--text-muted); 
    border-radius: 8px; 
    transition: 0.2s; 
}
.custom-pills .nav-link:hover { 
    background-color: rgba(255,255,255,0.05); 
    color: white; 
}
.custom-pills .nav-link.active { 
    background-color: var(--accent); 
    color: white; 
}

/* Таблица промптов */
.custom-table { 
    --bs-table-bg: transparent; 
    --bs-table-color: var(--text-main); 
    border-color: #3f3f46; 
}
.custom-table td, .custom-table th { 
    border-bottom-color: #3f3f46; 
    background-color: transparent !important; 
    vertical-align: middle;
}

/* Обрезка длинного текста промпта */
.prompt-cell { 
    max-width: 300px; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    font-family: monospace; 
    font-size: 0.85rem; 
}

/* Фильтры-табы категорий */
#categoryFilters {
    flex-wrap: wrap;
}
