/*
 * BapuTalk authentication UI.
 * One lightweight form language for native pages and the reusable modal.
 */

/* ── Keyframes ─────────────────────────────────────────────────────────── */
@keyframes bt-spin {
    to { transform: rotate(360deg); }
}
@keyframes bt-auth-shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-5px); }
    40%       { transform: translateX(5px); }
    60%       { transform: translateX(-4px); }
    80%       { transform: translateX(4px); }
}
@keyframes bt-auth-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes bt-ripple {
    to { transform: scale(4); opacity: 0; }
}
@keyframes bt-auth-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.55; }
}
.bt-auth-page,
.bt-auth-modal {
    color: #21170f;
    font-family: inherit;
    -webkit-font-smoothing: antialiased;
}

.bt-auth-page *,
.bt-auth-modal * {
    box-sizing: border-box;
}

/* Standalone login and registration pages */
.bt-auth-page {
    min-height: calc(100vh - 76px);
    min-height: calc(100dvh - 76px);
    padding: 42px 20px 56px;
    background: #f5f2ed;
}

.bt-auth-page__inner {
    width: min(520px, 100%);
    margin: 0 auto;
}

.bt-auth-shell {
    overflow: hidden;
    border: 1px solid #ded7ce;
    border-radius: 20px;
    background: #ffffff;
    box-shadow: 0 14px 40px rgba(42, 29, 17, 0.09);
}

.bt-auth-form-panel {
    min-width: 0;
    padding: 38px 40px 34px;
}

.bt-auth-form-panel__inner {
    width: 100%;
    min-width: 0;
}

.bt-auth-mobile-brand,
.bt-auth-modal__brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.bt-auth-mobile-brand {
    margin-bottom: 30px;
    color: #21170f !important;
    font-size: 1rem;
    font-weight: 800;
    text-decoration: none !important;
}

.bt-auth-brand-mark {
    display: inline-flex;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    align-items: center;
    justify-content: center;
    border: 1px solid #a98618;
    border-radius: 10px;
    color: #21170f;
    background: #e1bd4c;
    font-size: 1.15rem;
    font-weight: 850;
    line-height: 1;
}

.bt-auth-heading {
    margin-bottom: 24px;
}

.bt-auth-kicker,
.bt-auth-modal__eyebrow {
    margin: 0 0 7px;
    color: #765d08;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.bt-auth-heading h1 {
    margin: 0;
    color: #21170f;
    font-size: clamp(1.8rem, 4vw, 2.2rem);
    font-weight: 800;
    letter-spacing: -0.035em;
    line-height: 1.13;
}

.bt-auth-heading > p:last-child,
.bt-auth-modal__description,
.bt-auth-recovery-copy p {
    margin: 10px 0 0;
    color: #6c6259;
    font-size: 0.9rem;
    line-height: 1.55;
}

/* Shared alerts */
.bt-auth-alert {
    margin: 0 0 16px;
    padding: 11px 13px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 0.84rem;
    font-weight: 650;
    line-height: 1.45;
}

.bt-auth-alert--danger,
.bt-auth-form-status:not(.d-none) {
    border-color: #efb4ae;
    color: #8e2017;
    background: #fff1ef;
}

.bt-auth-alert--success,
.bt-auth-form-status.bt-auth-alert--success:not(.d-none) {
    border-color: #abd8c3;
    color: #09623e;
    background: #effbf4;
}

.bt-auth-alert--warning {
    border-color: #e8cf97;
    color: #74440f;
    background: #fff8e8;
}

/* Social login */
.bt-auth-social__buttons {
    display: grid;
    gap: 9px;
}

.bt-auth-social-button {
    position: relative;
    display: flex;
    min-height: 48px;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid #d7d0c7;
    border-radius: 11px;
    color: #21170f !important;
    background: #ffffff;
    font-size: 0.88rem;
    font-weight: 750;
    text-decoration: none !important;
    overflow: hidden;
    transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
    -webkit-tap-highlight-color: transparent;
}

.bt-auth-social-button img {
    display: block;
    width: 20px;
    height: 20px;
    object-fit: contain;
    transition: transform 0.18s ease;
}

/* Ripple element injected by JS */
.bt-auth-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(42, 29, 17, 0.1);
    transform: scale(0);
    animation: bt-ripple 0.5s linear;
    pointer-events: none;
}

/* Social button — loading state */
.bt-auth-social-button.is-loading {
    pointer-events: none;
    cursor: default;
    opacity: 0.75;
}

.bt-auth-social-button.is-loading .bt-auth-social-spinner {
    display: inline-block !important;
}

.bt-auth-social-spinner {
    display: none;
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    border: 2px solid rgba(42, 29, 17, 0.2);
    border-top-color: #21170f;
    border-radius: 50%;
    animation: bt-spin 0.6s linear infinite;
}

.bt-auth-divider {
    display: flex;
    align-items: center;
    gap: 11px;
    margin: 18px 0;
    color: #81766c;
    font-size: 0.71rem;
    font-weight: 750;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.bt-auth-divider::before,
.bt-auth-divider::after {
    height: 1px;
    flex: 1;
    background: #e2dcd4;
    content: "";
}

/* Shared forms */
.bt-auth-form {
    display: grid;
    gap: 16px;
    margin: 0;
}

.bt-auth-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 13px;
}

.bt-auth-field {
    min-width: 0;
}

.bt-auth-field > label,
.bt-auth-label-row label {
    display: block;
    margin: 0 0 7px;
    color: #3b3027;
    font-size: 0.81rem;
    font-weight: 760;
    line-height: 1.35;
}

.bt-auth-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.bt-auth-label-row a,
.bt-auth-text-button,
.bt-auth-switch a {
    color: #705807;
    font-size: 0.8rem;
    font-weight: 750;
    text-decoration: none;
}

.bt-auth-input {
    display: block;
    width: 100%;
    min-height: 50px;
    padding: 12px 13px;
    border: 1px solid #cfc7bd;
    border-radius: 10px;
    outline: 0;
    color: #21170f;
    background: #ffffff;
    background-clip: padding-box;
    font: inherit;
    font-size: 0.94rem;
    line-height: 1.4;
}

.bt-auth-input:focus {
    border-color: #977817;
    box-shadow: 0 0 0 3px rgba(168, 132, 17, 0.17);
}

.bt-auth-input.is-invalid,
.bt-auth-field .is-invalid {
    border-color: #b42318;
}

.bt-auth-input.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.13);
}

.bt-auth-password-wrap {
    position: relative;
}

.bt-auth-password-wrap .bt-auth-input {
    padding-right: 68px;
}

.bt-auth-password-toggle {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 58px;
    min-height: 42px;
    padding: 7px 9px;
    border: 0;
    border-radius: 8px;
    color: #61564c;
    background: transparent;
    font-size: 0.75rem;
    font-weight: 750;
    cursor: pointer;
}

.bt-auth-password-toggle:focus-visible,
.bt-auth-text-button:focus-visible,
.bt-auth-tab:focus-visible,
.bt-auth-modal__close:focus-visible,
.bt-auth-social-button:focus-visible,
.bt-auth-submit:focus-visible,
.bt-auth-mobile-brand:focus-visible,
.bt-auth-check input:focus-visible {
    outline: 3px solid rgba(151, 120, 23, 0.38);
    outline-offset: 2px;
}

.bt-auth-hint {
    display: block;
    margin-top: 5px;
    color: #756b62;
    font-size: 0.72rem;
}

.bt-auth-check {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr);
    align-items: start;
    gap: 9px;
    margin: 0;
    color: #62584f;
    font-size: 0.79rem;
    font-weight: 550;
    line-height: 1.5;
    cursor: pointer;
}

.bt-auth-check input {
    width: 18px;
    height: 18px;
    margin: 2px 0 0;
    accent-color: #8b6c0d;
}

.bt-auth-check a {
    color: #705807;
    font-weight: 750;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.bt-auth-submit {
    display: inline-flex;
    width: 100%;
    min-height: 52px;
    align-items: center;
    justify-content: center;
    gap: 11px;
    padding: 12px 18px;
    border: 1px solid #21170f;
    border-radius: 11px;
    color: #ffffff;
    background: #21170f;
    font-size: 0.9rem;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.1s ease, box-shadow 0.18s ease;
    position: relative;
    overflow: hidden;
}

.bt-auth-submit:active:not(:disabled) {
    transform: scale(0.98);
}

.bt-auth-submit:disabled {
    cursor: wait;
    opacity: 0.8;
}

/* Spinner shown inside submit button while busy */
.bt-auth-submit__spinner {
    display: none;
    width: 17px;
    height: 17px;
    flex: 0 0 17px;
    border: 2.5px solid rgba(255, 255, 255, 0.35);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: bt-spin 0.6s linear infinite;
}

.bt-auth-submit[aria-busy="true"] .bt-auth-submit__spinner {
    display: inline-block;
}

.bt-auth-submit[aria-busy="true"] .bt-auth-submit__label,
.bt-auth-submit[aria-busy="true"] .bt-auth-submit__arrow {
    opacity: 0.7;
}

.bt-auth-submit__arrow {
    color: #e1bd4c;
    font-size: 1.05rem;
    line-height: 1;
    transition: transform 0.18s ease;
}

.bt-auth-switch {
    margin: 0;
    color: #746a61;
    font-size: 0.81rem;
    text-align: center;
}

.bt-auth-switch a,
.bt-auth-text-button--strong {
    margin-left: 3px;
    color: #675005;
    font-weight: 800;
}

.bt-auth-text-button {
    min-height: 30px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.bt-auth-security-note,
.bt-auth-modal__footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #746b62;
    font-size: 0.72rem;
    line-height: 1.4;
}

.bt-auth-security-note {
    margin-top: 22px;
}

.bt-auth-security-note__icon {
    position: relative;
    display: inline-block;
    width: 13px;
    height: 11px;
    flex: 0 0 13px;
    border-radius: 3px;
    background: #087a4d;
}

.bt-auth-security-note__icon::before {
    position: absolute;
    top: -6px;
    left: 3px;
    width: 7px;
    height: 8px;
    border: 2px solid #087a4d;
    border-bottom: 0;
    border-radius: 7px 7px 0 0;
    content: "";
}

.invalid-feedback {
    margin-top: 5px;
    color: #b42318;
    font-size: 0.75rem;
    line-height: 1.4;
}

.bt-auth-form .invalid-feedback {
    display: block;
}

.bt-auth-captcha {
    display: block;
    max-width: 100%;
    overflow-x: hidden;
}

.bt-auth-captcha .captcha-field {
    width: 100%;
    max-width: 100%;
    margin-right: 0;
    margin-left: 0;
    padding-right: 0;
    padding-left: 0;
}

.bt-auth-recovery-copy {
    margin-bottom: 2px;
}

.bt-auth-recovery-copy h3 {
    margin: 0;
    color: #21170f;
    font-size: 1.25rem;
    font-weight: 800;
}

/* Reusable login/register modal */
.bt-auth-modal {
    z-index: 1080;
    padding: 0 !important;
}

.bt-auth-modal .modal-dialog {
    width: min(94vw, 520px) !important;
    max-width: 520px !important;
    margin-right: auto;
    margin-left: auto;
}

.bt-auth-modal .modal-content {
    position: relative;
    display: flex;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #d9d1c7;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 22px 60px rgba(26, 17, 10, 0.25);
}

.bt-auth-modal__header {
    display: flex;
    flex: 0 0 auto;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 21px 22px 8px;
}

.bt-auth-modal__brand .bt-auth-brand-mark {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
}

.bt-auth-modal__eyebrow {
    display: block;
    margin-bottom: 2px;
    font-size: 0.64rem;
}

.bt-auth-modal__header h2 {
    margin: 0;
    color: #21170f;
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    line-height: 1.2;
}

.bt-auth-modal__close {
    display: inline-grid;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 10px;
    color: #554b42;
    background: #f3f0ec;
    font-size: 1.45rem;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
}

.bt-auth-modal .modal-body {
    min-height: 0;
    max-height: none;
    flex: 1 1 auto;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 5px 22px 22px !important;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.bt-auth-modal__description {
    margin: 0 0 15px;
}

.bt-auth-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3px;
    margin-bottom: 18px;
    padding: 3px;
    border: 1px solid #ddd6cd;
    border-radius: 11px;
    background: #f1ede8;
}

.bt-auth-tab {
    min-height: 42px;
    padding: 8px 11px;
    border: 0;
    border-radius: 8px;
    color: #685e55;
    background: transparent;
    font-size: 0.79rem;
    font-weight: 800;
    cursor: pointer;
    transition: color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.bt-auth-tab.is-active {
    color: #21170f;
    background: #ffffff;
    box-shadow: 0 1px 4px rgba(42, 29, 17, 0.1);
}

/* Panel fade-in when tab switches */
.bt-auth-section-visible {
    animation: bt-auth-fade-in 0.22s ease both;
}

/* Shake the form on validation/server error */
.bt-auth-shake {
    animation: bt-auth-shake 0.38s ease;
}

.bt-auth-modal .bt-auth-form {
    gap: 15px;
}

.bt-auth-modal .bt-auth-form-grid {
    grid-template-columns: 1fr;
    gap: 15px;
}

.bt-auth-modal .bt-auth-input {
    min-height: 48px;
}

.bt-auth-modal__footer {
    min-height: 48px;
    flex: 0 0 auto;
    padding: 11px 20px;
    border-top: 1px solid #e2dcd4;
    background: #f8f6f3;
}

[dir="rtl"] .bt-auth-password-wrap .bt-auth-input {
    padding-right: 13px;
    padding-left: 68px;
}

[dir="rtl"] .bt-auth-password-toggle {
    right: auto;
    left: 4px;
}

/* Hover feedback is reserved for devices that actually have a pointer. */
@media (hover: hover) and (pointer: fine) {
    .bt-auth-mobile-brand:hover,
    .bt-auth-label-row a:hover,
    .bt-auth-text-button:hover,
    .bt-auth-switch a:hover {
        color: #4f3d04 !important;
        text-decoration: none;
    }

    .bt-auth-social-button:hover {
        border-color: #bdb3a7;
        background: #faf8f5;
        box-shadow: 0 2px 8px rgba(42, 29, 17, 0.08);
        transform: translateY(-1px);
    }

    .bt-auth-social-button:hover img {
        transform: scale(1.08);
    }

    .bt-auth-password-toggle:hover,
    .bt-auth-modal__close:hover {
        color: #21170f;
        background: #ebe6e0;
    }

    .bt-auth-submit:hover:not(:disabled) {
        color: #ffffff;
        background: #38291c;
        box-shadow: 0 4px 14px rgba(33, 23, 15, 0.3);
        transform: translateY(-1px);
    }

    .bt-auth-submit:hover:not(:disabled) .bt-auth-submit__arrow {
        transform: translateX(3px);
    }

    .bt-auth-tab:not(.is-active):hover {
        color: #3b3027;
        background: rgba(255, 255, 255, 0.5);
    }
}

/* Tablet and mobile: true bottom sheet with an independently scrollable body. */
@media (max-width: 991.98px) {
    .bt-auth-page {
        min-height: calc(100vh - 64px);
        min-height: calc(100dvh - 64px);
        padding: 28px 18px calc(80px + env(safe-area-inset-bottom, 0px));
    }

    .bt-auth-page__inner {
        width: min(620px, 100%);
    }

    .bt-auth-form-panel {
        padding: 34px 36px 32px;
    }

    .bt-auth-modal {
        overflow: hidden !important;
    }

    .bt-auth-modal .modal-dialog,
    .bt-auth-modal .modal-dialog-centered {
        display: flex;
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100%;
        min-height: 100%;
        align-items: flex-end;
        margin: 0 !important;
        padding: 0;
    }

    .bt-auth-modal .modal-dialog-centered::before {
        display: none;
    }

    .bt-auth-modal .modal-content {
        width: 100%;
        height: auto;
        min-height: 0;
        max-height: min(88vh, 780px);
        max-height: min(88dvh, 780px);
        border-right: 0;
        border-bottom: 0;
        border-left: 0;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -14px 44px rgba(26, 17, 10, 0.18);
    }

    .bt-auth-modal__header {
        padding: 18px 20px 7px;
    }

    .bt-auth-modal .modal-body {
        max-height: none;
        flex: 0 1 auto;
        padding: 5px 20px 22px !important;
        scrollbar-gutter: stable;
    }

    .bt-auth-modal__footer {
        padding-bottom: calc(11px + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 575.98px) {
    .bt-auth-page {
        padding: 12px 10px calc(76px + env(safe-area-inset-bottom, 0px));
        background: #f5f2ed;
    }

    .bt-auth-shell {
        border-radius: 16px;
        box-shadow: 0 8px 24px rgba(42, 29, 17, 0.07);
    }

    .bt-auth-form-panel {
        padding: 24px 18px 26px;
    }

    .bt-auth-mobile-brand {
        margin-bottom: 22px;
    }

    .bt-auth-heading {
        margin-bottom: 21px;
    }

    .bt-auth-heading h1 {
        font-size: 1.72rem;
    }

    .bt-auth-heading > p:last-child {
        font-size: 0.86rem;
    }

    .bt-auth-form-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .bt-auth-security-note {
        align-items: flex-start;
        justify-content: flex-start;
        text-align: left;
    }

    .bt-auth-modal .modal-content {
        height: auto;
        min-height: 0;
        max-height: calc(100vh - 6px);
        max-height: calc(100dvh - 6px);
        border-radius: 18px 18px 0 0;
    }

    .bt-auth-modal__header {
        padding: 15px 16px 6px;
    }

    .bt-auth-modal .modal-body {
        padding: 4px 16px 20px !important;
        scrollbar-gutter: auto;
    }

    .bt-auth-modal__description {
        margin-bottom: 13px;
        font-size: 0.83rem;
    }

    .bt-auth-modal__footer {
        padding-right: 16px;
        padding-left: 16px;
    }
}

@media (max-width: 359.98px) {
    .bt-auth-modal .modal-body {
        padding-right: 8px !important;
        padding-left: 8px !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bt-auth-page *,
    .bt-auth-modal * {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
