/* ============================================================
   Auth Gate — стили модуля
   Использует CSS-переменные основного сайта из _vars.scss
   ============================================================ */

/* --- Локальные переменные модуля -------------------------- */
:root {
    --auth-gate-accent: var(--theme-accent-color);
    --auth-gate-accent-hover: var(--theme-accent-color-active);
    --auth-gate-accent-disabled: var(--surface-contrast);
    --auth-gate-accent-ring: color-mix(in srgb, var(--theme-accent-color) 10%, transparent);
    --input-height: 2.8rem;
}

/* ============================================================
   Область формы
   ============================================================ */

.auth-gate-area {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-content: center;
}

.auth-gate-heading {
    text-align: center;
}

.js-auth-gate {
    min-height: 120px;
    display: flex;
    justify-content: center;
}

.auth-gate-revealed {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
}

/* ============================================================
   Карточка авторизации
   ============================================================ */

.auth-gate-auth {
    max-width: 480px;
    background: var(--surface-primary-blue);
    border: 1px solid var(--gray-line-color);
    border-radius: var(--border-radius-xs);
    padding: 2rem;
    box-shadow: var(--shadow-level-2);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.auth-gate-auth__title {
    font-size: 1.2rem;
    font-weight: var(--font-weight-400);
    color: var(--heading-color);
}

/* ============================================================
   Вкладки
   ============================================================ */

.auth-gate-modal__tabs {
    display: flex;
    gap: .25rem;
    border-bottom: 2px solid var(--gray-line-color);
}

.auth-gate-tab {
    background: none;
    border: none;
    padding: .5rem 1rem;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color .15s, border-color .15s;
    outline: none;
}

.auth-gate-tab:hover {
    color: var(--auth-gate-accent);
}

.auth-gate-tab.is-active {
    color: var(--auth-gate-accent);
    border-bottom-color: var(--auth-gate-accent);
    font-weight: var(--font-weight-500);
}

/* ============================================================
   Панели (grid-stacking — нет прыжка при переключении)
   ============================================================ */

.auth-gate-panes {
    display: grid;
}

.auth-gate-pane {
    grid-area: 1 / 1;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-gate-pane.is-active {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.auth-gate-pane__hint {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    margin-bottom: 1rem;
    line-height: var(--text-line-height);
}

/* ============================================================
   Поля ввода
   ============================================================ */

.auth-gate-field {
    position: relative;
}

.auth-gate-input {
    height: var(--input-height);
    display: block;
    width: 100%;
    padding: .625rem .75rem;
    border: 1px solid var(--surface-secondary);
    border-radius: var(--border-radius-xs);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    background: var(--surface-primary);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    box-sizing: border-box;
}

.auth-gate-input:focus {
    border-color: var(--auth-gate-accent);
    box-shadow: 0 0 0 3px var(--auth-gate-accent-ring);
}

.auth-gate-input:disabled {
    background: var(--surface-primary-blue);
    color: var(--text-disabled);
}

.auth-gate-input::placeholder {
    color: var(--input-placeholder-color);
}

.auth-gate-field__error {
    position: absolute;
    inset: auto .125rem -.75rem auto;
    display: block;
    background: var(--surface-heavy-contrast);
    color: var(--text-invert);
    padding: .125rem .25rem;
    font-size: .75rem;
    font-weight: 300;
    min-height: 1em;
    border-radius: var(--border-radius-xxs);
    white-space: nowrap;
    z-index: 1;

    &::before {
        content: "";
        position: absolute;
        bottom: 100%;
        right: 1rem;
        border-width: 5px;
        border-style: solid;
        border-color: rgba(0, 0, 0, 0) rgba(0, 0, 0, 0) var(--surface-heavy-contrast) rgba(0, 0, 0, 0);
    }
}

/* ============================================================
   Инпут с иконкой (fa-envelope)
   ============================================================ */

.auth-gate-input-wrap--icon {
    position: relative;
}

.auth-gate-input-icon {
    position: absolute;
    left: .75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--input-group-icon-color);
    pointer-events: none;
    font-size: var(--font-size-sm);
}

.auth-gate-input--with-icon {
    padding-left: 2.25rem;
}

/* ============================================================
   intl-tel-input внутри формы
   ============================================================ */

.auth-gate-pane .intl-tel-input {
    display: block;
    width: 100%;
    font-size: var(--font-size-sm);
}

.auth-gate-pane .intl-tel-input input {
    height: var(--input-height);
    width: 100%;
    box-sizing: border-box;
    background: var(--surface-primary);
}
/* ============================================================
   Intl-tel-input стили
   ============================================================ */

.auth-gate-field {
    .intl-tel-input {
        --flag-container-delta: 4px;
        --radius: var(--border-radius-xs);
        --arrow-size: .325rem;

        .flag-container {
            margin-left: var(--flag-container-delta);
            top: var(--flag-container-delta);
            bottom: var(--flag-container-delta);
        }

        .selected-flag {
            border-radius: var(--radius);
            background: var(--surface-primary);
            padding-right: 3px;

            &:hover {
                background: var(--surface-minimal);
            }
        }

        .selected-flag .iti-arrow {
            position: absolute;
            top: 55%;
            width: var(--arrow-size);
            height: var(--arrow-size);
            transform: translateY(-50%) rotate(45deg);
            border-right: 1px solid var(--text-secondary);
            border-bottom: 1px solid var(--text-secondary);
            right: var(--arrow-size);
            border-left: none;
            border-top: none;
        }

        .country-list {
            border-radius: var(--radius);
            box-shadow: var(--shadow-level-1);
            border: none;
            padding: 0.25rem;
        }
    ;

        .country {
            border-radius: var(--radius);
        }

    }
}

/* ============================================================
   Кнопка
   ============================================================ */

.auth-gate-btn {
    display: inline-block;
    padding: .75rem 1rem;
    border: none;
    border-radius: var(--border-radius-xs);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-500);
    cursor: pointer;
    background: var(--auth-gate-accent);
    color: var(--surface-primary);
    transition: background .2s;
    outline: none;
    margin-top: .75rem;
}

.auth-gate-btn:hover:not(:disabled) {
    background: var(--auth-gate-accent-hover);
}

.auth-gate-btn:disabled {
    background: var(--auth-gate-accent-disabled);
    cursor: default;
}

.auth-gate-btn--secondary {
    background: none;
    color: var(--auth-gate-accent);
    border: 1px solid var(--auth-gate-accent);
}

.auth-gate-btn--secondary:hover:not(:disabled) {
    background: var(--auth-gate-accent);
    color: var(--surface-primary);
}

.auth-gate-btn--secondary:disabled {
    background: none;
    color: var(--auth-gate-accent-disabled);
    border-color: var(--auth-gate-accent-disabled);
    cursor: default;
}

/* ============================================================
   Шаг ввода кода
   ============================================================ */

.auth-gate-code-step {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--gray-line-color);
}

.auth-gate-code-group {
    display: flex;
    gap: .5rem;
    justify-content: center;
}
.auth-gate-code-input {
    letter-spacing: .4em;
    text-align: center;
    font-size: 1.75rem;
    font-weight: var(--font-weight-700);
    padding: .5rem 1rem;
}

.auth-gate-code-digit {
    font-size: 1.75rem;
    text-align: center;
    padding: 2rem 1rem;
    flex: 0 0 3.5rem;
}
.auth-gate-code-digit-divider {
    align-self: center;
    width: 1rem;
    height: .25rem;
    background: var(--surface-secondary);
    border-radius: .5rem;
}
/* ============================================================
   Капча
   ============================================================ */

.auth-gate-captcha {
    display: flex;
    gap: 1rem;
}

.auth-gate-captcha__img-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: .5rem;
    height: var(--input-height);
    border-radius: var(--border-radius-xs);
    background: var(--surface-primary);
    border: 1px solid var(--surface-minimal);
}

.auth-gate-captcha__img {
    width: 100%;
    display: block;
    height: 100%;
    object-fit: contain;
    border-radius: var(--border-radius-xs);
}

.auth-gate-captcha__refresh {
    position: absolute;
    inset: -0.5em -0.5em auto auto;
    background: var(--surface-primary);
    border: none;
    border-radius: 50%;
    padding: .25rem;
    font-size: .875rem;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
    transition: color .15s;
    box-shadow: var(--shadow-level-2);

    &:hover {
        color: var(--auth-gate-accent);
        i.fa {
            animation: fa-spin 2s infinite linear;
            animation-delay: 0s;
        }
    }
}

/* ============================================================
   Сообщение об успехе
   ============================================================ */

.auth-gate-success {
    margin-top: .75rem;
    padding: .75rem 1rem;
    background: var(--success-color-100);
    border-radius: var(--border-radius-xs);
    color: var(--success-color-800);
    font-size: var(--font-size-sm);
    line-height: var(--text-line-height);
}

/* ============================================================
   Кнопка выхода
   ============================================================ */

.auth-gate-logout {
    display: block;
    margin-top: .75rem;
    background: none;
    border: none;
    padding: 0;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.auth-gate-logout:hover {
    color: var(--error-color);
}

.auth-gate-description{
    background: #fff;
    box-shadow: var(--shadow-level-2);
    border-radius: .25rem;
    margin-bottom: 2rem;
    padding: 1rem;
}