/* =========================================
   1. ГЛОБАЛЬНЫЕ ПЕРЕМЕННЫЕ И СБРОС
   ========================================= */
:root {
    --bg-dark: #0f1012;
    --bg-card: #1b1d21;
    --text-main: #e0e0e0;
    --text-muted: #9ca3af;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --border-color: rgba(255, 255, 255, 0.1);
    --sidebar-width: 300px; /* Ширина сайдбара библиотеки */
}

body {
    background-color: var(--bg-dark);
    background-image: radial-gradient(circle at 50% 0%, #1e293b 0%, #0f1012 100%);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden; 
}

a { text-decoration: none; color: inherit; transition: 0.2s; }
a:hover { color: var(--accent); }

/* Скроллбар */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #1a1a1a; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* =========================================
   2. ЭЛЕМЕНТЫ ФОРМ И КНОПКИ
   ========================================= */
.form-control, .form-select {
    background-color: #0b0c10;
    border: 1px solid var(--border-color);
    color: #fff;
    padding: 10px 15px;
}
.form-control:focus, .form-select:focus {
    background-color: #0b0c10;
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}
.form-control::placeholder { color: #555; }

.btn-primary { background-color: var(--accent); border: none; font-weight: 600; padding: 10px 20px; transition: 0.2s; }
.btn-primary:hover { background-color: var(--accent-hover); transform: translateY(-1px); }
.btn-danger { background-color: #ef4444; border: none; }
.btn-danger:hover { background-color: #dc2626; }
.btn-success { background-color: #10b981; border: none; color: #fff; }
.btn-success:hover { background-color: #059669; }

/* Карточки и Таблицы (Общие) */
.card-dark { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.table-dark { --bs-table-bg: transparent; color: #ccc; }
.table-dark td, .table-dark th { border-color: var(--border-color); vertical-align: middle; }

/* =========================================
   3. СТРАНИЦА ВХОДА (LOGIN)
   ========================================= */
.login-wrapper { display: flex; align-items: center; justify-content: center; height: 100vh; width: 100%; }
.login-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 16px; padding: 40px; width: 100%; max-width: 400px; box-shadow: 0 20px 50px rgba(0,0,0,0.5); }
.login-logo { font-weight: 900; font-size: 1.8rem; text-align: center; margin-bottom: 30px; color: #fff; }
.login-logo span { color: var(--accent); }

/* =========================================
   4. ЛОАДЕР ЗАГРУЗКИ (Admin Upload)
   ========================================= */
.upload-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(5px);
    z-index: 9999; display: none; /* Скрыто по умолчанию */
    align-items: center; justify-content: center; flex-direction: column;
}
.upload-overlay.active .upload-card { transform: scale(1); }
.upload-card {
    background: var(--bg-card); border: 1px solid var(--border-color); padding: 30px;
    border-radius: 16px; width: 90%; max-width: 400px; text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5); transform: scale(0.9); transition: 0.3s;
}
.progress-container { width: 100%; height: 10px; background: #333; border-radius: 5px; margin: 20px 0; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), #60a5fa); transition: width 0.1s linear; }
.upload-status-icon { font-size: 3rem; margin-bottom: 15px; }
.status-text { font-size: 1.1rem; font-weight: 600; color: #fff; }
.error-text { color: #ef4444; font-size: 0.9rem; margin-top: 10px; display: none; }

/* =========================================
   5. АДМИНКА (WordPress Style)
   ========================================= */
.admin-wrapper { display: flex; min-height: 100vh; }

.admin-sidebar {
    width: 260px; background: var(--bg-card); border-right: 1px solid var(--border-color);
    display: flex; flex-direction: column; position: fixed; height: 100vh; z-index: 100;
}
.admin-brand { height: 60px; display: flex; align-items: center; padding: 0 20px; font-weight: 900; font-size: 1.2rem; border-bottom: 1px solid var(--border-color); color: #fff; }
.admin-menu { list-style: none; padding: 20px 0; margin: 0; }
.menu-link { display: flex; align-items: center; padding: 12px 20px; color: var(--text-muted); font-weight: 500; transition: 0.2s; cursor: pointer; border-left: 3px solid transparent; }
.menu-link:hover { background: rgba(255,255,255,0.05); color: #fff; }
.menu-link.active { background: rgba(59, 130, 246, 0.1); color: var(--accent); border-left-color: var(--accent); }
.menu-link i { width: 25px; text-align: center; margin-right: 10px; }

.admin-main { flex-grow: 1; margin-left: 260px; display: flex; flex-direction: column; }
.admin-topbar {
    height: 60px; background: var(--bg-card); border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: space-between; padding: 0 30px;
    position: sticky; top: 0; z-index: 90;
}
.admin-content { padding: 30px; }

/* Вкладки и Статистика */
.tab-section { display: none; animation: fadeIn 0.3s ease; }
.tab-section.active { display: block; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border-color); padding: 20px; border-radius: 12px; display: flex; align-items: center; gap: 20px; }
.stat-icon { width: 50px; height: 50px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; background: rgba(59, 130, 246, 0.1); color: var(--accent); }

/* Сетка иконок (Admin) */
.icon-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; max-height: 150px; overflow-y: auto; padding: 5px; background: #111; border: 1px solid var(--border-color); border-radius: 6px; margin-bottom: 15px; }
.icon-option { cursor: pointer; display: flex; align-items: center; justify-content: center; height: 40px; border-radius: 4px; color: #555; transition: 0.2s; border: 1px solid transparent; }
.icon-option:hover { background: rgba(255,255,255,0.1); color: #fff; }
.icon-option input { display: none; }
.icon-option:has(input:checked) { background: var(--accent); color: #fff; border-color: var(--accent-hover); box-shadow: 0 0 10px rgba(59, 130, 246, 0.4); }

/* =========================================
   6. БИБЛИОТЕКА - ГЛАВНАЯ (Плитки + Сайдбар)
   ========================================= */

/* Сайдбар */
.library-sidebar {
    width: var(--sidebar-width); height: 100vh; background: var(--bg-card);
    border-right: 1px solid var(--border-color); display: flex; flex-direction: column;
    position: fixed; left: 0; top: 0; z-index: 100;
}
.sidebar-header { padding: 20px; border-bottom: 1px solid var(--border-color); }
.sidebar-footer { padding: 15px 20px; border-top: 1px solid var(--border-color); background: rgba(0,0,0,0.2); }
.sidebar-content { flex-grow: 1; overflow-y: auto; padding: 10px; }

/* Кнопки фильтров (Слева) */
.filter-btn {
    display: flex; align-items: center; width: 100%; padding: 10px 15px;
    background: transparent; border: none; color: var(--text-muted); border-radius: 8px;
    cursor: pointer; transition: 0.2s; text-align: left; margin-bottom: 5px;
}
.filter-btn:hover { background: rgba(255,255,255,0.05); color: #fff; }
.filter-btn.active { background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3); }
.filter-btn i { width: 25px; text-align: center; }

/* Основной контент (Сетка) */
.library-main {
    margin-left: var(--sidebar-width); height: 100vh; padding: 40px;
    overflow-y: auto; display: flex; flex-direction: column;
}

/* Сетка игр (GRID) */
.games-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); 
    gap: 25px; padding-bottom: 50px; width: 100%;
}

.game-card {
    background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px;
    overflow: hidden; transition: transform 0.2s, box-shadow 0.2s; cursor: pointer;
    display: flex; flex-direction: column;
}
.game-card:hover { transform: translateY(-5px); box-shadow: 0 10px 25px rgba(0,0,0,0.5); border-color: var(--accent); }

.card-img-wrap { width: 100%; height: 160px; background: #000; position: relative; overflow: hidden; }
.card-img { width: 100%; height: 100%; object-fit: cover; transition: 0.3s; }
.game-card:hover .card-img { transform: scale(1.05); }

.card-body { padding: 15px; display: flex; flex-direction: column; flex-grow: 1; }
.card-title { font-weight: 700; font-size: 1rem; color: #fff; margin-bottom: 5px; }
.card-cat { font-size: 0.75rem; text-transform: uppercase; color: var(--text-muted); font-weight: 600; margin-bottom: 10px; }
.card-desc { font-size: 0.85rem; color: #888; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* =========================================
   7. МОДАЛЬНОЕ ОКНО ПРОСМОТРА ИГРЫ
   ========================================= */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); backdrop-filter: blur(8px); z-index: 2000;
    display: none; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.3s ease;
}
.modal-overlay.open { display: flex; opacity: 1; }

.modal-content {
    background: #1b1d21; border: 1px solid rgba(255,255,255,0.1); width: 90%; max-width: 800px;
    border-radius: 20px; overflow: hidden; box-shadow: 0 50px 100px rgba(0,0,0,0.7);
    transform: scale(0.9); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex; flex-direction: column;
}
.modal-overlay.open .modal-content { transform: scale(1); }

.modal-header { height: 300px; position: relative; background: #000; }
.modal-img { width: 100%; height: 100%; object-fit: cover; mask-image: linear-gradient(to bottom, black 50%, transparent 100%); -webkit-mask-image: linear-gradient(to bottom, black 50%, transparent 100%); }
.modal-close { position: absolute; top: 20px; right: 20px; background: rgba(0,0,0,0.5); border: none; color: #fff; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; transition: 0.2s; z-index: 10; font-size: 1.2rem; }
.modal-close:hover { background: #ef4444; }

.modal-body { padding: 30px; margin-top: -60px; position: relative; z-index: 5; }
.modal-title { font-size: 2.5rem; font-weight: 900; line-height: 1.1; margin-bottom: 10px; text-shadow: 0 5px 15px rgba(0,0,0,0.8); }
.modal-meta { display: flex; gap: 15px; margin-bottom: 20px; }
.meta-tag { background: rgba(255,255,255,0.1); padding: 5px 12px; border-radius: 20px; font-size: 0.8rem; color: #ccc; border: 1px solid rgba(255,255,255,0.1); }

/* Анимация появления */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }/* Бейдж типа ассета (в углу картинки) */
.asset-type-badge {
    position: absolute;
    top: 10px; right: 10px;
    width: 32px; height: 32px;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; z-index: 2;
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

/* Цвета для разных типов */
.type-code { color: #f472b6; }   /* Розовый для кода */
.type-audio { color: #60a5fa; }  /* Синий для звука */
.type-image { color: #fbbf24; }  /* Желтый для картинок */
.type-project { color: #34d399; } /* Зеленый для проектов */

/* Статистика на карточке */
.card-stats {
    font-size: 0.75rem;
    opacity: 0.7;
}