/* Hope UI auth pages — HM branding + form compatibility */

html:has(body.hm-auth-body),
body.hm-auth-body {
    height: 100%;
    margin: 0;
    overflow: hidden;
}

.hm-auth-page-root {
    height: 100%;
    min-height: 100dvh;
    overflow: hidden;
}

.hm-hope-auth {
    height: 100%;
    min-height: 100dvh;
    overflow: hidden;
}

.hm-hope-auth__row {
    height: 100%;
    min-height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
}

.hm-hope-auth__form-col {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    max-height: 100dvh;
    overflow: hidden;
    padding: 3.5rem 0 1.25rem;
}

.hm-hope-auth__form-col > .row {
    width: 100%;
    max-height: 100%;
    overflow: hidden;
}

.hm-hope-auth__center-wrap {
    width: 100%;
    max-width: min(32rem, 100%);
    min-width: 0;
    margin-inline: auto;
    padding-inline: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    z-index: 1;
    box-sizing: border-box;
}

/* OTP: keep Hope UI split (form + visual), center form content inside its half */
.hm-hope-auth--centered,
.hm-hope-auth--centered .hm-hope-auth__row {
    height: 100%;
    min-height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
}

.hm-hope-auth--centered .hm-hope-auth__form-col {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
    height: 100%;
    min-height: 100dvh;
    max-height: 100dvh;
    padding: 4rem 1.5rem 1.75rem;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

.hm-hope-auth--centered .hm-hope-auth__visual-col {
    min-width: 0;
    height: 100%;
    min-height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
}

.hm-hope-auth--centered .hm-hope-auth__card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    max-height: none;
    /* Override Hope UI .auth-card horizontal padding that squeezes/shifts OTP */
    padding: 0 !important;
    margin: 0;
}

.hm-hope-auth--centered .hm-hope-auth__card .card-body {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    max-height: none;
    overflow: visible;
    box-sizing: border-box;
}

.hm-hope-auth--centered .sign-bg {
    display: none;
}

.hm-hope-auth__card {
    max-height: 100%;
}

.hm-hope-auth__card .card-body {
    max-height: calc(100dvh - 4.75rem);
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.hm-hope-auth__card .card-body::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

.hm-hope-auth__visual-col {
    height: 100%;
    max-height: 100dvh;
    overflow: hidden;
}

.hm-hope-auth__visual {
    object-fit: cover;
}

.hm-auth-lang-hope {
    display: flex;
    gap: 0.25rem;
    padding: 0.25rem;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid #e9ecef;
    border-radius: 999px;
    box-shadow: 0 8px 24px rgba(15, 35, 58, 0.1);
}

.hm-auth-lang-hope .hm-auth-lang__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.75rem;
    padding: 0.45rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    color: #64748b;
    border-radius: 999px;
}

.hm-auth-lang-hope .hm-auth-lang__btn.is-active {
    color: #fff;
    background: var(--bs-primary, #3a57e8);
}

.hm-hope-auth .auth-card .navbar-brand img {
    height: 40px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

.hm-hope-auth .form-group {
    margin-bottom: 1rem;
}

.hm-hope-auth .hm-auth-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    border-radius: 10px;
    font-size: 0.9rem;
}

.hm-hope-auth .hm-auth-alert--danger {
    background: #fff5f5;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.hm-hope-auth .hm-auth-alert--success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #15803d;
}

.hm-hope-auth .hm-auth-alert--info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1d4ed8;
}

.hm-hope-auth .hm-auth-copyright {
    margin-top: 1.25rem;
    text-align: center;
    font-size: 0.78rem;
    color: #8a92a6;
}

.hm-hope-auth .hm-auth-copyright__line {
    margin: 0.15rem 0;
}

.hm-auth-lang.hm-auth-lang-hope {
    position: fixed;
    top: 0.75rem;
    inset-inline-end: 0.75rem;
    z-index: 120;
}

.hm-hope-auth .navbar-brand {
    margin-bottom: 0.75rem !important;
}

.hm-hope-auth__title {
    font-size: clamp(1.25rem, 2.4vw, 1.75rem);
    line-height: 1.25;
}

.hm-hope-auth__group,
.hm-hope-auth__subtitle {
    font-size: 0.92rem;
}

@media (max-width: 991.98px) {
    .hm-hope-auth__form-col {
        padding: 3.25rem 0.5rem 1rem;
    }

    .hm-hope-auth .auth-card .navbar-brand img {
        height: 36px;
    }

    .hm-hope-auth .hm-auth-copyright {
        margin-top: 1rem;
    }
}

@media (max-width: 767.98px) {
    .hm-hope-auth__row {
        display: block;
    }

    .hm-hope-auth__form-col {
        width: 100%;
        max-width: 100%;
        padding: 4rem 1rem 1.25rem;
    }

    .hm-hope-auth__card .card-body {
        max-height: calc(100dvh - 5.25rem);
    }

    .hm-hope-auth .form-group {
        margin-bottom: 0.85rem;
    }

    .hm-hope-auth .hm-auth-alert {
        margin-bottom: 0.85rem;
        padding: 0.7rem 0.85rem;
        font-size: 0.84rem;
    }

    .hm-auth-lang.hm-auth-lang-hope {
        top: 0.65rem;
        inset-inline-end: 0.65rem;
        transform: scale(0.95);
        transform-origin: top right;
    }

    [dir='rtl'] .hm-auth-lang.hm-auth-lang-hope {
        transform-origin: top left;
    }
}

@media (max-width: 575.98px) {
    .hm-hope-auth .auth-card .navbar-brand img {
        height: 32px;
    }

    .hm-hope-auth__title {
        font-size: 1.2rem;
    }

    .hm-hope-auth__group,
    .hm-hope-auth__subtitle {
        font-size: 0.85rem;
    }
}

@media (max-height: 720px) {
    .hm-hope-auth__form-col {
        padding-top: 3rem;
        padding-bottom: 0.75rem;
    }

    .hm-hope-auth .form-group {
        margin-bottom: 0.7rem;
    }

    .hm-hope-auth .hm-auth-copyright {
        margin-top: 0.75rem;
        font-size: 0.72rem;
    }

    .hm-hope-auth .auth-card .navbar-brand img {
        height: 34px;
    }
}

/* Login verifying overlay */
.hm-auth-verify-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(10, 28, 44, 0.42);
    backdrop-filter: blur(3px);
}

.hm-auth-verify-overlay[hidden] {
    display: none !important;
}

.hm-auth-verify-overlay__card {
    width: min(100%, 360px);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 28px 70px rgba(15, 35, 58, 0.22);
    padding: 2rem 1.5rem 1.75rem;
    text-align: center;
}

.hm-auth-verify-overlay__ring {
    width: 5.5rem;
    height: 5.5rem;
    margin: 0 auto 1.15rem;
    border-radius: 50%;
    border: 3px solid #d9e8f7;
    border-top-color: var(--bs-primary, #3a57e8);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: hm-hope-auth-spin 0.9s linear infinite;
}

.hm-auth-verify-overlay__ring img {
    width: 2.2rem;
    height: 2.2rem;
    object-fit: contain;
    animation: hm-hope-auth-spin-reverse 0.9s linear infinite;
}

.hm-auth-verify-overlay__title {
    margin: 0 0 0.35rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--bs-primary, #3a57e8);
}

.hm-auth-verify-overlay__text {
    margin: 0;
    font-size: 0.86rem;
    color: #64748b;
    line-height: 1.5;
}

@keyframes hm-hope-auth-spin {
    to { transform: rotate(360deg); }
}

@keyframes hm-hope-auth-spin-reverse {
    to { transform: rotate(-360deg); }
}

/* OTP — centered form block (fits fully in LTR + RTL) */
.hm-hope-otp {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    box-sizing: border-box;
    text-align: center;
}

.hm-hope-auth-logos {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    width: 100%;
    max-width: 100%;
    margin-bottom: 1.15rem;
    box-sizing: border-box;
}

.hm-hope-auth-logos__vision {
    height: 40px;
    width: auto;
    max-width: min(140px, 45%);
    object-fit: contain;
}

.hm-hope-auth-logos__hospital {
    height: 32px;
    width: auto;
    max-width: min(180px, 50%);
    object-fit: contain;
}

.hm-hope-otp__intro {
    text-align: center;
    width: 100%;
    max-width: 100%;
    margin-bottom: 1rem;
}

.hm-hope-otp__title {
    margin: 0 0 0.4rem;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.3;
    color: #232d42;
    overflow-wrap: anywhere;
}

.hm-hope-otp__instruction {
    margin: 0;
    font-size: 0.92rem;
    color: #8a92a6;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.hm-hope-otp__destination-wrap {
    margin: 0.4rem 0 0;
}

.hm-hope-otp-destination {
    display: inline-block;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--bs-primary, #3a57e8);
    direction: ltr;
    unicode-bidi: isolate;
    overflow-wrap: anywhere;
}

.hm-hope-otp .hm-auth-alert {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin-bottom: 0.85rem;
    padding: 0.7rem 0.85rem;
    font-size: 0.86rem;
    text-align: start;
}

.hm-hope-otp__form {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.hm-hope-otp-inputs {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.45rem;
    width: 100%;
    max-width: 100%;
    margin: 0.5rem auto 1rem;
    box-sizing: border-box;
}

.hm-hope-otp-digit {
    flex: 0 1 2.75rem;
    width: 2.75rem;
    max-width: calc((100% - 2.25rem) / 6);
    height: 2.85rem;
    padding: 0;
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 2.85rem;
    text-align: center !important;
    direction: ltr;
    unicode-bidi: isolate;
    border-radius: 10px;
    border: 1.5px solid #dee2e6;
    color: #232d42;
    background: #fff;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Beat Hope UI RTL: [dir=rtl] .form-control { text-align: right } */
[dir='rtl'] .hm-hope-otp-digit.form-control,
.hm-hope-otp-digit.form-control {
    text-align: center !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

.hm-hope-otp-digit:focus {
    border-color: var(--bs-primary, #3a57e8);
    box-shadow: 0 0 0 0.2rem rgba(58, 87, 232, 0.15);
}

.hm-hope-otp-digit.is-invalid {
    border-color: #dc3545;
}

.hm-hope-otp__actions {
    display: grid;
    width: 100%;
    max-width: 100%;
}

.hm-hope-otp__submit {
    width: 100%;
    min-height: 2.75rem;
    font-weight: 600;
    border-radius: 10px;
}

.hm-hope-otp__resend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
    max-width: 100%;
    margin-top: 1rem;
}

.hm-hope-otp-timer {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    max-width: 100%;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    background: #f4f7ff;
    border: 1px solid #e8edff;
    color: var(--bs-primary, #3a57e8);
    font-size: 0.86rem;
    line-height: 1.3;
    box-sizing: border-box;
}

.hm-hope-otp-timer i {
    font-size: 0.95rem;
}

.hm-hope-otp-resend .btn-link {
    color: var(--bs-primary, #3a57e8);
    font-weight: 600;
    text-decoration: none;
    padding: 0.35rem 0.5rem;
}

.hm-hope-otp-resend .btn-link:hover {
    text-decoration: underline;
}

.hm-hope-otp__footer {
    width: 100%;
    max-width: 100%;
    margin-top: 1.15rem;
    padding-top: 0.85rem;
    border-top: 1px solid #eef1f6;
    text-align: center;
}

.hm-hope-otp__back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--bs-primary, #3a57e8);
    text-decoration: none;
}

.hm-hope-otp__back:hover {
    text-decoration: underline;
}

@media (max-width: 767.98px) {
    .hm-hope-auth--centered .hm-hope-auth__form-col {
        padding: 4rem 1rem 1.25rem;
        max-height: none;
        min-height: auto;
    }

    .hm-hope-auth--centered,
    .hm-hope-auth--centered .hm-hope-auth__row {
        max-height: none;
        height: auto;
        overflow: visible;
    }

    .hm-hope-auth__center-wrap {
        padding-inline: 0.75rem;
    }

    .hm-hope-otp__title {
        font-size: 1.3rem;
    }
}

@media (max-width: 399.98px) {
    .hm-hope-otp-digit {
        flex-basis: 2.15rem;
        width: 2.15rem;
        height: 2.35rem;
        line-height: 2.35rem;
        font-size: 1rem;
        border-radius: 8px;
    }

    .hm-hope-otp-inputs {
        gap: 0.3rem;
    }

    .hm-hope-auth-logos__vision {
        height: 32px;
    }

    .hm-hope-auth-logos__hospital {
        height: 26px;
    }
}

@media (max-height: 720px) {
    .hm-hope-auth-logos {
        margin-bottom: 0.75rem;
    }

    .hm-hope-otp .hm-auth-alert {
        margin-bottom: 0.55rem;
        padding: 0.55rem 0.75rem;
    }

    .hm-hope-otp__submit {
        min-height: 2.5rem;
    }
}

@media (max-height: 640px) {
    .hm-hope-auth--centered .hm-hope-auth__form-col {
        padding-top: 3.25rem;
    }

    .hm-hope-otp__title {
        font-size: 1.2rem;
    }

    .hm-hope-otp-digit {
        flex-basis: 2.35rem;
        width: 2.35rem;
        height: 2.45rem;
        line-height: 2.45rem;
        font-size: 1.05rem;
    }
}
