/* auth.css — экран входа RGS WEB */

@font-face {
    font-family: 'Bauhaus 93';
    src: url('fonts/Bauhaus93.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* WebView: без синего flash */
.auth-page,
.auth-page * {
    -webkit-tap-highlight-color: transparent;
}

.auth-page button,
.auth-page a,
.auth-page .auth-tab,
.auth-page .info-icon,
.auth-page .toggle-password,
.auth-page .action-btn,
.auth-page .verification-links a {
    touch-action: manipulation;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.auth-page input,
.auth-page textarea {
    -webkit-appearance: none;
    appearance: none;
}

.auth-page *:focus,
.auth-page *:focus-visible {
    outline: none;
}

/* —— Layout —— */
.auth-page {
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg-primary);
    color: var(--text-primary);
    overscroll-behavior: none;
    touch-action: manipulation;
}

.auth-shell {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding:
        calc(16px + var(--safe-top, env(safe-area-inset-top, 0px)))
        calc(16px + var(--safe-right, env(safe-area-inset-right, 0px)))
        calc(16px + var(--safe-bottom, env(safe-area-inset-bottom, 0px)))
        calc(16px + var(--safe-left, env(safe-area-inset-left, 0px)));
}

.auth-app {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* —— Шапка (центр, без логотипа) —— */
.auth-hero {
    text-align: center;
    padding: 0 8px;
}

.auth-logo-text {
    margin: 0;
    font-family: 'Bauhaus 93', Impact, sans-serif;
    font-size: clamp(2rem, 8vw, 2.5rem);
    font-weight: normal;
    letter-spacing: 0.05em;
    line-height: 1.05;
    color: var(--text-primary);
}

.auth-tagline {
    margin: 10px auto 0;
    max-width: 26ch;
    font-size: 14px;
    line-height: 1.45;
    color: var(--text-secondary);
}

/* —— Карточка —— */
.auth-body {
    width: 100%;
}

.auth-card {
    background: var(--block-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 20px 18px 18px;
    box-shadow: var(--shadow-elevated, 0 4px 24px rgba(0, 0, 0, 0.06));
}

[data-theme="dark"] .auth-card,
.dark-theme .auth-card {
    background: var(--block-bg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28);
}

/* —— Табы —— */
.auth-tabs.theme-segmented {
    display: flex;
    width: 100%;
    margin-bottom: 20px;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
    border: 1px solid var(--border-color);
}

.auth-tab.theme-segmented-option {
    flex: 1;
    background: transparent;
    border: none;
    padding: 11px 14px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.16s ease, color 0.16s ease, transform 0.1s ease;
}

.auth-tab.theme-segmented-option:active {
    transform: scale(0.98);
}

.auth-tab.theme-segmented-option.active {
    background: var(--block-bg);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm, 0 1px 4px rgba(0, 0, 0, 0.1));
}

/* —— Заголовок формы —— */
.auth-form-head {
    margin-bottom: 16px;
}

.auth-form-head h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.auth-form-head p {
    margin: 4px 0 0;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.auth-form-head--center {
    text-align: center;
}

#verificationBlock .form-header {
    display: block;
}

/* —— Поля —— */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-fields {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.input-group-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.input-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.input-field {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-input {
    width: 100%;
    padding: 13px 15px;
    font-size: 16px;
    line-height: 1.25;
    border: 1px solid var(--input-border, var(--border-color));
    border-radius: 12px;
    background: var(--input-bg, var(--bg-primary));
    color: var(--text-primary);
    font-family: inherit;
    transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}

.auth-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.85;
}

.auth-input:focus {
    border-color: var(--accent-primary);
    background: var(--input-bg, var(--block-bg));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-primary) 16%, transparent);
}

.auth-input.has-icon {
    padding-right: 2.75rem;
}

.password-wrapper {
    position: relative;
    width: 100%;
}

.password-wrapper .auth-input {
    padding-right: 48px;
}

.toggle-password,
.info-icon {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.12s, color 0.12s, transform 0.1s;
}

.info-icon {
    width: 24px;
    height: 24px;
    right: 12px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    font: 700 11px/1 monospace;
}

.toggle-password:active,
.info-icon:active {
    transform: translateY(-50%) scale(0.92);
    background: var(--bg-active);
    color: var(--text-primary);
}

.toggle-password svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}

.forgot-link {
    flex-shrink: 0;
}

.forgot-link a {
    display: inline-block;
    padding: 2px 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    white-space: nowrap;
}

.forgot-link a:active {
    color: var(--accent-primary);
    background: var(--bg-active);
}

/* —— Кнопка —— */
.auth-submit.action-btn {
    width: 100%;
    padding: 14px 18px;
    border: none;
    border-radius: 14px;
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s ease, opacity 0.15s ease;
}

.auth-submit.action-btn:active:not(:disabled) {
    transform: scale(0.98);
    opacity: 0.88;
}

.auth-submit.action-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* —— Сообщения —— */
.message {
    display: none;
    margin-bottom: 14px;
    padding: 11px 13px;
    border-radius: 12px;
    font-size: 13px;
    text-align: center;
    line-height: 1.4;
}

.message.error {
    display: block;
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color, #ef4444);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.message.success {
    display: block;
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

[data-theme="dark"] .message.success,
.dark-theme .message.success {
    color: #86efac;
}

.toggle-auth {
    display: none;
}

/* —— OTP —— */
.verify-badge {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--accent-primary);
}

.verify-badge svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.auth-otp-row {
    display: flex;
    gap: clamp(6px, 2vw, 10px);
    justify-content: center;
    margin: 4px 0 16px;
}

.auth-otp-digit {
    width: clamp(40px, 11vw, 48px);
    height: clamp(46px, 12vw, 54px);
    text-align: center;
    font: 700 clamp(18px, 5vw, 22px)/1 inherit;
    border: 1px solid var(--input-border, var(--border-color));
    border-radius: 12px;
    background: var(--input-bg, var(--bg-primary));
    color: var(--text-primary);
    padding: 0;
    caret-color: var(--accent-primary);
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.auth-otp-digit:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-primary) 16%, transparent);
}

.auth-otp-digit.filled {
    border-color: var(--accent-primary);
    background: var(--block-bg-secondary);
}

#verificationCode {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

.verification-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 24px;
    margin-top: 4px;
}

.verification-links a {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 4px;
    border-radius: 8px;
}

.verification-links a:active {
    color: var(--accent-primary);
    background: var(--bg-active);
}

/* —— Telegram —— */
.auth-telegram {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.auth-telegram-label {
    margin-bottom: 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* —— Тултип —— */
.custom-tooltip {
    position: fixed;
    z-index: 1000;
    max-width: 280px;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1.45;
    background: var(--block-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-elevated, 0 8px 24px rgba(0, 0, 0, 0.15));
    pointer-events: none;
}

.custom-tooltip strong {
    color: var(--accent-primary);
}

.custom-tooltip ul {
    margin: 4px 0 0 14px;
}

/* —— ПК —— */
@media (min-width: 640px) {
    .auth-shell {
        padding:
            calc(32px + var(--safe-top, env(safe-area-inset-top, 0px)))
            24px
            calc(32px + var(--safe-bottom, env(safe-area-inset-bottom, 0px)));
    }

    .auth-app {
        max-width: 440px;
        gap: 28px;
    }

    .auth-logo-text {
        font-size: 2.75rem;
    }

    .auth-tagline {
        font-size: 15px;
        max-width: 32ch;
    }

    .auth-card {
        padding: 24px 22px 22px;
        border-radius: 24px;
    }

    .auth-tabs.theme-segmented {
        margin-bottom: 22px;
    }

    .auth-form-head h2 {
        font-size: 20px;
    }

    .auth-input {
        padding: 14px 16px;
        font-size: 15px;
        border-radius: 12px;
    }

    .auth-submit.action-btn {
        padding: 15px 18px;
        border-radius: 14px;
    }
}

/* —— Узкие телефоны —— */
@media (max-width: 380px) {
    .auth-shell {
        padding-left: calc(12px + var(--safe-left, env(safe-area-inset-left, 0px)));
        padding-right: calc(12px + var(--safe-right, env(safe-area-inset-right, 0px)));
    }

    .auth-card {
        padding: 16px 14px 14px;
        border-radius: 18px;
    }

    .auth-tab.theme-segmented-option {
        padding: 10px 8px;
        font-size: 13px;
    }
}

@media (hover: hover) and (pointer: fine) {
    .auth-tab.theme-segmented-option:hover:not(.active) {
        color: var(--text-primary);
    }

    .toggle-password:hover,
    .info-icon:hover {
        color: var(--text-primary);
        background: var(--bg-hover);
    }

    .forgot-link a:hover {
        color: var(--accent-primary);
    }

    .auth-submit.action-btn:hover:not(:disabled) {
        opacity: 0.92;
    }

    .verification-links a:hover {
        color: var(--accent-primary);
    }

    .auth-card {
        transition: box-shadow 0.2s ease;
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-tab,
    .auth-submit,
    .toggle-password,
    .info-icon,
    .auth-otp-digit {
        transition: none;
    }
}
