/* style.css */
/* Версия: 1.0 */
/* Стили админ-панели VK-Пульт */

/* ============================================================
   МОНТАЖНАЯ ЧАСТЬ 01
   Сброс, переменные, базовые стили
   ============================================================ */

/* Переменные */
:root {
    --bg: #f0f2f5;
    --bg-card: #ffffff;
    --bg-sidebar: #2c3e50;
    --bg-sidebar-hover: #34495e;
    --text: #333333;
    --text-light: #777777;
    --text-white: #ffffff;
    --primary: #3498db;
    --primary-hover: #2980b9;
    --success: #27ae60;
    --success-hover: #219a52;
    --warning: #f39c12;
    --warning-hover: #d68910;
    --danger: #e74c3c;
    --danger-hover: #c0392b;
    --border: #e0e0e0;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --radius: 8px;
    --sidebar-width: 220px;
}

/* Сброс */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    display: flex;
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1, h2, h3 {
    font-weight: 600;
}

/* Текстовые утилиты */
.text-muted {
    color: var(--text-light);
}


/* ============================================================
   МОНТАЖНАЯ ЧАСТЬ 02
   Сайдбар (навигация)
   ============================================================ */

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--text-white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
    font-size: 18px;
    margin-bottom: 8px;
}

.season-badge {
    background: var(--primary);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    display: inline-block;
}

.nav-list {
    list-style: none;
    flex: 1;
    padding: 10px 0;
}

.nav-item a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--text-white);
    text-decoration: none;
    transition: background 0.2s;
}

.nav-item a:hover {
    background: var(--bg-sidebar-hover);
    text-decoration: none;
}

.nav-item.active a {
    background: var(--bg-sidebar-hover);
    border-left: 3px solid var(--primary);
}

.nav-icon {
    margin-right: 10px;
    font-size: 18px;
}

.nav-title {
    font-size: 14px;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.logout-link {
    color: var(--text-white);
    opacity: 0.7;
    font-size: 14px;
}

.logout-link:hover {
    opacity: 1;
    text-decoration: none;
}


/* ============================================================
   МОНТАЖНАЯ ЧАСТЬ 03
   Основной контент + заголовок
   ============================================================ */

.content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 30px;
    max-width: 1200px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 10px;
}

.page-header h1 {
    font-size: 24px;
}

.header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}


/* ============================================================
   МОНТАЖНАЯ ЧАСТЬ 04
   Кнопки
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover {
    background: var(--bg);
}

.btn-primary {
    background: var(--primary);
    color: var(--text-white);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-success {
    background: var(--success);
    color: var(--text-white);
    border-color: var(--success);
}

.btn-success:hover {
    background: var(--success-hover);
}

.btn-warning {
    background: var(--warning);
    color: var(--text-white);
    border-color: var(--warning);
}

.btn-warning:hover {
    background: var(--warning-hover);
}

.btn-danger {
    background: var(--danger);
    color: var(--text-white);
    border-color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 13px;
}

.btn-full {
    width: 100%;
    justify-content: center;
}


/* ============================================================
   МОНТАЖНАЯ ЧАСТЬ 05
   Карточки + статистика
   ============================================================ */

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-highlight {
    border-left: 4px solid var(--success);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 10px;
}

.card-header h2 {
    font-size: 16px;
}

.card-actions {
    display: flex;
    gap: 6px;
}

.card-body {
    padding: 20px;
}

.card-collapsed .card-body {
    display: none;
}

.card-toggle {
    cursor: pointer;
}

.toggle-icon {
    font-size: 12px;
    color: var(--text-light);
}

/* Сетка статистики */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 5px;
}

/* Инфо-сетка сезона */
.season-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.info-label {
    font-size: 12px;
    color: var(--text-light);
    text-transform: uppercase;
}

.info-value {
    font-size: 15px;
    font-weight: 500;
}

/* ============================================================
   МОНТАЖНАЯ ЧАСТЬ 06
   Таблицы
   ============================================================ */

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-light);
    font-weight: 600;
    background: var(--bg);
}

.table tbody tr:hover {
    background: #f8f9fa;
}

.table-compact th,
.table-compact td {
    padding: 6px 10px;
    font-size: 13px;
}

.td-time {
    font-size: 12px;
    color: var(--text-light);
    white-space: nowrap;
}

.td-details {
    font-size: 13px;
    color: var(--text-light);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Рейтинг-таблица */
.rating-table .th-place,
.rating-table .td-place {
    width: 50px;
    text-align: center;
}

.rating-table .th-points,
.rating-table .td-points {
    font-weight: 600;
    color: var(--primary);
}

.rating-table .td-points .bonus-note {
    color: var(--success);
    font-weight: 400;
}


/* ============================================================
   МОНТАЖНАЯ ЧАСТЬ 07
   Бейджи
   ============================================================ */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.badge-active {
    background: #d4edda;
    color: #155724;
}

.badge-draft {
    background: #fff3cd;
    color: #856404;
}

.badge-inactive {
    background: #f8d7da;
    color: #721c24;
}

.badge-code {
    background: #d1ecf1;
    color: #0c5460;
}

.badge-game {
    background: #d4edda;
    color: #155724;
}

.badge-system {
    background: #e2e3e5;
    color: #383d41;
}

.badge-achievement {
    background: #fff3cd;
    color: #856404;
}

/* Бейджи действий в логе */
.badge-first_visit     { background: #d1ecf1; color: #0c5460; }
.badge-return_visit    { background: #d4edda; color: #155724; }
.badge-riddle_shown    { background: #e2e3e5; color: #383d41; }
.badge-first_attempt   { background: #fff3cd; color: #856404; }
.badge-riddle_completed { background: #d4edda; color: #155724; }
.badge-riddle_skipped  { background: #f8d7da; color: #721c24; }
.badge-hint_used       { background: #fff3cd; color: #856404; }
.badge-season_bonus    { background: #cce5ff; color: #004085; }
.badge-achievement     { background: #fff3cd; color: #856404; }


/* ============================================================
   МОНТАЖНАЯ ЧАСТЬ 08
   Формы
   ============================================================ */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--text);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="date"],
.form-group input[type="file"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(52,152,219,0.15);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-hint {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
}

/* Варианты ответов (редактор) */
.options-editor {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.option-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.option-num {
    font-weight: 600;
    width: 20px;
    color: var(--text-light);
}

.option-input {
    flex: 1;
}

.option-correct-label {
    cursor: pointer;
    font-size: 18px;
}

.option-correct-cb {
    display: none;
}

.option-correct-cb:checked + .option-correct-label,
.option-correct-label:has(input:checked) {
    color: var(--success);
}


/* ============================================================
   МОНТАЖНАЯ ЧАСТЬ 09
   Модальные окна
   ============================================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-wide {
    max-width: 700px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 16px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-light);
    padding: 0 5px;
}

.modal-close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 15px 20px;
    border-top: 1px solid var(--border);
}


/* ============================================================
   МОНТАЖНАЯ ЧАСТЬ 10
   Уведомления + flash-сообщения
   ============================================================ */

#notifications {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 400px;
}

.notification {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-size: 14px;
    animation: slideIn 0.3s ease;
}

.notification button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    margin-left: 10px;
    opacity: 0.6;
}

.notification button:hover {
    opacity: 1;
}

.notification-info {
    background: #d1ecf1;
    color: #0c5460;
    border-left: 4px solid #17a2b8;
}

.notification-success {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid var(--success);
}

.notification-warning {
    background: #fff3cd;
    color: #856404;
    border-left: 4px solid var(--warning);
}

.notification-error {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid var(--danger);
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

/* Flash-сообщения */
.flash {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-radius: var(--radius);
    margin-bottom: 15px;
    font-size: 14px;
}

.flash-error {
    background: #f8d7da;
    color: #721c24;
}

.flash-success {
    background: #d4edda;
    color: #155724;
}

.flash-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    opacity: 0.6;
}

.flash-close:hover {
    opacity: 1;
}


/* ============================================================
   МОНТАЖНАЯ ЧАСТЬ 11
   Загадки (сетка карточек)
   ============================================================ */

.riddles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 15px;
}

.riddle-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    border-left: 4px solid var(--border);
}

.riddle-active {
    border-left-color: var(--success);
}

.riddle-draft {
    border-left-color: var(--warning);
}

.riddle-image {
    width: 100%;
    height: 180px;
    overflow: hidden;
    background: var(--bg);
}

.riddle-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.riddle-no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    font-size: 14px;
}

.riddle-info {
    padding: 12px 15px;
}

.riddle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.riddle-id {
    font-weight: 600;
    color: var(--text-light);
}

.riddle-season {
    font-size: 13px;
    margin-bottom: 8px;
}

.riddle-options-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}

.option-chip {
    padding: 2px 8px;
    background: var(--bg);
    border-radius: 10px;
    font-size: 12px;
}

.option-correct {
    background: #d4edda;
    color: #155724;
    font-weight: 600;
}

.riddle-stats {
    display: flex;
    gap: 12px;
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.riddle-errors {
    margin-bottom: 8px;
}

.error-chip {
    display: inline-block;
    padding: 2px 6px;
    background: #f8d7da;
    color: #721c24;
    border-radius: 4px;
    font-size: 11px;
    margin: 2px;
}

.riddle-actions {
    display: flex;
    gap: 6px;
}

.image-preview {
    max-width: 100%;
    max-height: 200px;
    border-radius: var(--radius);
    margin-top: 8px;
}


/* ============================================================
   МОНТАЖНАЯ ЧАСТЬ 12
   Фразы + фильтр + табы + логин + пустые состояния
   ============================================================ */

/* Фразы */
.phrases-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.phrase-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px 15px;
}

.phrase-header {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.phrase-text {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 8px;
    padding: 8px;
    background: var(--bg);
    border-radius: 4px;
    white-space: pre-wrap;
    word-break: break-word;
}

.phrase-actions {
    display: flex;
    gap: 6px;
}

/* Фильтр-бар */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding: 10px 15px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    flex-wrap: wrap;
}

.filter-bar label {
    font-size: 13px;
    font-weight: 600;
}

.filter-bar select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
}

.filter-count {
    margin-left: auto;
    font-size: 13px;
    color: var(--text-light);
}

/* Табы */
.tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
}

.tab {
    padding: 10px 20px;
    border: none;
    background: none;
    font-size: 14px;
    cursor: pointer;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Логин */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--bg-sidebar);
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    padding: 40px;
    width: 90%;
    max-width: 400px;
    text-align: center;
}

.login-card h1 {
    font-size: 28px;
    margin-bottom: 5px;
}

.login-subtitle {
    color: var(--text-light);
    margin-bottom: 25px;
}

.login-card .form-group {
    text-align: left;
}

/* Пустые состояния */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

.empty-state p {
    margin-bottom: 15px;
    font-size: 16px;
}


/* ============================================================
   МОНТАЖНАЯ ЧАСТЬ 13
   Адаптивность (мобильные)
   ============================================================ */

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: relative;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .sidebar-header {
        flex: 1;
        padding: 10px 15px;
        border-bottom: none;
    }

    .sidebar-header h2 {
        font-size: 16px;
        margin-bottom: 0;
    }

    .nav-list {
        display: flex;
        width: 100%;
        padding: 0;
        overflow-x: auto;
        border-top: 1px solid rgba(255,255,255,0.1);
    }

    .nav-item a {
        padding: 8px 12px;
        white-space: nowrap;
    }

    .nav-title {
        font-size: 12px;
    }

    .sidebar-footer {
        display: none;
    }

    body {
        flex-direction: column;
    }

    .content {
        margin-left: 0;
        padding: 15px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .riddles-grid {
        grid-template-columns: 1fr;
    }

    .modal {
        width: 95%;
    }

    .season-info-grid {
        grid-template-columns: 1fr;
    }

    #notifications {
        left: 15px;
        right: 15px;
        max-width: none;
    }
}