/* ============================================
   GLOBAL STYLES
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: #ffffff;
    color: #1a1a1a;
    min-height: 100vh;
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* ============================================
   ЕДИНЫЙ ХЕДЕР (объединённый стиль)
   ============================================ */

.header {
    background: linear-gradient(135deg, #cc0000 0%, #e60000 100%);
    padding: 0.8rem 2rem;
    border-radius: 20px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px rgba(204, 0, 0, 0.3);
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    min-height: 80px;
}

/* Логотипы */
.header .logo-left,
.header .logo-right {
    height: 50px;
    width: auto;
    flex-shrink: 0;
}

/* Центральная часть с заголовком */
.header .header-center {
    flex: 1;
    text-align: center;
}

.header .header-center h1 {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #ffffff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.header .header-center h1 span {
    font-weight: 300;
    opacity: 0.9;
}

.header .header-center h1 .icon {
    font-size: 1.8rem;
}

.header .header-subtitle {
    display: block;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.85);
    margin-top: 0.1rem;
    font-weight: 400;
    letter-spacing: 0.02em;
}

/* Правая часть с кнопками */
.header .header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.header .btn-back {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 6px 18px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    color: white;
    text-decoration: none;
    transition: 0.2s;
    display: inline-block;
    white-space: nowrap;
}

.header .btn-back:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
}

.header .btn-logout {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 6px 18px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    transition: 0.2s;
    font-family: inherit;
}

.header .btn-logout:hover {
    background: rgba(255, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
}

/* Адаптив для хедера */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        padding: 0.8rem 1rem;
        gap: 0.6rem;
        justify-content: center;
        min-height: auto;
    }
    .header .logo-left,
    .header .logo-right {
        height: 45px;
    }
    .header .header-center h1 {
        font-size: 1.2rem;
    }
    .header .header-subtitle {
        font-size: 0.75rem;
    }
    .header .header-right {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 0.6rem 0.8rem;
        border-radius: 16px;
    }
    .header .logo-left,
    .header .logo-right {
        height: 35px;
    }
    .header .header-center h1 {
        font-size: 1rem;
    }
    .header .header-subtitle {
        font-size: 0.7rem;
    }
    .header .btn-back,
    .header .btn-logout {
        font-size: 11px;
        padding: 4px 12px;
    }
}

/* ============================================
   ФОРМА
   ============================================ */

.form-container {
    background: #f8f9fa;
    border-radius: 20px;
    padding: 2.5rem 3rem;
    border: 1px solid #eaeaea;
    margin-bottom: 2rem;
    width: 100%;
}

.form-container .form-subtitle {
    color: #888;
    font-size: 0.95rem;
    margin: 0 0 1.5rem 0;
}

.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #444;
    margin-bottom: 0.3rem;
}

.form-group label .required {
    color: #cc0000;
    margin-left: 2px;
}

.form-group .hint {
    font-size: 0.8rem;
    color: #999;
    margin-top: 0.3rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 1px solid #d5d5d5;
    border-radius: 8px;
    font-size: 1rem;
    transition: 0.2s;
    background: #fff;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #cc0000;
    outline: none;
    box-shadow: 0 0 0 3px rgba(204, 0, 0, 0.1);
}

.form-group input:disabled,
.form-group select:disabled {
    background: #f5f5f5;
    color: #888;
    cursor: not-allowed;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.2rem;
}

.form-actions {
    margin-top: 1.8rem;
    padding-top: 1.5rem;
    border-top: 2px solid #eaeaea;
}

.form-actions .btn-submit {
    width: 100%;
    padding: 1rem;
    border-radius: 60px;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    background: #cc0000;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    box-shadow: 0 4px 20px rgba(204, 0, 0, 0.3);
}

.form-actions .btn-submit:hover:not(:disabled) {
    background: #b30000;
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(204, 0, 0, 0.4);
}

.form-actions .btn-submit:active:not(:disabled) {
    transform: translateY(0);
}

.form-actions .btn-submit:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-group label {
    font-weight: 400;
    color: #555;
    margin: 0;
    cursor: pointer;
}

.race-select-wrapper {
    position: relative;
}

.race-select-wrapper select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

.race-select-wrapper select:disabled {
    background-image: none;
}

/* ============================================
   КНОПКИ (общие стили)
   ============================================ */

.btn {
    display: inline-block;
    padding: 10px 24px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-family: inherit;
}

.btn-primary {
    background: #cc0000;
    color: white;
}

.btn-primary:hover {
    background: #b30000;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(204, 0, 0, 0.3);
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.btn-secondary:hover {
    background: #cbd5e0;
}

/* ============================================
   АВТОРИЗАЦИЯ НА СТРАНИЦЕ ЗАЯВКИ
   ============================================ */

.auth-banner {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    display: none;
}

.auth-banner.visible {
    display: block;
}

.auth-banner .banner-text {
    color: #856404;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.auth-banner .btn-login {
    background: #cc0000;
    color: #fff;
    border: none;
    border-radius: 30px;
    padding: 4px 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: 0.2s;
    text-decoration: none;
    display: inline-block;
}

.auth-banner .btn-login:hover {
    background: #b30000;
    transform: scale(1.02);
}

.auto-fill-hint {
    background: #f0f7f0;
    border: 1px solid #d0e0d0;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    display: none;
}

.auto-fill-hint.visible {
    display: block;
}

.auto-fill-hint .hint-text {
    color: #2a6b2a;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-auto-fill {
    background: none;
    border: none;
    color: #2a6b2a;
    text-decoration: underline;
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    margin-left: 8px;
    font-weight: 500;
}

.btn-auto-fill:hover {
    color: #1a4a1a;
}

/* ============================================
   МОДАЛЬНОЕ ОКНО
   ============================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    background: #fff;
    border-radius: 16px;
    max-width: 780px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 28px;
    border-bottom: 2px solid #f0f0f0;
    background: #fafafa;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: #cc0000;
    margin: 0;
}

.modal-header .close-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
    padding: 0 4px;
}

.modal-header .close-btn:hover {
    color: #1a1a1a;
    transform: rotate(90deg);
}

.modal-body {
    padding: 28px 30px;
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 28px;
    border-top: 2px solid #f0f0f0;
    background: #fafafa;
}

/* КНОПКИ МОДАЛИ */
.btn-cancel-modal {
    background: none;
    border: 1px solid #d5d5d5;
    padding: 10px 28px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #555;
    transition: 0.2s;
}

.btn-cancel-modal:hover {
    background: #f0f0f0;
}

.btn-edit-modal {
    background: #1a1a1a;
    color: #fff;
    border: none;
    padding: 10px 28px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: 0.2s;
}

.btn-edit-modal:hover {
    background: #333;
}

.btn-save-modal {
    background: #2a6b2a;
    color: #fff;
    border: none;
    padding: 10px 28px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: 0.2s;
}

.btn-save-modal:hover {
    background: #1a4a1a;
}

.btn-save-modal:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* АДАПТИВНОСТЬ МОДАЛЬНЫХ ОКОН */
@media (max-width: 768px) {
    .modal-box {
        max-width: 100%;
        border-radius: 12px;
    }
    
    .modal-header {
        padding: 14px 18px;
    }
    
    .modal-header h2 {
        font-size: 17px;
    }
    
    .modal-body {
        padding: 18px 16px;
        max-height: calc(90vh - 120px);
    }
    
    .modal-footer {
        padding: 14px 16px;
        flex-wrap: wrap;
    }
    
    .modal-footer .btn-cancel-modal,
    .modal-footer .btn-edit-modal,
    .modal-footer .btn-save-modal {
        flex: 1;
        text-align: center;
        padding: 8px 16px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .modal-box {
        border-radius: 10px;
    }
    
    .modal-header {
        padding: 12px 14px;
    }
    
    .modal-header h2 {
        font-size: 15px;
    }
    
    .modal-body {
        padding: 14px 12px;
        max-height: calc(90vh - 100px);
    }
    
    .modal-footer {
        flex-direction: column;
        padding: 10px 14px;
    }
    
    .modal-footer .btn-cancel-modal,
    .modal-footer .btn-edit-modal,
    .modal-footer .btn-save-modal {
        width: 100%;
        padding: 10px 16px;
    }
}

/* ============================================
   ЕДИНЫЙ ФУТЕР
   ============================================ */

.footer {
    background: #f5f5f5;
    border-top: 2px solid #e0e0e0;
    padding: 0.8rem 2rem;
    border-radius: 20px;
    margin-top: 1rem;
}

.footer .footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* Левая часть с логотипом — как в хедере */
.footer .footer-left {
    flex-shrink: 0;
}

.footer-logo-left {
    height: 50px;
    width: auto;
    display: block;
}

/* Центральная часть */
.footer .footer-center {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    flex: 1;
}

.footer .footer-center p {
    color: #666666;
    font-size: 0.9rem;
    margin: 0;
    white-space: nowrap;
}

.footer .footer-links {
    display: flex;
    gap: 1.5rem;
}

.footer .footer-links a {
    color: #888888;
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.2s ease;
    white-space: nowrap;
}

.footer .footer-links a:hover {
    color: #cc0000;
}

.footer .social-links {
    display: flex;
    gap: 1.2rem;
}

.footer .social-links a {
    color: #888888;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s ease;
    white-space: nowrap;
}

.footer .social-links a:hover {
    color: #cc0000;
}

/* Адаптив футера */
@media (max-width: 992px) {
    .footer .footer-content {
        flex-wrap: wrap;
        justify-content: center;
    }
    .footer .footer-center {
        justify-content: center;
        gap: 0.8rem 1.5rem;
    }
}

@media (max-width: 768px) {
    .footer {
        padding: 0.8rem 1rem;
    }
    .footer .footer-content {
        flex-direction: column;
    }
    .footer .footer-center {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }
    .footer .footer-center p {
        white-space: normal;
    }
    .footer .footer-links {
        flex-direction: column;
        gap: 0.3rem;
    }
    .footer .social-links {
        gap: 0.8rem;
    }
    .footer-logo-left {
        height: 40px;
    }
}

@media (max-width: 480px) {
    .footer {
        padding: 0.6rem 0.8rem;
        border-radius: 16px;
    }
    .footer-logo-left {
        height: 35px;
    }
    .footer .footer-center p {
        font-size: 0.8rem;
    }
    .footer .footer-links a,
    .footer .social-links a {
        font-size: 0.8rem;
    }
}

/* ============================================
   RESPONSIVE (общие адаптивы)
   ============================================ */

@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
    }

    .form-container {
        padding: 1.5rem;
        border-radius: 16px;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
}

@media (max-width: 480px) {
    .form-container {
        padding: 1rem;
        border-radius: 12px;
    }
}

/* ============================================
   БЕЙДЖИ ЛИГ (для таблиц, модалок и др.)
   ============================================ */

/* Базовый класс для бейджа в таблицах */
.league-col {
    font-size: 10px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Специфичные цвета лиг */
.league-gold {
    background: #f0e6b8;
    color: #8a6d3b;
}

.league-main {
    background: #e6f0e6;
    color: #2a6b2a;
}

.league-other {
    background: #f0f0f0;
    color: #888;
}

/* Стили для бейджей в модальном окне (шапка) */
.modal-header .modal-header-right .modal-league .league-badge {
    font-size: 13px;
    font-weight: 600;
    padding: 4px 14px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.modal-header .modal-header-right .modal-league .league-badge.gold {
    background: #f0e6b8;
    color: #8a6d3b;
    border: 1px solid #e6c200;
}

.modal-header .modal-header-right .modal-league .league-badge.main {
    background: #e6f0e6;
    color: #2a6b2a;
}

.modal-header .modal-header-right .modal-league .league-badge.none {
    background: #f0f0f0;
    color: #888;
}

/* Стили для бейджей в таблице заездов участника (внутри модалки) */
.participant-races .league-col {
    font-size: 10px;
    font-weight: 500;
    padding: 2px 10px;
    border-radius: 12px;
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.participant-races .league-gold {
    background: #ffd700;
    color: #8b7300;
    border: 1px solid #e6c200;
}

.participant-races .league-main {
    background: #e6f0e6;
    color: #2a6b2a;
}

.participant-races .league-other {
    background: #f0f0f0;
    color: #888;
}