/* Auth Layout Styles */

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-dark: #0f172a;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --danger: #ef4444;
    --success: #22c55e;
}

body {
    margin: 0;
    /* fallback, затем safe-area для устройств с «чёлкой» (viewport-fit=cover) */
    padding: 24px 16px;
    padding:
        max(24px, env(safe-area-inset-top))
        max(16px, env(safe-area-inset-right))
        max(24px, env(safe-area-inset-bottom))
        max(16px, env(safe-area-inset-left));
    box-sizing: border-box;
    font-family: 'ubuntu', sans-serif;
    /* Статичный фон: индиго сверху-слева + розовый снизу-справа (бывшие орбы) +
       синий/маджента сверху. Без анимации и блюр-слоёв — экономия ОЗУ/GPU. */
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(at 18% 18%, hsla(243, 75%, 59%, 0.42) 0px, transparent 50%),
        radial-gradient(at 85% 82%, hsla(330, 81%, 60%, 0.38) 0px, transparent 50%),
        radial-gradient(at 55% 0%, hsla(225, 39%, 30%, 0.85) 0px, transparent 55%),
        radial-gradient(at 100% 0%, hsla(339, 49%, 30%, 0.70) 0px, transparent 50%);
    background-repeat: no-repeat;
    /* fallback 100vh, затем динамический вьюпорт (учитывает адресную строку на мобильных) */
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-main);
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 40px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    /* position: relative — контекст для absolute-кнопки «назад» на десктопе;
       НЕ transform (он бы сделал fixed-потомков относительными контейнеру) */
    position: relative;
    animation: slideUp 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.logo-area {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-icon {
    font-size: 2rem;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.logo-icon svg {
    fill: #aa86fa;
}

.logo-icon img {
    display: block;
    width: 42px;
    height: 42px;
    margin: 0 auto;
}

h2 {
    margin: 0;
    font-weight: 600;
    font-size: 1.75rem;
    letter-spacing: -0.025em;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 0.5rem;
}

.field {
    margin-bottom: 1.125rem;
    position: relative;
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    transition: color 0.2s;
}

.field:focus-within label {
    color: var(--primary);
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="datetime-local"],
textarea,
select {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:focus,
input[type="datetime-local"]:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    background: rgba(15, 23, 42, 0.8);
}

/* Fix browser autofill styling */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px rgba(15, 23, 42, 1) inset !important;
    -webkit-text-fill-color: var(--text-main) !important;
    transition: background-color 5000s ease-in-out 0s;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
}

/* Password field with show/hide toggle (десктоп + мобайл) */
.password-field {
    position: relative;
}

.password-field input {
    padding-right: 48px;
}

.password-toggle {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}

.password-toggle:hover {
    color: var(--text-main);
}

.password-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -4px;
    border-radius: 10px;
}

.password-toggle svg {
    width: 20px;
    height: 20px;
}

.password-toggle .icon-eye-off {
    display: none;
}

.password-toggle[aria-pressed="true"] .icon-eye {
    display: none;
}

.password-toggle[aria-pressed="true"] .icon-eye-off {
    display: block;
}

/* Checkbox */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1.5rem;
}

.checkbox-wrapper label {
    margin-bottom: 0;
    cursor: pointer;
    font-size: 0.95rem;
}

.checkbox-wrapper input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    margin: 0;
}

.checkbox-wrapper input[type="checkbox"]:checked {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-wrapper input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 45%;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: translate(-50%, -50%) rotate(45deg);
}

.checkbox-wrapper input[type="checkbox"]:hover {
    border-color: var(--primary);
}

.actions {
    margin-top: 2rem;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
    box-sizing: border-box;
    text-align: center;
    margin-bottom: 12px;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0) 80%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 0;
}

.btn:hover::before {
    opacity: 1;
}

.btn>* {
    position: relative;
    z-index: 1;
}

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

.btn:hover {
    filter: brightness(1.1);
}

.btn:active {
    transform: translateY(1px);
    transition: transform 0.1s;
}

/* Primary Button */
.btn-primary {
    background-color: #4159ce;
    color: white;
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.3);
}

.btn-primary::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #4159ce 0% 20%, #ef356c 100%);
    transition: opacity 0.3s ease;
    z-index: 0;
}

.btn-primary:hover::after {
    opacity: 0;
}

.btn-primary:hover {
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.4);
}

.btn-primary::before {
    background: radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(239, 53, 108, 0.9), rgba(239, 53, 108, 0) 85%);
    z-index: 1;
}

/* Secondary Button */
.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
}

.btn-secondary::before {
    display: none;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Indigo Button */
.btn-indigo {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: #a5b4fc;
}

.btn-indigo::before {
    display: none;
}

.btn-indigo:hover {
    background: rgba(99, 102, 241, 0.2);
    color: white;
    border-color: rgba(99, 102, 241, 0.5);
}

/* Danger Button */
.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.btn-danger::before {
    display: none;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
    color: white;
    border-color: rgba(239, 68, 68, 0.5);
}

/* Social Buttons & Divider */
.auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1.75rem 0 1.25rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--glass-border);
}

.auth-divider:not(:empty)::before {
    margin-right: 1rem;
}

.auth-divider:not(:empty)::after {
    margin-left: 1rem;
}

.social-buttons-row {
    display: flex;
    gap: 12px;
    margin-top: 0;
    justify-content: center;
}

.btn-social {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
}

.btn-social::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0) 80%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 0;
}

.btn-social:hover::before {
    opacity: 1;
}

.btn-social>svg,
.btn-social>span {
    position: relative;
    z-index: 1;
}

.btn-social svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.btn-google,
.btn-yandex,
.btn-apple {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    backdrop-filter: blur(10px);
}

.btn-google:hover,
.btn-yandex:hover,
.btn-apple:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

.links-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 1.25rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.links-row a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.links-row a:hover {
    color: var(--primary);
}

/* ── Multi-step Registration ── */

/* Back arrow button — top-left of auth-container */
.reg-back-btn {
    position: absolute;
    top: 16px;
    left: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
    padding: 0;
}

.reg-back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Step indicator dots */
.step-indicator {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 1.5rem;
}

.step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    transition: all 0.3s ease;
}

.step-dot.active {
    background: var(--primary);
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.4);
}

/* Field error highlight */
input.field-error {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}

/* Flash Toast Container — floats above everything */
.flash-toast-container {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 90%;
    max-width: 440px;
    pointer-events: none;
}

/* Flash Messages */
.flash-message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    pointer-events: auto;
    animation: toastIn 0.4s cubic-bezier(0.16, 1, 0.3, 1),
        toastOut 0.4s 4.6s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    to {
        opacity: 0;
        transform: translateY(-12px) scale(0.95);
    }
}

.notice {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.25);
    color: #86efac;
}

.alert {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #fca5a5;
}

.flash-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 2px;
}

/* ── Language switcher — компактный дропдаун (в стиле web-client) ── */
.lang-switcher {
    position: relative;
    display: inline-flex;
}

/* Фиксированное размещение в углу (auth-страницы); в админке партиал стоит в навбаре */
.lang-switcher--fixed {
    position: fixed;
    top: max(16px, env(safe-area-inset-top));
    right: max(16px, env(safe-area-inset-right));
    z-index: 100;
}

.lang-switcher__trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.lang-switcher__trigger:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.lang-switcher__icon {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.lang-switcher__chevron {
    width: 12px;
    height: 12px;
    color: var(--text-muted);
    transition: transform 0.2s;
    flex-shrink: 0;
}

.lang-switcher__trigger[aria-expanded="true"] .lang-switcher__chevron {
    transform: rotate(180deg);
}

.lang-switcher__menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    transform-origin: top right;
    visibility: hidden;
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    pointer-events: none;
}

.lang-switcher.is-open .lang-switcher__menu {
    visibility: visible;
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.lang-switcher__item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border: none;
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    text-align: left;
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
}

.lang-switcher__item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
}

.lang-switcher__item:focus-visible {
    outline: none;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.lang-switcher__item--active {
    color: var(--primary);
}

.lang-switcher__short {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.06);
    padding: 3px 7px;
    border-radius: 8px;
    min-width: 30px;
    text-align: center;
}

.lang-switcher__item--active .lang-switcher__short {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.18);
}

.lang-switcher__name {
    flex: 1;
}

.lang-switcher__check {
    width: 16px;
    height: 16px;
    color: var(--primary);
    flex-shrink: 0;
}

/* ── Status Pages (denied, 404, 500, etc.) ── */

.status-page {
    text-align: center;
}

.status-page-icon {
    margin-bottom: 24px;
}

.status-page-code {
    font-family: 'Outfit', sans-serif;
    font-size: 80px;
    font-weight: 700;
    line-height: 1;
    margin: 0 0 8px;
    background: linear-gradient(135deg, #6274f0, #b055d0, #f7456f);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.status-page-heading {
    font-family: 'Outfit', sans-serif;
    font-size: 22px;
    font-weight: 600;
    color: var(--text-main);
    margin: 0 0 12px;
}

.status-page-message {
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    color: var(--text-muted);
    margin: 0 0 32px;
    line-height: 1.6;
}

.status-page-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.status-page-meta {
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    color: #475569;
    margin-top: 24px;
}

.btn-inline {
    width: auto;
    display: inline-block;
}

.btn-inline .btn {
    width: auto;
    padding: 12px 28px;
}

/* ── Телефоны: форма на весь экран без «карточки» (нативный лист) ── */
@media (max-width: 600px) {
    body {
        padding: 0;
        align-items: stretch;
    }

    .auth-container {
        width: 100%;
        max-width: none;
        min-height: 100dvh;
        box-sizing: border-box;
        /* убираем стеклянную карточку — фон-градиент становится фоном экрана */
        background: transparent;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        border: none;
        border-radius: 0;
        box-shadow: none;
        /* slideUp со сдвигом translateY на full-bleed вызывает кратковременный
           вертикальный скролл при загрузке — на мобильном въезд не нужен */
        animation: none;
        /* контент прижат к верху — удобнее при открытой клавиатуре (форма не «прыгает»
           и не уезжает под клавиатуру); верхний отступ — клиренс от переключателя языка */
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        /* верхушка (лого + иконка языка + кнопка «назад») с отступом 25px сверху */
        padding:
            max(25px, env(safe-area-inset-top))
            max(22px, env(safe-area-inset-right))
            max(36px, calc(env(safe-area-inset-bottom) + 24px))
            max(22px, env(safe-area-inset-left));
    }

    /* Лого + название в один ряд по центру; слева остаётся место для кнопки «назад» */
    .logo-area {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 10px;
        margin-bottom: 2rem;
    }

    .logo-icon {
        margin-bottom: 0;
    }

    .logo-icon img {
        width: 34px;
        height: 34px;
        margin: 0;
    }

    h2 {
        font-size: 1.4rem;
    }

    /* Подзаголовок на телефоне не показываем — чище */
    .subtitle {
        display: none;
    }

    /* Крупнее тап-таргеты (инпуты ≥16px шрифт — iOS не зумит) */
    input[type="email"],
    input[type="password"],
    input[type="text"],
    input[type="datetime-local"],
    textarea,
    select {
        padding: 15px 16px;
    }

    .btn {
        padding: 16px;
        font-size: 1.05rem;
    }

    .btn-social {
        padding: 13px;
    }

    .links-row {
        flex-wrap: wrap;
        gap: 8px 16px;
    }

    .status-page-code {
        font-size: 64px;
    }

    /* Переключатель языка: на телефоне только глобус — занимает меньше места */
    .lang-switcher__label {
        display: none;
    }

    .lang-switcher--fixed {
        top: max(25px, env(safe-area-inset-top));
    }

    /* Кнопка «назад» (регистрация): стеклянной карточки на телефоне нет,
       поэтому фиксируем её отдельно в левом верхнем углу (с учётом «чёлки»).
       display не задаём — видимостью по шагам управляет JS. */
    .reg-back-btn {
        position: fixed;
        top: max(25px, env(safe-area-inset-top));
        left: max(16px, env(safe-area-inset-left));
    }
}

/* Совсем маленькая высота (ландшафт телефона) — поджимаем верх/низ */
@media (max-height: 640px) {
    .logo-area {
        margin-bottom: 1.25rem;
    }
}

/* Уважаем системную настройку «уменьшить движение» */
@media (prefers-reduced-motion: reduce) {

    .auth-container,
    .flash-message {
        animation: none;
    }
}