/* =========================================================
   1. СБРОС И ОСНОВНЫЕ СТИЛИ СТРАНИЦЫ
   ========================================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

body {
    background-color: #0f172a;
    color: #fff;
    font-family: system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 20px;
    width: 100%;
    box-sizing: border-box;
}

.full-width {
    grid-column: 1 / -1;
    margin-top: 20px;
}

/* =========================================================
   2. АВТОРИЗАЦИЯ И ФОРМЫ
   ========================================================= */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
    padding: 20px;
}

.auth-card {
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid #334155;
    padding: 30px;
    border-radius: 12px;
    width: 100%;
    max-width: 360px;
}

.auth-card h2 {
    margin-bottom: 20px;
    font-size: 22px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    color: #94a3b8;
}

.form-group input, 
.form-group select, 
.form-group textarea {
    width: 100%;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #334155;
    background: #0f172a;
    color: #fff;
}

.form-group input:focus, 
.form-group select:focus, 
.form-group textarea:focus {
    outline: none;
    border-color: #3b82f6;
}

.btn {
    width: 100%;
    padding: 10px;
    border-radius: 6px;
    border: none;
    background: #3b82f6;
    color: #fff;
    font-weight: bold;
    cursor: pointer;
    font-size: 14px;
}

.btn:hover {
    background: #2563eb;
}

.btn-danger {
    background: #ef4444;
}

.btn-danger:hover {
    background: #dc2626;
}

.toggle-btn {
    margin-top: 15px;
    background: none;
    border: none;
    color: #94a3b8;
    text-decoration: underline;
    font-size: 13px;
    cursor: pointer;
    width: 100%;
}

#message {
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 6px;
    display: none;
    font-size: 14px;
}

.error {
    background: #ef444422;
    border: 1px solid #ef4444;
    color: #f87171;
}

.success {
    background: #10b98122;
    border: 1px solid #10b981;
    color: #34d399;
}

/* =========================================================
   3. ШАПКА САЙТА И НАВИГАЦИЯ (HEADER)
   ========================================================= */
header {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 10px 16px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.8);
    position: fixed; /* fixed гарантированно работает при overflow-x: hidden */
    top: 0;
    left: 0;
    z-index: 1000;
    width: 100%;
    box-sizing: border-box;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

/* Класс скрытия шапки */
header.header-hidden {
    transform: translateY(-100%);
}

/* Отступ сверху для body, чтобы фиксированная шапка не перекрывала контент */
body {
    padding-top: 65px;
}

@media (max-width: 768px) {
    body {
        padding-top: 105px; /* На мобильных шапка выше из-за переноса поиска */
    }
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 15px;
}

.logo {
    font-size: 18px;
    font-weight: 800;
    color: #ffffff;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.logo-icon {
    width: 22px;
    height: 22px;
    color: #3b82f6;
    fill: #3b82f6;
}

.logo .highlight {
    color: #3b82f6;
}

.user-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #0f172a;
    border: 1px solid #334155;
    padding: 6px 12px;
    border-radius: 20px;
    color: #f1f5f9;
    font-size: 13px;
    text-decoration: none;
    transition: border-color 0.2s;
    max-width: 100%;
    overflow: hidden;
}

.user-badge:hover {
    border-color: #3b82f6;
}

.user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-role-tag {
    background: rgba(59, 130, 246, 0.2);
    color: #38bdf8;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
}

.btn-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #334155;
    background: #1e293b;
    color: #ffffff;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-header:hover {
    background: #334155;
    color: #fff;
    border-color: #475569;
}

.btn-header.btn-primary {
    background-color: #1d4ed8 !important; /* Более темный синий цвет (коэффициент > 6:1) */
    border-color: #1d4ed8 !important;
    color: #ffffff !important;
}

.btn-header.btn-primary:hover {
    background-color: #1e40af !important;
    border-color: #1e40af !important;
}

.btn-header.btn-primary span,
.btn-header.btn-primary svg {
    color: #ffffff !important;
    stroke: #ffffff !important;
}

.btn-header.btn-accent {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.4);
    color: #38bdf8;
}

.btn-header.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    color: #f87171;
}

.btn-header.btn-danger:hover {
    background: #ef4444;
    color: #fff;
}

.nav-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Поисковая строка в шапке */
.search-box {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    max-width: 480px;
    margin: 0 15px;
}

.search-input {
    width: 100%;
    height: 38px;
    padding: 0 70px 0 14px;
    border-radius: 8px;
    border: 1px solid #334155;
    background: #0f172a;
    color: #fff;
    font-size: 14px;
    transition: all 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: #38bdf8;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.search-clear-btn {
    position: absolute;
    right: 38px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-clear-btn:hover {
    color: #f87171;
}

.search-btn-icon {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: #3b82f6;
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.search-btn-icon:hover {
    background: #2563eb;
}

a:focus-visible, 
button:focus-visible, 
select:focus-visible, 
input:focus-visible {
    outline: 3px solid #3b82f6 !important;
    outline-offset: 3px;
    border-radius: 6px;
}

/* =========================================================
   4. НИЖНЕЕ МОБИЛЬНОЕ МЕНЮ
   ========================================================= */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid #334155;
    z-index: 9999;
    justify-content: space-around;
    align-items: center;
    padding: 0 5px;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    text-decoration: none;
    font-size: 11px;
    gap: 3px;
    flex: 1;
    height: 100%;
    transition: color 0.2s ease;
}

.bottom-nav-icon {
    width: 22px;
    height: 22px;
}

.bottom-nav-item.active,
.bottom-nav-item:hover {
    color: #3b82f6;
}

/* =========================================================
   5. АДАПТИВНОСТЬ (MEDIA QUERIES)
   ========================================================= */

@media (min-width: 1600px) {
    .container {
        max-width: 1500px;
    }
}

@media (max-width: 768px) {
    body {
        padding-bottom: 70px;
    }

    .header-top {
        flex-wrap: wrap;
    }

    header {
        padding: 8px 12px;
        gap: 8px;
    }

    .search-box {
        order: 3;
        width: 100%;
        max-width: 100%;
        margin: 8px 0 0 0;
    }

    .user-nav {
        gap: 6px;
    }

    .user-badge {
        padding: 4px 8px;
        font-size: 11px;
    }

    .user-role-tag {
        display: none;
    }

    .desktop-only-link,
    .desktop-only-text {
        display: none !important;
    }

    .btn-header {
        padding: 6px 8px;
    }

    .btn-header span {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .user-nav .btn-danger {
        display: inline-block !important;
        padding: 5px 10px;
        font-size: 12px;
    }

    .bottom-nav {
        display: flex;
    }

    .container {
        padding: 0 12px;
        margin: 15px auto;
    }
}
@media (max-width: 480px) {
    header {
        padding: 8px 10px !important;
        overflow: visible;
    }

    .header-top {
        display: flex;
        flex-wrap: wrap; /* Разрешаем перенос поиска на вторую строчку */
        align-items: center;
        justify-content: space-between;
        gap: 6px;
        width: 100%;
    }

    .logo {
        font-size: 15px;
    }

    .user-nav {
        gap: 4px;
        max-width: 60%;
        justify-content: flex-end;
    }

    .user-badge {
        padding: 4px 6px;
        font-size: 11px;
        max-width: 110px;
    }

    .user-name {
        max-width: 60px;
        display: inline-block;
    }

    /* Поиск аккуратно встает на 2-ю строчку во всю ширину */
    .search-box {
        order: 3;
        flex: 0 0 100%;
        width: 100%;
        max-width: 100%;
        margin: 6px 0 0 0 !important;
    }
}
/* =========================================================
   КНОПКИ БЫСТРОЙ ПРОКРУТКИ (ВВЕРХ / ВНИЗ)
   ========================================================= */
.scroll-buttons {
    position: fixed;
    right: 16px;
    bottom: 30px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
}

/* Показ блока при скролле */
.scroll-buttons.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(30, 41, 59, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(51, 65, 85, 0.8);
    color: #38bdf8;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    transition: all 0.2s ease;
    padding: 0;
}

.scroll-btn:hover {
    background: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
    transform: scale(1.1);
}

.scroll-btn:active {
    transform: scale(0.95);
}

.scroll-btn svg {
    width: 20px;
    height: 20px;
}

/* Отступ для мобильных устройств, чтобы кнопки были НАД нижним меню */
@media (max-width: 768px) {
    .scroll-buttons {
        right: 12px;
        bottom: 75px; /* Поднято выше нижнего меню (60px) */
        gap: 6px;
    }

    .scroll-btn {
        width: 36px;
        height: 36px;
    }

    .scroll-btn svg {
        width: 18px;
        height: 18px;
    }
}

/* =========================================================
   ИСПРАВЛЕНИЯ ДЛЯ ФОРМ И ВЫПАДАЮЩИХ СПИСКОВ (DARK THEME)
   ========================================================= */

/* Тёмная стилизация выпадающего списка */
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid #334155;
    background-color: #0f172a !important;
    color: #ffffff !important;
    font-size: 14px;
    cursor: pointer;
    outline: none;
    appearance: auto; /* Сохраняет стрелку ОС */
}

/* Стилизация выпадающих пунктов (option) */
.form-group select option {
    background-color: #1e293b !important;
    color: #ffffff !important;
    padding: 10px;
}

/* Выравнивание чекбокса и текста «Я согласен с правилами» */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 15px 0;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #cbd5e1;
    cursor: pointer;
    user-select: none;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-width: 18px;
    accent-color: #3b82f6; /* Синяя галочка */
    cursor: pointer;
}

/* Ссылка на правила в чекбоксе */
.checkbox-group a {
    color: #60a5fa;
    text-decoration: underline;
}

.checkbox-group a:hover {
    color: #93c5fd;
}
/* Сброс стандартных стилей браузера для кнопки поиска в нижнем меню */
button#bottomNavSearch.bottom-nav-item {
    background: transparent !important;
    border: none !important;
    outline: none !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
}

/* Цвет иконки и текста при наведении или нажатии */
button#bottomNavSearch.bottom-nav-item:hover,
button#bottomNavSearch.bottom-nav-item:focus,
button#bottomNavSearch.bottom-nav-item:active {
    background: transparent !important;
    color: #3b82f6 !important;
}
/* =========================================================
   БАННЕР ТЕЛЕГРАМ-КАНАЛА
   ========================================================= */
.tg-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.95));
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 12px;
    padding: 14px 18px;
    margin: 20px 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.tg-banner-content {
    display: flex;
    align-items: center;
    gap: 14px;
}

.tg-banner-icon {
    width: 44px;
    height: 44px;
    min-width: 44px;
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tg-banner-text .tg-banner-title {
    color: #f8fafc;
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 2px;
}

/* Кнопка с идеальным контрастом по WCAG AA (5.7:1) */
.tg-banner-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #0369a1;
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    padding: 9px 16px;
    border-radius: 8px;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.2s ease, transform 0.1s ease;
}

.tg-banner-btn:hover {
    background: #0284c7;
    transform: translateY(-1px);
}

/* Адаптив для мобильных устройств */
@media (max-width: 600px) {
    .tg-banner {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        padding: 14px;
    }

    .tg-banner-content {
        flex-direction: column;
        gap: 8px;
    }

    .tg-banner-btn {
        width: 100%;
        margin-top: 4px;
    }
}


