/**
 * Intermediary auth — fixed full-viewport left rail (Figma), scroll only on right.
 */

.intermediary-auth-shell {
    position: relative;
    margin: 0;
    padding: 0;
    /* svh/dvh: avoid gap above taskbar / mobile browser chrome vs legacy vh */
    min-height: 100svh;
    min-height: 100dvh;
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Mobile: marketing column hidden; form uses full width */
.intermediary-auth-visual {
    display: none;
}

/*
 * Figma left column: the FULL illustration is visible (no crop).
 * We use `contain` so nothing is cut at top/bottom; purple fills any letterboxing.
 */
.intermediary-auth-visual-img {
    display: block;
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    min-height: 0;
    height: 100%;
    object-fit: contain;
    object-position: center center;
    background: #2d1f5c;
}

/* Desktop: left panel fixed, fills viewport; does not scroll with page */
@media (min-width: 992px) {
    .intermediary-auth-visual {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: stretch;
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 40%;
        height: auto;
        margin: 0;
        min-height: 100svh;
        min-height: 100dvh;
        min-height: 100vh;
        /* Edge-to-edge; only safe-area (fills to real screen bottom on Windows/Android) */
        padding: max(0px, env(safe-area-inset-top, 0px)) max(0px, env(safe-area-inset-right, 0px))
            max(0px, env(safe-area-inset-bottom, 0px)) max(0px, env(safe-area-inset-left, 0px));
        background: #2d1f5c;
        overflow: hidden;
        z-index: 100;
        box-sizing: border-box;
    }

    /* Only the right column scrolls — flex-start so tall cards aren’t clipped top/bottom */
    .intermediary-auth-panel {
        margin-left: 40%;
        width: 60%;
        max-width: none;
        min-height: 100svh;
        min-height: 100dvh;
        min-height: 100vh;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        align-items: flex-start;
    }
}

/* Right workspace */
.intermediary-auth-panel {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: max(16px, env(safe-area-inset-top, 0px)) clamp(16px, 3vw, 32px)
        max(28px, env(safe-area-inset-bottom, 0px));
    background-color: #f4f6fb;
    background-image: url("/img/p5_background.png");
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    box-sizing: border-box;
}

.intermediary-auth-card {
    width: 100%;
    max-width: 460px;
    margin-inline: auto;
    background: #fff;
    border-radius: 16px;
    border: 1px solid #e8eaef;
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.06);
    padding: clamp(20px, 4vw, 28px);
    box-sizing: border-box;
    flex-shrink: 0;
}

/* Tight label → input (Figma) */
.intermediary-auth-form .form-group.mt-3,
.intermediary-auth-form .crm-password-container.mt-3 {
    margin-top: 0 !important;
}

.intermediary-auth-form .form-label {
    margin-bottom: 0;
    font-size: 14px;
    font-weight: 600;
    color: #4a5568;
    line-height: 1.2;
}

/* Label sits directly above input (Figma tight stack) */
.intermediary-auth-form .intermediary-auth-field-gap {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    margin-bottom: 0.45rem;
}

.intermediary-auth-form .intermediary-auth-field-gap > .form-label {
    padding: 0;
    margin: 0;
    line-height: 1.15;
}

/* Login: password row has label + link in one row — don’t flex-wrap oddly */
.intermediary-auth-form .intermediary-auth-field-gap .d-flex.justify-content-between {
    gap: 8px;
    margin-bottom: 4px;
}

/* Password eye — Figma: grey icon inside field, no boxed background */
.intermediary-auth-shell .crm-password-container {
    position: relative;
}

.intermediary-auth-shell .crm-password-container .crm-password-input {
    padding-right: 40px;
}

.intermediary-auth-shell .toggle-password {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    margin: 0;
    padding: 4px;
    background: transparent !important;
    border: none;
    border-radius: 0;
    box-shadow: none;
    z-index: 2;
    line-height: 0;
}

.intermediary-auth-shell .toggle-password img {
    width: 20px;
    height: 20px;
    opacity: 0.62;
    display: block;
}

.intermediary-auth-shell .toggle-password:hover img {
    opacity: 0.85;
}

.intermediary-auth-shell .toggle-password img.close-eyes {
    display: none;
}

.intermediary-auth-shell .toggle-password.is-revealed img.open-eyes {
    display: none;
}

.intermediary-auth-shell .toggle-password.is-revealed img.close-eyes {
    display: block;
    opacity: 0.62;
}

.intermediary-auth-shell .form-control.is-invalid ~ .toggle-password {
    top: 50%;
}

/* Hover behavior (matches old auth): show cut-eye on hover */
.intermediary-auth-shell .toggle-password:hover img.open-eyes {
    display: none;
}

.intermediary-auth-shell .toggle-password:hover img.close-eyes {
    display: block;
}

/* If revealed (clicked), always keep cut-eye visible (even on hover) */
.intermediary-auth-shell .toggle-password.is-revealed:hover img.open-eyes {
    display: none;
}

.intermediary-auth-shell .toggle-password.is-revealed:hover img.close-eyes {
    display: block;
}

/* Full-viewport auth (guest): no stray bands at screen bottom */
html:has(.intermediary-auth-shell),
body:has(.intermediary-auth-shell) {
    margin: 0;
    min-height: 100svh;
    min-height: 100dvh;
    min-height: 100vh;
}

/* Primary submit stays visibly purple with label + spinner while disabled (matches old auth UX) */
.intermediary-auth-form .custom-btn.intermediarySignInBtn:disabled,
.intermediary-auth-form .custom-btn.intermediaryRegisterBtn:disabled,
.intermediary-auth-form .custom-btn.intermediaryForgotPasswordBtn:disabled,
.intermediary-auth-form .custom-btn.intermediaryResetPasswordBtn:disabled {
    opacity: 1;
    color: #fff !important;
    background-color: #383192 !important;
    border-color: transparent !important;
}

.intermediary-auth-form .custom-btn .spinner-grow {
    vertical-align: middle;
}

/* Sign-up referral code (optional) */
.signup-referral-card {
    border-radius: 16px;
    border: 1px solid rgba(56, 49, 146, 0.14);
    background: linear-gradient(145deg, #fafaff 0%, #f4f3fc 55%, #fff 100%);
    padding: 14px 16px 16px;
    box-shadow: 0 6px 20px rgba(56, 49, 146, 0.06);
}
.signup-referral-card__head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}
.signup-referral-card__icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #383192 0%, #6b5ce7 100%);
    box-shadow: 0 6px 16px rgba(56, 49, 146, 0.22);
}
.signup-referral-card__icon i::before {
    color: #fff;
}
.signup-referral-card__copy {
    flex: 1;
    min-width: 0;
}
.signup-referral-card__title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 4px;
}
.signup-referral-card__title {
    font-size: 14px;
    font-weight: 700;
    color: #383192;
    line-height: 1.3;
}
.signup-referral-card__badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #383192;
    background: rgba(56, 49, 146, 0.1);
    border: 1px solid rgba(56, 49, 146, 0.12);
}
.signup-referral-card__help {
    font-size: 12px;
    line-height: 1.45;
    color: #6b7280;
}
.signup-referral-card__input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px 0 14px;
    min-height: 46px;
    border-radius: 16px;
    border: 1px solid #e0e3ef;
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.signup-referral-card__input-wrap:focus-within {
    border-color: #383192;
    box-shadow: 0 0 0 3px rgba(56, 49, 146, 0.12);
}
.signup-referral-card__field-icon {
    flex-shrink: 0;
    line-height: 0;
    pointer-events: none;
}
.signup-referral-card__field-icon i::before {
    color: #383192;
    opacity: 0.55;
}
.signup-referral-card__input-group {
    margin-top: 0 !important;
    flex: 1;
    min-width: 0;
}
.signup-referral-card__input {
    border: none !important;
    box-shadow: none !important;
    padding: 10px 0 !important;
    height: 44px;
    font-size: 14px;
    font-weight: 500;
    color: #383192;
    background: transparent !important;
}
.signup-referral-card__input:focus {
    border: none !important;
    box-shadow: none !important;
    outline: none;
}
.signup-referral-card__input::placeholder {
    color: #9ca3af;
    font-weight: 400;
}
.signup-referral-card__input--locked,
.signup-referral-card__input--locked:focus {
    cursor: not-allowed;
    opacity: 0.85;
}
.signup-referral-card__input-wrap:has(.signup-referral-card__input--locked) {
    background-color: #f3f4f6;
}
