/* ================== АВТОРИЗАЦИЯ — МОДАЛЬНОЕ ОКНО ================== */
.modal-overlay-auth {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse 80% 60% at 50% 30%, rgba(212, 175, 55, 0.18), transparent 60%),
        radial-gradient(ellipse 60% 40% at 80% 80%, rgba(180, 130, 70, 0.14), transparent 60%),
        rgba(26, 18, 12, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0s linear 0.35s;
    transform: translateZ(0);
}

.modal-overlay-auth.active {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.35s ease, visibility 0s linear 0s;
}

.modal-container-auth {
    position: relative;
    width: 90%;
    max-width: 460px;
    max-height: 92vh;
    background:
        radial-gradient(circle at 50% 0%, rgba(212, 175, 55, 0.18), transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(180, 130, 70, 0.16), transparent 60%),
        linear-gradient(180deg, rgba(46, 32, 23, 0.98), rgba(26, 18, 12, 0.99));
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    border: 1px solid var(--line-2);
    border-radius: var(--r-xl);
    box-shadow:
        0 32px 70px rgba(0, 0, 0, 0.7),
        inset 0 1px 0 rgba(244, 228, 188, 0.10),
        0 0 60px rgba(212, 175, 55, 0.20);
    overflow: hidden;
    transform: translate3d(0, 24px, 0);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
    will-change: transform, opacity;
}

.modal-overlay-auth.active .modal-container-auth {
    transform: translate3d(0, 0, 0);
    opacity: 1;
}

/* Декоративный звёздный градиентный бордер сверху */
.modal-container-auth::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent) 30%, var(--accent-3) 50%, var(--accent) 70%, transparent);
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.65);
    z-index: 1;
    clip-path: none;
}

.modal-header-auth {
    position: relative;
    z-index: 2;
    padding: 26px 28px 16px;
    border-bottom: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    align-items: center;
    background: transparent;
}

.modal-logo-auth {
    width: 72px;
    height: auto;
    margin-bottom: 14px;
    filter:
        drop-shadow(0 0 18px rgba(212, 175, 55, 0.55))
        drop-shadow(0 0 30px rgba(244, 228, 188, 0.25));
}

.modal-close-auth {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.25s ease;
    line-height: 1;
}

.modal-close-auth:hover {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
    border-color: var(--line-strong);
    color: #fff;
    transform: rotate(90deg);
    box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.22);
}

/* ================== ТАБЫ ================== */
.auth-tabs {
    display: flex;
    gap: 4px;
    width: 100%;
    padding: 4px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
}

.auth-tab {
    flex: 1;
    padding: 9px 14px;
    background: transparent;
    border: none;
    border-radius: var(--r-pill);
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.auth-tab::before {
    display: none;
}

.auth-tab:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

.auth-tab.active {
    background: linear-gradient(180deg, rgba(244, 228, 188, 0.12), rgba(244, 228, 188, 0.04));
    color: var(--accent-3);
    box-shadow:
        inset 0 1px 0 rgba(244, 228, 188, 0.14),
        0 0 0 1px rgba(212, 175, 55, 0.45),
        0 0 14px rgba(212, 175, 55, 0.32);
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.4);
}

/* ================== КОНТЕНТ ================== */
.modal-content-auth {
    position: relative;
    z-index: 2;
    padding: 16px 28px 28px;
    max-height: calc(92vh - 200px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.modal-content-auth::-webkit-scrollbar {
    width: 6px;
}

.modal-content-auth::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 3px;
}

.modal-content-auth::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--accent), #8b6f47);
    border-radius: 3px;
}

.modal-content-auth::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #f4d978, #b88848);
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.form-group {
    margin-bottom: 14px;
}

.form-group:last-of-type {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    margin-bottom: 7px;
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
}

.password-input-wrapper {
    position: relative;
    width: 100%;
}

.password-input-wrapper .form-input {
    padding-right: 42px;
}

.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
    z-index: 10;
}

.password-toggle:hover {
    color: #fff;
}

.password-toggle.active {
    color: var(--accent);
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: #fff;
    font-family: var(--font-sans);
    font-size: 14px;
    letter-spacing: 0;
    transition: all 0.25s ease;
    box-sizing: border-box;
}

.form-input:focus {
    outline: none;
    border-color: rgba(212, 175, 55, 0.55);
    background: rgba(26, 18, 12, 0.7);
    box-shadow:
        0 0 0 4px rgba(212, 175, 55, 0.22),
        inset 0 1px 0 rgba(244, 228, 188, 0.06);
    color: var(--accent-3);
}

.form-input::placeholder {
    color: var(--text-faint);
    font-style: normal;
}

/* ================== ЧЕКБОКС С СОГЛАШЕНИЕМ ================== */
.form-checkbox-group {
    margin-bottom: 22px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.form-checkbox {
    margin-top: 2px;
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
    accent-color: var(--accent);
}

.form-checkbox-label,
.form-checkbox-text {
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 13px;
    line-height: 1.55;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.form-checkbox-label a,
.form-checkbox-label .policy-link,
.form-checkbox-label .terms-link,
.form-checkbox-text a,
.policy-link-inline,
.terms-link-inline {
    color: var(--accent-3);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.2s ease, text-shadow 0.2s ease;
    pointer-events: auto;
    cursor: pointer;
}

.form-checkbox-label a:hover,
.form-checkbox-label .policy-link:hover,
.form-checkbox-label .terms-link:hover,
.form-checkbox-text a:hover,
.policy-link-inline:hover,
.terms-link-inline:hover {
    color: var(--accent);
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

/* ================== КНОПКА ОТПРАВКИ ================== */
.form-submit {
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
    display: block;
    padding: 13px 24px;
    background: linear-gradient(180deg, #f5e8d4, #d4c4a8);
    border: 1px solid transparent;
    border-radius: var(--r-pill);
    color: var(--ink);
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: all 0.25s ease;
    text-transform: none;
    position: relative;
    overflow: hidden;
    box-shadow:
        0 8px 22px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(212, 175, 55, 0.45),
        inset 0 1px 0 rgba(255, 248, 230, 0.55);
    isolation: isolate;
    text-shadow: none;
}

.form-submit::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: conic-gradient(from var(--sb-angle, 0deg),
        rgba(244, 228, 188, 0.95),
        rgba(212, 175, 55, 0.95),
        rgba(180, 130, 70, 0.95),
        rgba(244, 228, 188, 0.95));
    -webkit-mask:
        linear-gradient(#000 0 0) content-box,
        linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: starRotate 6s linear infinite;
    pointer-events: none;
    z-index: 0;
    width: auto;
    height: auto;
    background-color: transparent;
    opacity: 1;
    transform: none;
    transition: none;
}

.form-submit:hover {
    transform: translateY(-2px);
    background: linear-gradient(180deg, #fff8e6, #e8d5a8);
    color: #1a120c;
    box-shadow:
        0 14px 30px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(212, 175, 55, 0.65),
        0 0 30px rgba(212, 175, 55, 0.45),
        inset 0 1px 0 rgba(255, 248, 230, 0.7);
}

.form-submit:hover::before {
    width: auto;
    height: auto;
}

/* ================== ТРЕБОВАНИЯ К ПАРОЛЮ ================== */
.password-requirements {
    margin-top: 10px;
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
}

.requirement {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-family: var(--font-sans);
    font-size: 12px;
    color: var(--text-faint);
    transition: color 0.3s ease;
}

.requirement:last-child {
    margin-bottom: 0;
}

.requirement i {
    font-size: 13px;
    color: var(--text-faint);
    transition: color 0.3s ease;
}

.requirement.valid {
    color: var(--text);
}

.requirement.valid i {
    color: #4ade80;
    text-shadow: 0 0 8px rgba(74, 222, 128, 0.55);
}

/* ================== ПОДСКАЗКА ================== */
.form-hint {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-faint);
    font-family: var(--font-sans);
    font-style: normal;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-hint i {
    font-size: 12px;
    color: var(--accent);
}

/* ================== ОШИБКА ================== */
.form-error {
    margin-top: 6px;
    font-size: 12px;
    color: #ff8b9c;
    font-family: var(--font-sans);
    text-shadow: 0 0 10px rgba(255, 92, 174, 0.30);
    display: none;
}

.form-error.visible {
    display: block;
}

/* ================== ССЫЛКА "ЗАБЫЛИ ПАРОЛЬ?" ================== */
.forgot-password-link {
    margin-top: 8px;
    text-align: right;
}

.forgot-password-link a {
    color: var(--text-muted);
    font-size: 13px;
    font-family: var(--font-sans);
    font-style: normal;
    text-decoration: none;
    transition: color 0.2s ease;
}

.forgot-password-link a:hover {
    color: var(--accent);
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.45);
}

/* ================== МОДАЛЬНОЕ ОКНО ВОССТАНОВЛЕНИЯ ПАРОЛЯ ================== */
#forgotPasswordModal .modal-container-auth {
    max-width: 420px;
}

#forgotPasswordModal .modal-header-auth {
    padding: 22px 28px 14px;
}

#forgotPasswordModal .modal-logo-auth {
    width: 60px;
    margin-bottom: 10px;
}

.modal-title-forgot {
    color: #fff;
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    margin: 0;
    width: 100%;
    letter-spacing: -0.01em;
    text-transform: none;
    text-shadow: none;
}

#forgotPasswordModal .modal-content-auth {
    padding: 18px 28px 26px;
}

#forgotPasswordModal .auth-form {
    display: block;
}

#forgotPasswordModal .form-group {
    margin-bottom: 18px;
}

.forgot-password-description {
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 13px;
    line-height: 1.6;
    font-style: normal;
    margin-bottom: 18px;
    padding: 14px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.forgot-password-description i {
    font-size: 14px;
    color: var(--accent);
    flex-shrink: 0;
    margin-top: 2px;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.45);
}

.back-to-login {
    margin-top: 14px;
    text-align: center;
}

.back-to-login a {
    color: var(--text-muted);
    font-size: 13px;
    font-family: var(--font-sans);
    font-style: normal;
    text-decoration: none;
    transition: color 0.2s ease, transform 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.back-to-login a i {
    font-size: 12px;
}

.back-to-login a:hover {
    color: var(--accent-3);
    transform: translateX(-3px);
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.45);
}

.modal-close-forgot {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
}

/* ================== CAPTCHA ================== */
.captcha-container {
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.cf-turnstile {
    transform: scale(0.95);
    transform-origin: center;
}

#captchaRegisterError,
#captchaLoginError,
#captchaForgotError {
    display: none;
    text-align: center;
}

#captchaRegisterError.visible,
#captchaLoginError.visible,
#captchaForgotError.visible {
    display: block;
}

@media (max-width: 640px) {
    .modal-container-auth {
        width: 95%;
    }

    .cf-turnstile {
        transform: scale(0.85);
    }
}

/* Финальные оверрайды */
.modal-overlay-auth {
    z-index: 20000 !important;
}

.modal-overlay-auth .modal-container-auth {
    width: min(92vw, 460px) !important;
    max-width: 460px !important;
    max-height: 94vh !important;
}

#forgotPasswordModal .modal-container-auth {
    width: min(92vw, 420px) !important;
    max-width: 420px !important;
}

.modal-overlay-auth .modal-content-auth {
    max-height: calc(94vh - 200px) !important;
    padding: 16px 28px 22px !important;
    overflow-y: auto !important;
    border-bottom: 1px solid var(--line);
}

#registerForm.active,
#loginForm.active {
    display: block !important;
    padding-bottom: 4px;
}

#registerForm .form-submit,
#loginForm .form-submit {
    position: relative !important;
    margin: 14px auto 0 !important;
}

#registerForm .cf-turnstile {
    margin-bottom: 8px;
}
