/* ===== AUTH FORM STEPS / HINTS ===== */
.auth-step[hidden] { display: none; }

.form-hint {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.78rem;
    line-height: 1.35;
    color: var(--gray-500, #6b7280);
}

/* ===== AUTH MODAL STYLES ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
    /* visible — иначе backdrop-filter на оверлее не размывает страницу */
    overflow: visible;
    background: transparent;
}

.modal.active {
    display: flex;
    overflow: visible;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(12px) saturate(1.2);
    -webkit-backdrop-filter: blur(12px) saturate(1.2);
    z-index: 0;
}

.modal-content {
    position: relative;
    background: var(--surface, #fff);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    width: 100%;
    max-width: 440px;
    max-height: min(90dvh, calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 2rem));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: var(--shadow-2xl);
    animation: modalSlideIn 0.3s ease;
    /* Hide scrollbar but keep scrolling functionality */
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex-shrink: 0;
    margin: auto;
}

@supports (-webkit-touch-callout: none) {
    /* iOS: dvh + safe-area */
    .modal-content {
        margin: auto;
        max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 1.5rem);
    }
}

/* Hide scrollbar for Chrome, Safari and Opera */
.modal-content::-webkit-scrollbar {
    display: none;
}

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

.modal-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: var(--surface, #fff);
    border: 1px solid var(--gray-200);
    color: var(--gray-600);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    transition: all var(--transition-fast);
    z-index: 100;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: auto;
}

.modal-close:hover {
    background: var(--gray-50);
    color: var(--gray-900);
    border-color: var(--gray-300);
}

.modal-close:active {
    transform: scale(0.95);
}

.modal-close:focus {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

/* Auth Tabs */
.auth-tabs {
    display: flex;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: var(--spacing-lg);
}

.auth-tab {
    flex: 1;
    padding: var(--spacing-md) var(--spacing-lg);
    background: none;
    border: none;
    color: var(--gray-600);
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    position: relative;
    transition: color var(--transition-fast);
}

.auth-tab:hover {
    color: var(--primary-600);
}

.auth-tab.active {
    color: var(--primary-600);
}

.auth-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-600);
}

.auth-tabs.is-reset {
    display: none;
}

.auth-tabs.is-reset + .auth-forms-shell {
    min-height: 0;
}

.auth-reset-title {
    margin: 0 0 0.35rem;
    font-family: var(--font-heading);
    font-size: 1.15rem;
    color: var(--gray-900, #0f172a);
}

.auth-reset-lead {
    margin: 0 0 1.1rem;
    color: var(--gray-500, #6b7280);
    font-size: 0.88rem;
    line-height: 1.4;
}

/* Формы входа/регистрации — без скачка высоты при переключении вкладок */
.auth-forms-shell {
    display: grid;
    grid-template-columns: 1fr;
    margin-bottom: var(--spacing-md);
    min-height: 28rem;
}

.auth-forms-shell .auth-form {
    grid-area: 1 / 1;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    overflow: visible;
    transition: opacity 0.2s ease;
}

.auth-forms-shell .auth-form.active {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.form-group {
    margin-bottom: var(--spacing-md);
}

/* Prevent autoscroll to input when focused in modal */
.modal input:focus,
.modal textarea:focus,
.modal select:focus {
    scroll-behavior: auto;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--gray-700);
    font-weight: 500;
    font-size: 0.875rem;
}

.input-with-icon {
    position: relative;
}

.input-with-icon i:first-child {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    font-size: 1rem;
    /* только над своим input, не над списком стран телефона */
    z-index: 1;
}

.input-with-icon .password-toggle {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0.25rem;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: color var(--transition-fast);
    z-index: 1;
}

.input-with-icon .password-toggle:hover {
    color: var(--gray-600);
}

.input-with-icon input {
    width: 100%;
    padding: 0.75rem 3rem 0.75rem 2.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    background: var(--surface, #fff);
    position: relative;
}

.input-with-icon input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
    background: var(--surface, #fff);
}

.input-with-icon input.error {
    border-color: var(--error);
}

.input-with-icon input.error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Form Options */
.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    font-size: 0.875rem;
}

.checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--gray-600);
}

.checkbox input {
    width: 1rem;
    height: 1rem;
    margin-top: 0.15rem;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-300);
    cursor: pointer;
}

.auth-consent {
    margin: 0 0 1.1rem;
    font-size: 0.82rem;
    line-height: 1.45;
}

.auth-consent-text {
    color: var(--text-muted, var(--gray-600));
}

.auth-consent-text a {
    color: var(--primary-600);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.auth-consent-text a:hover {
    color: var(--primary-700);
}

.text-link {
    background: none;
    border: none;
    color: var(--primary-600);
    text-decoration: none;
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0;
    transition: color var(--transition-fast);
}

.text-link:hover {
    color: var(--primary-700);
    text-decoration: underline;
}

/* Auth Switch */
.auth-switch {
    text-align: center;
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--gray-200);
    color: var(--gray-600);
    font-size: 0.875rem;
}

.auth-switch button {
    margin-left: 0.5rem;
}

/* Demo Login */
.demo-login {
    margin-top: var(--spacing-xl);
    padding: var(--spacing-md);
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}

.demo-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: var(--spacing-sm);
    color: var(--gray-600);
    font-size: 0.875rem;
}

.demo-info i {
    color: var(--warning);
}

#demo-login-btn {
    width: 100%;
}

/* Error Messages */
.error-message {
    color: var(--error);
    font-size: 0.75rem;
    margin-top: 0.25rem;
    display: none;
}

.error-message.active {
    display: block;
}

/* Success Message */
.success-message {
    background: var(--success);
    color: white;
    padding: var(--spacing-md);
    border-radius: var(--radius);
    margin-bottom: var(--spacing-md);
    display: none;
}

.success-message.active {
    display: block;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Добавим отдельный класс для полей с паролем */
.password-field .input-with-icon input {
    padding-right: 3.5rem; /* Больше места для иконки глаза */
}

/* OAuth: сетка провайдеров */
.auth-oauth {
    margin: 0 0 0.85rem;
    display: grid;
    gap: 0.45rem;
}

.auth-oauth--compact {
    gap: 0.45rem;
}

.auth-oauth[hidden],
[data-register-after-region][hidden] {
    display: none !important;
}

.auth-oauth-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
}

@media (min-width: 420px) {
    .auth-oauth-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.auth-oauth-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.auth-oauth-tg-hint {
    margin: 0.45rem 0 0;
}

.auth-tg-code {
    display: grid;
    gap: 0.65rem;
    margin: 0.35rem 0 0.15rem;
}

.auth-tg-code[hidden] {
    display: none !important;
}

.auth-tg-code__field {
    margin-bottom: 0;
}

.auth-tg-code__field .input-with-icon input {
    letter-spacing: 0.22em;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.auth-tg-code__field .input-with-icon i:first-child {
    color: #229ed9;
}

.auth-tg-code__actions {
    display: grid;
    gap: 0.45rem;
}

.auth-tg-code__bot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
}

.auth-tg-code__bot i {
    color: #229ed9;
}

.btn-oauth-chip {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 2.45rem;
    padding: 0.4rem 0.55rem;
    border-radius: var(--radius, 0.65rem);
    border: 1px solid var(--gray-300, #d1d5db);
    background: var(--surface, #fff);
    color: var(--gray-800, #1f2937);
    font-family: var(--font-primary, inherit);
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.12s ease, border-color 0.12s ease, opacity 0.12s ease, filter 0.12s ease;
}

.btn-oauth-chip i {
    font-size: 1rem;
    opacity: 0.95;
}

.btn-oauth-chip--yandex i { color: #fc3f1d; }
.btn-oauth-chip--google i { color: #4285f4; }
.btn-oauth-chip--vk i { color: #0077ff; }
.btn-oauth-chip--apple i { color: #111827; }
.btn-oauth-chip--telegram i { color: #229ed9; }

.btn-oauth-chip:hover:not(:disabled) {
    background: var(--gray-50, #f9fafb);
    border-color: var(--gray-400, #9ca3af);
}

.btn-oauth-chip:disabled:not([data-oauth-soon]) {
    opacity: 0.55;
    cursor: wait;
}

.btn-oauth-chip[data-oauth-soon],
.btn-oauth-chip--disabled {
    opacity: 0.42;
    filter: grayscale(0.85);
    cursor: not-allowed;
    background: var(--gray-100, #f3f4f6);
    border-color: var(--gray-200, #e5e7eb);
    color: var(--gray-500, #6b7280);
}

.btn-oauth-chip[data-oauth-soon] i,
.btn-oauth-chip--disabled i {
    color: var(--gray-400, #9ca3af) !important;
}

.btn-oauth-chip[hidden] {
    display: none !important;
}

html[data-theme="dark"] .btn-oauth-chip,
html[data-theme="vice-city"] .btn-oauth-chip {
    background: color-mix(in srgb, var(--surface, #1f2937) 92%, #000);
    border-color: var(--gray-600, #4b5563);
    color: var(--gray-100, #f3f4f6);
}

html[data-theme="dark"] .btn-oauth-chip--apple i,
html[data-theme="vice-city"] .btn-oauth-chip--apple i { color: #f9fafb; }

html[data-theme="dark"] .btn-oauth-chip[data-oauth-soon],
html[data-theme="vice-city"] .btn-oauth-chip[data-oauth-soon],
html[data-theme="dark"] .btn-oauth-chip--disabled,
html[data-theme="vice-city"] .btn-oauth-chip--disabled {
    background: color-mix(in srgb, #111827 80%, transparent);
    border-color: var(--gray-700, #374151);
}

/* Старый полный btn — на случай других экранов */
.btn-oauth {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    background: var(--surface, #fff);
    color: var(--gray-900, #111827);
    border: 1px solid var(--gray-300, #d1d5db);
    font-weight: 600;
}

.btn-oauth:hover {
    background: var(--gray-50, #f9fafb);
    border-color: var(--gray-400, #9ca3af);
}

.btn-oauth[hidden] {
    display: none !important;
}

.auth-oauth-divider {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin: 0.1rem 0 0;
    color: var(--gray-500, #6b7280);
    font-size: 0.72rem;
    text-transform: lowercase;
}

.auth-oauth-divider::before,
.auth-oauth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--gray-200, #e5e7eb);
}
