/**
 * Экран входа/регистрации для PWA (без лендинга).
 */

html:has(body.pwa-auth-page),
html.pwa-standalone:has(body.pwa-auth-page) {
    scrollbar-gutter: auto;
    overflow-x: hidden;
    overflow-y: auto;
    height: auto;
    min-height: 100%;
}

html.pwa-standalone body.pwa-auth-page,
body.pwa-auth-page {
    margin: 0;
    min-height: 100dvh;
    height: auto;
    max-height: none;
    background: linear-gradient(165deg, #f8fafc 0%, #e0f2fe 45%, #f1f5f9 100%);
    padding: 0 !important;
    overflow-x: hidden;
    overflow-y: auto;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
}

body.pwa-auth-page.has-fixed-header {
    padding-top: 0 !important;
}

.pwa-auth-shell {
    position: relative;
    z-index: 1;
    min-height: 100dvh;
    height: auto;
    max-height: none;
    width: 100%;
    max-width: 26rem;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow: visible;
    padding:
        max(0.75rem, env(safe-area-inset-top, 0px))
        max(1rem, env(safe-area-inset-right, 0px))
        calc(0.65rem + env(safe-area-inset-bottom, 0px) + 28px)
        max(1rem, env(safe-area-inset-left, 0px));
}

.pwa-auth-brand {
    text-align: center;
    padding: 0.5rem 0 0.85rem;
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
}

.pwa-auth-logo {
    width: 4rem;
    height: 4rem;
    margin: 0 auto 0.65rem;
    border-radius: 1.1rem;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.pwa-auth-logo img {
    width: 2.5rem;
    height: 2.5rem;
    object-fit: contain;
}

.pwa-auth-name {
    margin: 0 0 0.35rem;
    font-family: var(--font-heading, Manrope, sans-serif);
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--gray-900, #0f172a);
    letter-spacing: -0.02em;
}

.pwa-auth-lead {
    margin: 0 auto;
    max-width: 22rem;
    padding: 0 0.25rem;
    font-size: 0.9rem;
    line-height: 1.45;
    color: var(--gray-600, #475569);
}

.pwa-auth-main {
    flex: 1 1 auto;
    min-height: 0;
    overflow: visible;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* Форма как карточка, не модалка — без боковых margin из responsive.css */
body.pwa-auth-page #auth-modal.modal,
body.pwa-auth-page #auth-modal.modal.active {
    position: relative !important;
    inset: auto !important;
    display: block !important;
    z-index: 1;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible;
    background: transparent;
    align-items: stretch;
    justify-content: stretch;
    max-height: none;
    box-sizing: border-box;
}

body.pwa-auth-page #auth-modal .modal-overlay,
body.pwa-auth-page #auth-modal .modal-close {
    display: none !important;
}

body.pwa-auth-page #auth-modal .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 1.1rem 1rem 1.15rem !important;
    border-radius: 1.1rem;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.1);
    animation: none;
    overflow: visible;
    box-sizing: border-box;
}

body.pwa-auth-page .auth-tabs {
    margin-bottom: 0.85rem;
}

/* Высота по активной вкладке — без пустого «колодца» под формой */
body.pwa-auth-page .auth-forms-shell {
    display: block;
    min-height: 0 !important;
    margin-bottom: 0 !important;
    width: 100%;
}

body.pwa-auth-page .auth-forms-shell .auth-form {
    display: none;
    grid-area: auto;
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    width: 100%;
    margin: 0;
}

body.pwa-auth-page .auth-forms-shell .auth-form.active {
    display: block;
}

body.pwa-auth-page .auth-switch {
    margin-top: 0.85rem;
    margin-bottom: 0;
    padding-bottom: 0;
}

body.pwa-auth-page .form-group {
    margin-bottom: 0.7rem;
}

body.pwa-auth-page .form-group,
body.pwa-auth-page .form-group input,
body.pwa-auth-page .form-group .input-with-icon,
body.pwa-auth-page .iti,
body.pwa-auth-page .iti--allow-dropdown,
body.pwa-auth-page .iti input {
    max-width: 100%;
    box-sizing: border-box;
}

body.pwa-auth-page .iti {
    width: 100%;
    display: block;
}

/* iOS PWA / Android: капча с нормальной шириной касания */
body.pwa-auth-page .vp-captcha-wrap {
    width: 100%;
    overflow: visible !important;
    position: relative;
    z-index: 3;
    margin: 0.45rem 0 0.65rem;
}

body.pwa-auth-page .vp-captcha {
    --vp-cap-track-h: 40px;
    --vp-cap-knob: 36px;
}

/* Язык снизу — переключалка, запас под жест Android */
.pwa-auth-lang {
    flex-shrink: 0;
    width: 100%;
    padding-top: 0.65rem;
    margin-top: 0;
    box-sizing: border-box;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
}

.pwa-auth-lang-caption {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--gray-500, #64748b);
}

.pwa-auth-lang .lang-switcher {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--gray-200, #e2e8f0);
    border-radius: 0.85rem;
    padding: 0.2rem 0.3rem;
}

@media (max-height: 700px) {
    .pwa-auth-brand { padding-bottom: 0.4rem; }
    .pwa-auth-logo { width: 3.25rem; height: 3.25rem; margin-bottom: 0.4rem; }
    .pwa-auth-logo img { width: 2rem; height: 2rem; }
    .pwa-auth-name { font-size: 1.35rem; }
    .pwa-auth-lead { font-size: 0.82rem; }
    .pwa-auth-lang { padding-top: 0.5rem; }
    body.pwa-auth-page:has(#register-form.active) .pwa-auth-lead { display: none; }
}
