: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;
    transition: padding-left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =========================================
   📌 ПРЕМИУМ УМНАЯ СЕТКА И ПАНЕЛИ (ПК)
   ========================================= */

/* МИНИ-ПАНЕЛЬ (Узкая слева) */
.mini-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 60px;
    height: 100vh;
    background: rgba(20, 22, 25, 0.95);
    backdrop-filter: blur(10px);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 1050;
    padding: 10px 0;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s;
}

.nav-icon {
    color: rgba(255, 255, 255, 0.4);
    font-size: 1.3rem;
    cursor: pointer;
    border-radius: 12px;
    transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    justify-content: center;
    align-items: center;
    width: 42px;
    height: 42px;
    margin: 0 auto;
}
.nav-icon:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.nav-icon.active { color: var(--accent); background: rgba(99, 102, 241, 0.15); }

/* ВЫЕЗЖАЮЩЕЕ ПОДМЕНЮ (Анимации - Вертикальная колонка) */
.mini-submenu {
    position: absolute;
    left: 100%;
    top: -5px; /* Выравниваем по верхнему краю иконки-родителя */
    transform: translateX(-15px);
    background: rgba(20, 22, 25, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 8px;
    display: flex;
    flex-direction: column; /* 🔥 Делаем иконки в столбик! */
    gap: 8px;
    opacity: 0;
    pointer-events: none;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1060;
    box-shadow: 5px 5px 20px rgba(0,0,0,0.5);
}
.mini-submenu.show {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(10px);
}

/* =========================================
   ИДЕАЛЬНОЕ ЦЕНТРИРОВАНИЕ ПЛЕЕРА И СТРЕЛОК
   ========================================= */

/* Главный контейнер окна */
#modalMediaContainer {
    position: relative;
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 400px; /* Чтобы пустой плеер не схлопывался */
    background: transparent;
}

/* Принудительно растягиваем JS-обертки на всю ширину */
.player-swipe-zone, 
.player-zoom-container {
    width: 100% !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    position: static !important; /* Отвязываем стрелки от узких оберток */
}

/* Сама картинка или видео */
#modalMediaContainer img,
#modalMediaContainer video {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    margin: 0 auto !important; /* Жестко по центру */
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5); /* Красивая тень для объема */
}

/* Стеклянные стрелки (теперь по бокам самой модалки) */
.gallery-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1050;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.7;
    font-size: 1.4rem;
    padding: 0;
}

.gallery-nav-arrow:hover {
    background: rgba(99, 102, 241, 0.8); /* Фирменный цвет при наведении */
    opacity: 1;
    transform: translateY(-50%) scale(1.1); /* Эффект нажатия */
    border-color: rgba(255, 255, 255, 0.4);
}

.gallery-nav-arrow.prev { left: 20px; } /* Отступ от левого края окна */
.gallery-nav-arrow.next { right: 20px; } /* Отступ от правого края окна */

/* Для мобилок делаем стрелочки аккуратнее и ближе к краям */
@media (max-width: 768px) {
    .gallery-nav-arrow {
        width: 38px;
        height: 38px;
        font-size: 1.1rem;
    }
    .gallery-nav-arrow.prev { left: 5px; }
    .gallery-nav-arrow.next { right: 5px; }
}

/* ОСНОВНОЙ ГЕНЕРАТОР (Сайдбар) */
.sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 320px; 
    height: 100vh;
    z-index: 1045;
    background: #1a1d20;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    box-shadow: 5px 0 25px rgba(0,0,0,0.6);
}

/* ЛОГИКА ПОВЕДЕНИЯ ДЛЯ ПК (>= 992px) */
@media (min-width: 992px) {
    body { padding-left: 60px; } /* Место под мини-панель */
    
    .sidebar {
        transform: translateX(-100%); /* Скрыт влево */
        box-shadow: none;
        border-right: 1px solid rgba(255, 255, 255, 0.05);
    }

    /* СОСТОЯНИЕ: ГЕНЕРАТОР ОТКРЫТ */
    body.sidebar-open { padding-left: 320px; } /* Сдвигаем на ширину генератора */
    
    body.sidebar-open .sidebar {
        transform: translateX(0); /* Показываем генератор */
    }
    
    body.sidebar-open .mini-sidebar {
        transform: translateX(-100%); /* Прячем мини-панель */
        opacity: 0;
        pointer-events: none;
    }

    /* 🔥 МАГИЯ: Скрываем вкладки в шапке, когда генератор ЗАКРЫТ */
    body:not(.sidebar-open) .hide-on-mini {
        display: none !important;
    }
}

/* ЛОГИКА ДЛЯ МОБИЛОК (< 992px) */
@media (max-width: 991px) {
    .mini-sidebar { display: none !important; }
    .sidebar { left: 0; width: 100%; max-width: 360px; transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: 5px 0 25px rgba(0,0,0,0.6); }
    .hide-on-mini { display: flex; } /* На мобилках шапка всегда полная */
}


/* =========================================
   ОСНОВНЫЕ СТИЛИ (Формы, Кнопки, Модалки)
   ========================================= */
.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; padding-bottom: 5px; 
}
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tabs .nav-link {
    color: var(--text-muted); border-radius: 20px; margin-right: 5px; padding: 6px 14px; font-size: 0.9rem; white-space: nowrap; transition: 0.3s;
}

/* =========================================
   СЕТКА ГАЛЕРЕИ И КАРТОЧКИ
   ========================================= */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }

/* ПЛАВНОЕ ПОЯВЛЕНИЕ ПЛИТОК */
.media-card-wrapper { opacity: 0; transform: translateY(15px); animation: tileFadeIn 0.4s ease-out forwards; }
@keyframes tileFadeIn { to { opacity: 1; transform: translateY(0); } }

.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); }

/* Иконки действий на карточке */
.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); } }
.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; }

/* =========================================
   ОСТАЛЬНЫЕ ЭЛЕМЕНТЫ (Аватарки, Плеер)
   ========================================= */
.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; }

.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; }

/* GLASSMORPHISM */
.glass-panel { background: rgba(0, 0, 0, 0.65); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 6px; }
.glass-btn { width: 30px; height: 30px; transition: all 0.2s ease-in-out; }
.glass-btn:hover { background: rgba(99, 102, 241, 0.9) !important; }
.glass-btn.magic { border-color: rgba(255, 193, 7, 0.4); }
.glass-btn.magic:hover { background: rgba(255, 193, 7, 0.2) !important; }
.action-btn-glass { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); border-radius: 50%; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; transition: 0.2s; }

.magic-glow-form { box-shadow: 0 0 30px rgba(99, 102, 241, 0.25) !important; background-color: rgba(99, 102, 241, 0.05) !important; border-radius: 12px !important; transition: box-shadow 0.4s ease-out, background-color 0.4s ease-out !important; }
.magic-glow-input { background-color: rgba(99, 102, 241, 0.25) !important; border-color: var(--accent) !important; transition: background-color 0.3s ease, border-color 0.3s ease !important; }

/* =========================================
   ПОЛЗУНКИ СТИЛЕВЫЕ
   ========================================= */
input[type=range] { -webkit-appearance: none; width: 100%; background: transparent; }
input[type=range]:focus { outline: none; }
input[type=range]::-webkit-slider-runnable-track { width: 100%; height: 6px; cursor: pointer; background: rgba(255, 255, 255, 0.1); border-radius: 4px; border: 1px solid rgba(255, 255, 255, 0.05); box-shadow: inset 0 1px 3px rgba(0,0,0,0.3); }
input[type=range]::-webkit-slider-thumb { height: 18px; width: 18px; border-radius: 50%; background: #fff; border: 2px solid #6366f1; box-shadow: 0 0 10px rgba(99, 102, 241, 0.6); cursor: pointer; -webkit-appearance: none; margin-top: -7px; transition: transform 0.1s, box-shadow 0.2s; }
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.2); box-shadow: 0 0 15px rgba(99, 102, 241, 0.9); }
input[type=range]:active::-webkit-slider-thumb { transform: scale(1.1); background: #6366f1; }
input[type=range]::-moz-range-track { width: 100%; height: 6px; cursor: pointer; background: rgba(255, 255, 255, 0.1); border-radius: 4px; }
input[type=range]::-moz-range-thumb { height: 18px; width: 18px; border-radius: 50%; background: #fff; border: 2px solid #6366f1; box-shadow: 0 0 10px rgba(99, 102, 241, 0.6); cursor: pointer; }

/* =========================================
   ГЛОБАЛЬНЫЕ СКРОЛЛБАРЫ
   ========================================= */
html { scrollbar-width: thin !important; scrollbar-color: rgba(255, 255, 255, 0.15) #1a1d20 !important; }
::-webkit-scrollbar { width: 8px !important; height: 8px !important; }
::-webkit-scrollbar-track { background: #1a1d20 !important; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15) !important; border-radius: 10px !important; border: 2px solid #1a1d20 !important; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.3) !important; }

/* =========================================
   ОКНО ПРОФИЛЯ
   ========================================= */
#profileModal .modal-dialog { max-width: 90vw; }
#profileModal .modal-content { height: 85vh !important; max-height: 85vh !important; overflow: hidden; }
#profileModal .modal-body { overflow-y: auto; overflow-x: hidden; }
.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; }

/* =========================================
   📱 МОБИЛЬНАЯ АДАПТАЦИЯ (Телефоны до 768px)
   ========================================= */
@media (max-width: 768px) {
    .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 12px; }
    .top-header { position: sticky; top: 0; z-index: 1040; background-color: rgba(18, 18, 18, 0.95); backdrop-filter: blur(10px); 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); }
    .media-card { border-radius: 10px; }
    .media-overlay { padding: 30px 6px 6px; } 
    .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; } 
    .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; }
    .favorite-btn-top { width: 32px; height: 32px; top: 6px; right: 6px; }
    .favorite-btn-top .heart-icon { font-size: 1.1rem !important; }
    
    .sidebar { border-left: 1px solid rgba(255,255,255,0.1); border-bottom: none !important; padding: 20px 20px 100px !important; }
    .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: 12px 0 0 12px; padding: 12px 6px 12px 10px; z-index: 1045; cursor: pointer; transition: 0.2s; }
    .mobile-gen-trigger i { font-size: 1.3rem; text-shadow: 0 0 10px rgba(255,255,255,0.5); }
    .mobile-gen-trigger.active-glow { background: #fff; color: var(--accent); box-shadow: 0 0 20px rgba(255,255,255,0.9); transform: translateY(-50%) scale(0.95); }
    .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; }
}