/**
 * Auth pages (login, register) — общие стили
 * Цвета сохранены (#ff3a6e, #111827). Мобильный UX: без верхнего меню/лого, компактно, анимации в стиле нативных приложений.
 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@500;700&display=swap');

/* ========== Сплэш: только на мобильных (max-width: 768px) ========== */
.auth-splash {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease-out;
}

@media (min-width: 769px) {
    .auth-splash {
        display: none !important;
    }
}

.auth-splash.auth-splash-out {
    opacity: 0;
}

.auth-splash.auth-splash-removed {
    pointer-events: none;
}

.auth-splash-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    opacity: 0;
    animation: authSplashFadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.auth-splash-logo-icon {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
}

.auth-splash-logo-circle {
    transform-origin: center;
    animation: authSplashPulse 1.5s ease-in-out infinite;
}

.auth-splash-logo-letter {
    transform-origin: center;
}

.auth-splash-logo-name {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.02em;
}

@keyframes authSplashFadeIn {
    0% {
        opacity: 0;
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes authSplashPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.9;
    }
}

/* ========== Логотип в шапке (login/register, только десктоп) — как на лендинге ========== */
.auth-page-nav .navbar-brand {
    padding: 0;
}

.auth-logo-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.auth-logo-icon {
    width: 30px;
    height: 30px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.auth-logo-text {
    display: flex;
    align-items: center;
}

.auth-logo-name {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: #000000;
    letter-spacing: -0.02em;
    transition: color 0.3s ease, transform 0.3s ease;
}

.auth-logo-circle {
    transform-origin: center;
    animation: authLogoCircleAppear 1s ease-out;
}

.auth-logo-letter {
    transform-origin: center;
    animation: authLogoLetterAppear 1.2s ease-out 0.5s both;
}

.auth-logo-container:hover .auth-logo-icon {
    transform: scale(1.1);
}

.auth-logo-container:hover .auth-logo-circle {
    transform: scale(1.05);
}

.auth-logo-container:hover .auth-logo-letter {
    opacity: 0.9;
}

.auth-logo-container:hover .auth-logo-name {
    color: #333333;
    transform: translateX(4px);
}

@keyframes authLogoCircleAppear {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    60% {
        transform: scale(1.05);
        opacity: 0.9;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes authLogoLetterAppear {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* --- Базовый layout --- */
.auth-wrapper.auth-v3 {
    background: #ffffff;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.auth-content {
    width: 100%;
    max-width: 340px;
    margin: 0 auto;
    padding: 0 20px;
}

.bg-auth-side {
    display: none;
}

.auth-wrapper .auth-content {
    padding: 0;
    background: transparent;
}

/* --- Контейнер формы: появление с анимацией --- */
.minimal-auth-container {
    background: #ffffff;
    padding: 38px 26px 26px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 320px;
    margin: 15px auto 0 auto;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1), transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Заголовки --- */
.auth-header {
    text-align: center;
    margin-bottom: 26px;
}

.auth-title {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 20px;
    font-weight: 600;
    color: #111827;
    margin: 0 0 6px 0;
    letter-spacing: -0.025em;
}

.auth-subtitle {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 12px;
    font-weight: 400;
    color: #6b7280;
    margin: 0;
    line-height: 1.4;
}

/* --- Форма --- */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 12px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 5px;
    line-height: 1.3;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    font-weight: 400;
    color: #111827;
    background: #ffffff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.form-input:focus {
    border-color: #111827;
    box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.1);
}

.form-input::placeholder {
    color: #9ca3af;
}

.password-field {
    position: relative;
}

.password-input {
    padding-right: 44px !important;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: #6b7280;
    transition: color 0.2s ease, transform 0.15s ease;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

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

.password-toggle:active {
    transform: translateY(-50%) scale(0.92);
}

.password-toggle svg {
    width: 18px;
    height: 18px;
    display: block;
}

/* --- Кнопки (цвета сохранены) --- */
.minimal-auth-container .btn-primary {
    width: 100%;
    padding: 0.8rem 1.6rem;
    background: transparent;
    color: #ff3a6e;
    border: 2px solid #ff3a6e;
    border-radius: 10px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.25s ease, color 0.25s ease, transform 0.2s ease, box-shadow 0.25s ease;
    outline: none;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    box-shadow: 0 3px 16px rgba(255, 58, 110, 0.2);
    min-height: auto;
    -webkit-tap-highlight-color: transparent;
}

.minimal-auth-container .btn-primary:hover {
    background: #ff3a6e;
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(255, 58, 110, 0.4);
}

.minimal-auth-container .btn-primary:active {
    transform: translateY(0) scale(0.98);
    transition-duration: 0.1s;
}

.minimal-auth-container .btn-secondary {
    background: #ffffff;
    border: 2px solid #d1d5db;
    color: #6b7280;
    padding: 0.8rem 1.2rem;
    border-radius: 10px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    outline: none;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    -webkit-tap-highlight-color: transparent;
}

.minimal-auth-container .btn-secondary:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    color: #374151;
    transform: translateY(-1px);
}

.minimal-auth-container .btn-secondary:active {
    transform: scale(0.98);
    transition-duration: 0.1s;
}

/* --- Ошибки, алерты, ссылки --- */
.error-message,
.text-danger {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 10px;
    font-weight: 400;
    color: #ef4444;
    margin-top: 3px;
    line-height: 1.3;
}

.form-input.error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.invalid-email,
.invalid-password {
    display: block;
    margin-top: 3px;
}

.alert {
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.3;
}

.alert-success {
    background: #f0f9ff;
    border: 1px solid #0ea5e9;
    color: #0f172a;
}

.alert-danger {
    background: #fef2f2;
    border: 1px solid #ef4444;
    color: #0f172a;
}

.auth-link {
    text-align: center;
    margin-top: 20px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 12px;
    color: #6b7280;
}

.auth-link a {
    color: #111827;
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s ease;
}

.auth-link a:hover {
    text-decoration: underline;
}

.auth-link a:active {
    opacity: 0.8;
}

.forgot-password-link {
    text-align: right;
    margin-bottom: 20px;
}

.forgot-password-link a {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 11px;
    color: #6b7280;
    text-decoration: none;
    font-weight: 400;
}

.forgot-password-link a:hover {
    color: #111827;
    text-decoration: underline;
}

.privacy-notice {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 12px;
    margin: 16px 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 11px;
    color: #475569;
    line-height: 1.4;
}

.privacy-notice a {
    color: #111827;
    text-decoration: underline;
    font-weight: 500;
}

/* --- Регистрация: шаги, кнопки, индикатор пароля --- */
.step-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 26px;
    gap: 10px;
}

.step-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #e5e7eb;
    transition: background 0.2s ease, transform 0.2s ease;
}

.step-dot.active {
    background: #111827;
    transform: scale(1.2);
}

.step-dot.completed {
    background: #10b981;
}

.step-content {
    display: none;
}

.step-content.active {
    display: block;
    animation: authFadeIn 0.3s ease;
}

@keyframes authFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.button-group .btn-secondary {
    flex: 0 0 auto;
    min-width: 64px;
    width: auto;
}

.button-group .btn-primary {
    flex: 1;
}

.password-strength {
    margin-top: 6px;
}

.strength-bar {
    width: 100%;
    height: 2px;
    background: #f3f4f6;
    border-radius: 1px;
    overflow: hidden;
    margin-bottom: 3px;
}

.strength-fill {
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 1px;
}

.strength-weak .strength-fill { background: #ef4444; width: 25%; }
.strength-fair .strength-fill { background: #f59e0b; width: 50%; }
.strength-good .strength-fill { background: #eab308; width: 75%; }
.strength-strong .strength-fill { background: #10b981; width: 100%; }

.strength-text {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 10px;
    font-weight: 400;
    color: #6b7280;
}

.info-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 12px;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.info-box-icon {
    color: #64748b;
    font-size: 12px;
    margin-top: 1px;
    flex-shrink: 0;
}

.info-box-text {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 11px;
    font-weight: 400;
    color: #475569;
    line-height: 1.3;
    margin: 0;
}

.g-recaptcha {
    transform: scale(0.85);
    transform-origin: 0 0;
    margin-bottom: 8px;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    opacity: 0;
    animation: loadingFadeIn 0.2s ease-out forwards;
}

@keyframes loadingFadeIn {
    to {
        opacity: 1;
    }
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top: 3px solid #ffffff;
    border-radius: 50%;
    animation: authSpin 0.8s linear infinite;
}

@keyframes authSpin {
    to { transform: rotate(360deg); }
}

/* ========== МОБИЛЬНЫЙ UX (нативные приложения) ========== */
@media (max-width: 768px) {
    /* Убираем верхнее меню и лого полностью */
    .auth-page-nav {
        display: none !important;
    }

    /* Футер — компактная одна строка */
    .auth-footer {
        padding: 0.35rem 0.5rem !important;
        margin-top: 0.5rem !important;
        font-size: 10px;
        color: #9ca3af;
    }

    .auth-footer .container-fluid {
        padding: 0 0.5rem !important;
    }

    body.auth-mobile-ready {
        padding: 0 !important;
        margin: 0 !important;
        padding-top: env(safe-area-inset-top) !important;
        padding-bottom: env(safe-area-inset-bottom) !important;
        padding-left: env(safe-area-inset-left) !important;
        padding-right: env(safe-area-inset-right) !important;
    }

    /* Строго по центру экрана: обёртки на всю высоту + flex-центрирование */
    #authMainContent.auth-wrapper.auth-v3 {
        min-height: 100vh;
        min-height: 100dvh;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 12px 16px !important;
        padding-top: max(12px, env(safe-area-inset-top)) !important;
        padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
    }

    #authMainContent > .auth-content {
        min-height: 100vh;
        min-height: 100dvh;
        width: 100%;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0 12px !important;
        max-width: none !important;
        overflow: visible;
    }

    #authMainContent .auth-wrapper.auth-v3:not(#authMainContent) {
        width: 100%;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    #authMainContent .auth-wrapper .auth-content {
        width: 100%;
        padding: 0 12px !important;
        max-width: none !important;
        overflow: visible;
    }

    .auth-wrapper.auth-v3 {
        min-height: 100vh;
        min-height: 100dvh;
        align-items: center !important;
        justify-content: center !important;
    }

    .auth-content {
        padding: 0 12px !important;
        max-width: none !important;
    }

    /* Контейнер формы: 95% ширины экрана для удобного ввода на мобильных */
    .minimal-auth-container {
        padding: 24px 16px 20px !important;
        margin: 0 auto !important;
        border: none !important;
        border-radius: 0;
        max-width: none;
        width: 95%;
        box-sizing: border-box;
        box-shadow: none !important;
        background: transparent !important;
        transform: none;
        animation: authSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
        transition: transform 0.25s ease;
    }

    @keyframes authSlideUp {
        from {
            opacity: 0;
            transform: translateY(12px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* Микроанимации: появление полей по очереди */
    .minimal-auth-container .form-group {
        animation: authFieldIn 0.35s ease backwards;
    }
    .minimal-auth-container .form-group:nth-child(1) { animation-delay: 0.05s; }
    .minimal-auth-container .form-group:nth-child(2) { animation-delay: 0.1s; }
    .minimal-auth-container .form-group:nth-child(3) { animation-delay: 0.15s; }
    .minimal-auth-container .form-group:nth-child(4) { animation-delay: 0.2s; }
    .minimal-auth-container .form-group:nth-child(5) { animation-delay: 0.25s; }
    .minimal-auth-container .form-group:nth-child(6) { animation-delay: 0.3s; }
    .minimal-auth-container .form-group:nth-child(7) { animation-delay: 0.35s; }
    .minimal-auth-container .form-group:nth-child(8) { animation-delay: 0.4s; }
    .minimal-auth-container .auth-header {
        animation: authFieldIn 0.35s ease 0s backwards;
    }
    .minimal-auth-container .forgot-password-link {
        animation: authFieldIn 0.35s ease 0.2s backwards;
    }
    .minimal-auth-container .btn-primary,
    .minimal-auth-container .button-group {
        animation: authFieldIn 0.35s ease 0.3s backwards;
    }
    .minimal-auth-container .auth-link,
    .minimal-auth-container .privacy-notice {
        animation: authFieldIn 0.35s ease 0.4s backwards;
    }
    @keyframes authFieldIn {
        from {
            opacity: 0;
            transform: translateY(6px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .auth-header {
        margin-bottom: 18px;
    }

    .auth-title {
        font-size: 17px !important;
        font-weight: 600;
    }

    .auth-subtitle {
        font-size: 11px !important;
    }

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

    .form-label {
        font-size: 11px;
        transition: color 0.2s ease;
    }

    /* Поля ввода: шире за счёт отступов контейнера, высота уменьшена на ~30% */
    .form-input {
        width: 100% !important;
        padding: 8px 12px !important;
        font-size: 16px; /* предотвращает зум на iOS */
        border-radius: 8px;
        min-height: 31px;
        box-sizing: border-box;
        transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    }

    .form-input:focus {
        transform: scale(1.01);
        box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.12);
    }

    .form-input::placeholder {
        transition: opacity 0.2s ease;
    }

    .form-input:focus::placeholder {
        opacity: 0.6;
    }

    .password-input {
        padding-right: 44px !important;
    }

    .minimal-auth-container .btn-primary,
    .minimal-auth-container .btn-secondary {
        padding: 8px 1rem !important;
        font-size: 0.95rem !important;
        border-radius: 8px;
        min-height: 40px;
        border-width: 1.5px !important;
        transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    }

    .minimal-auth-container .btn-primary:active,
    .minimal-auth-container .btn-secondary:active {
        transform: scale(0.96);
    }

    .forgot-password-link a,
    .auth-link a {
        transition: opacity 0.2s ease, color 0.2s ease;
    }

    .forgot-password-link a:active,
    .auth-link a:active {
        opacity: 0.7;
    }

    .forgot-password-link {
        margin-bottom: 14px;
    }

    .auth-link {
        margin-top: 16px;
        font-size: 11px;
    }

    .privacy-notice {
        padding: 10px !important;
        margin: 12px 0 !important;
        font-size: 10px;
        transition: opacity 0.2s ease;
    }

    /* Регистрация: один экран на мобильном — оба шага видны, без переключения */
    .minimal-auth-container .step-indicator {
        display: none !important;
    }

    .minimal-auth-container .step-content {
        display: block !important;
    }

    .minimal-auth-container .step-content.active {
        display: block !important;
    }

    .minimal-auth-container .btn-next-step,
    .minimal-auth-container .btn-prev-step {
        display: none !important;
    }

    .step-indicator {
        margin-bottom: 18px;
    }

    .step-indicator .step-dot {
        transition: transform 0.25s ease, background 0.25s ease;
    }

    .button-group {
        margin-top: 16px;
        gap: 8px;
        flex-direction: column;
    }

    .button-group .btn-primary {
        order: 1;
    }

    .button-group .btn-secondary {
        order: 2;
        width: 100%;
    }

    .g-recaptcha {
        transform: scale(0.88);
        margin-bottom: 6px;
    }

    /* PWA информационный блок - только на мобильных */
    .pwa-info-block {
        margin-top: 20px;
        padding: 12px 14px;
        background: rgba(17, 24, 39, 0.03);
        border: 1px solid rgba(17, 24, 39, 0.08);
        border-radius: 8px;
        opacity: 0.7;
        transition: opacity 0.3s ease;
    }

    .pwa-info-block:hover {
        opacity: 0.85;
    }

    .pwa-info-content {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }

    .pwa-icons {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 12px;
        opacity: 0.6;
    }

    .pwa-icons i {
        font-size: 14px;
        color: #6b7280;
        transition: color 0.2s ease, transform 0.2s ease;
    }

    .pwa-info-text {
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
        font-size: 10px;
        font-weight: 400;
        color: #6b7280;
        text-align: center;
        margin: 0;
        line-height: 1.3;
        opacity: 0.8;
    }
}

/* Скрываем PWA блок на десктопе */
@media (min-width: 769px) {
    .pwa-info-block {
        display: none !important;
    }
}

/* Очень маленькие экраны */
@media (max-width: 360px) {
    .auth-wrapper.auth-v3 {
        padding: 10px 12px !important;
    }

    .minimal-auth-container {
        padding: 12px 12px 12px !important;
        margin: 0 10px !important;
    }

    .auth-title {
        font-size: 16px !important;
    }

    .auth-subtitle {
        font-size: 10px !important;
    }

    .g-recaptcha {
        transform: scale(0.8);
    }
}

/* Планшеты: форма строго по центру */
@media (min-width: 769px) and (max-width: 1024px) {
    #authMainContent.auth-wrapper.auth-v3 {
        min-height: 100vh;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 20px;
    }

    #authMainContent > .auth-content {
        min-height: 100vh;
        width: 100%;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    #authMainContent .auth-wrapper.auth-v3:not(#authMainContent) {
        width: 100%;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .auth-wrapper.auth-v3 {
        padding: 20px;
    }

    .minimal-auth-container {
        max-width: 360px;
        padding: 32px 28px;
    }

    .form-input {
        font-size: 15px;
    }
}
