/**
 * Shofy OTP Auth - Modal Flip Card UI
 * RTL-first (Persian) · Colors from theme CSS variables (--tp-*)
 */

/* ── RTL base ── */
.shofy-auth-page-shell,
.shofy-auth-modal-overlay,
.shofy-auth-modal {
    direction: rtl;
    text-align: right;
}

/* ── Page shell ── */
body.woocommerce-account:not(.logged-in) .woocommerce-MyAccount-content {
    min-height: 0;
}

body.woocommerce-account:not(.logged-in) .shofy-auth-page-shell .row#customer_login {
    margin: 0;
}

/* ── Modal overlay ── */
.shofy-auth-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: color-mix(in srgb, var(--tp-common-black, #010F1C) 55%, transparent);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

@supports not (background: color-mix(in srgb, black 50%, transparent)) {
    .shofy-auth-modal-overlay {
        background: rgba(1, 15, 28, 0.55);
    }
}

.shofy-auth-modal-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

/* ── Modal card ── */
.shofy-auth-modal {
    position: relative;
    width: 100%;
    max-width: 520px;
    background: var(--tp-common-white, #fff);
    border-radius: 24px;
    box-shadow: 0 24px 48px rgba(1, 15, 28, 0.18);
    overflow: hidden;
    transform: translateY(24px) scale(0.97);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.shofy-auth-modal-overlay.is-open .shofy-auth-modal {
    transform: translateY(0) scale(1);
}

.shofy-auth-modal-close {
    position: absolute;
    top: 20px;
    inset-inline-start: 20px;
    z-index: 10;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tp-grey-1, #F6F7F9);
    border: none;
    border-radius: 50%;
    color: var(--tp-text-body, #55585B);
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.2s;
    padding: 0;
    font-size: 18px;
    line-height: 1;
}

.shofy-auth-modal-close:hover {
    background: var(--tp-grey-2, #ECF2F7);
    color: var(--tp-common-black, #010F1C);
    transform: rotate(90deg);
}

/* ── Flip container ── */
.shofy-auth-flip-container {
    perspective: 1200px;
}

.shofy-auth-flipper {
    position: relative;
    width: 100%;
    min-height: 560px;
    transform-style: preserve-3d;
    transition: transform 0.65s cubic-bezier(0.4, 0.2, 0.2, 1);
}

.shofy-auth-flipper.is-flipped {
    transform: rotateY(-180deg);
}

.shofy-auth-flipper.is-flipping {
    pointer-events: none;
}

/* ── Faces ── */
.shofy-auth-face {
    position: absolute;
    inset: 0;
    width: 100%;
    min-height: 560px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    background: var(--tp-common-white, #fff);
    direction: rtl;
    text-align: right;
}

.shofy-auth-face--phone {
    transform: rotateY(0deg);
}

.shofy-auth-face--email {
    transform: rotateY(180deg);
}

.shofy-auth-face-header,
.shofy-auth-body,
.shofy-auth-footer {
    transform: translateZ(1px);
    -webkit-transform: translateZ(1px);
}

/* ── Face header ── */
.shofy-auth-face-header {
    text-align: center;
    padding: 48px 40px 28px;
    background: linear-gradient(180deg, var(--tp-grey-1, #F6F7F9) 0%, var(--tp-common-white, #fff) 100%);
    border-bottom: 1px solid var(--tp-border-primary, #EAEBED);
}

.shofy-auth-icon {
    width: 76px;
    height: 76px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    color: var(--tp-common-white, #fff);
}

.shofy-auth-icon i {
    display: block;
    font-size: 32px;
    line-height: 1;
    font-style: normal;
}

.shofy-auth-icon--phone {
    background: var(--tp-theme-primary, #0989FF);
    box-shadow: 0 8px 20px rgba(9, 137, 255, 0.25);
}

.shofy-auth-icon--email {
    background: var(--tp-theme-secondary, #821F40);
    box-shadow: 0 8px 20px rgba(130, 31, 64, 0.25);
}

.shofy-auth-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--tp-heading-primary, #010F1C);
    margin: 0 0 8px;
    line-height: 1.4;
}

.shofy-auth-subtitle {
    font-size: 16px;
    color: var(--tp-text-1, #767A7D);
    margin: 0;
    line-height: 1.6;
}

/* ── Body ── */
.shofy-auth-body {
    flex: 1;
    padding: 28px 40px 20px;
    overflow-y: auto;
}

.shofy-auth-email-body {
    padding-top: 20px;
}

/* ── Footer / switch ── */
.shofy-auth-footer {
    padding: 20px 40px 32px;
    border-top: 1px solid var(--tp-border-primary, #EAEBED);
    text-align: center;
}

.shofy-auth-switch {
    display: inline-flex;
    align-items: center;
    flex-direction: row-reverse;
    gap: 10px;
    background: none;
    border: none;
    color: var(--tp-theme-primary, #0989FF);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    padding: 10px 20px;
    border-radius: 10px;
    transition: background 0.2s, color 0.2s;
}

.shofy-auth-switch i {
    font-size: 18px;
    line-height: 1;
    font-style: normal;
}

.shofy-auth-switch:hover {
    background: var(--tp-grey-1, #F6F7F9);
    color: var(--tp-common-black, #010F1C);
}

/* ── Form fields ── */
.shofy-auth-field {
    margin-bottom: 24px;
    text-align: right;
}

.shofy-auth-field label {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: var(--tp-text-body, #55585B);
    margin-bottom: 10px;
    text-align: right;
}

.shofy-auth-input-wrap {
    display: flex;
    flex-direction: row;
    align-items: center;
    border: 1.5px solid var(--tp-border-primary, #EAEBED);
    border-radius: 14px;
    overflow: hidden;
    background: var(--tp-grey-1, #F6F7F9);
    transition: border-color 0.2s, box-shadow 0.2s;
    direction: ltr;
    text-align: left;
}

.shofy-auth-input-wrap:focus-within {
    border-color: var(--tp-theme-primary, #0989FF);
    box-shadow: 0 0 0 3px rgba(9, 137, 255, 0.12);
    background: var(--tp-common-white, #fff);
}

.shofy-auth-input-prefix {
    padding: 0 16px;
    font-size: 16px;
    font-weight: 600;
    color: var(--tp-text-1, #767A7D);
    background: var(--tp-grey-2, #ECF2F7);
    align-self: stretch;
    display: flex;
    align-items: center;
    border-inline-end: 1.5px solid var(--tp-border-primary, #EAEBED);
    flex-shrink: 0;
}

.shofy-auth-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 16px 18px;
    font-size: 18px;
    font-weight: 500;
    color: var(--tp-heading-primary, #010F1C);
    outline: none;
    width: 100%;
    box-sizing: border-box;
    text-align: left;
    direction: ltr;
}

.shofy-auth-input--code {
    text-align: center;
    letter-spacing: 10px;
    font-size: 26px;
    font-weight: 700;
    border: 1.5px solid var(--tp-border-primary, #EAEBED);
    border-radius: 14px;
    background: var(--tp-grey-1, #F6F7F9);
    transition: border-color 0.2s, box-shadow 0.2s;
    direction: ltr;
    width: 100%;
    padding: 18px 20px;
}

.shofy-auth-input--code:focus {
    border-color: var(--tp-theme-primary, #0989FF);
    box-shadow: 0 0 0 3px rgba(9, 137, 255, 0.12);
    background: var(--tp-common-white, #fff);
}

/* ── Primary button ── */
.shofy-auth-btn,
.shofy-otp-btn-send,
.shofy-otp-btn-verify {
    width: 100%;
    padding: 18px 28px !important;
    font-size: 17px !important;
    font-weight: 600 !important;
    background-color: var(--tp-theme-primary, #0989FF) !important;
    color: var(--tp-common-white, #fff) !important;
    border: none !important;
    border-radius: 0 !important;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s !important;
    height: auto !important;
    min-height: 54px;
    line-height: 1.5 !important;
}

.shofy-auth-btn:hover,
.shofy-otp-btn-send:hover,
.shofy-otp-btn-verify:hover,
.shofy-auth-btn:focus,
.shofy-otp-btn-send:focus,
.shofy-otp-btn-verify:focus {
    background-color: var(--tp-common-black, #010F1C) !important;
    color: var(--tp-common-white, #fff) !important;
    transform: translateY(-1px);
}

.shofy-auth-btn:active,
.shofy-otp-btn-send:active,
.shofy-otp-btn-verify:active {
    transform: translateY(0);
}

.shofy-auth-btn:disabled,
.shofy-otp-btn-send:disabled,
.shofy-otp-btn-verify:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none !important;
}

/* ── OTP steps ── */
.shofy-otp-step {
    display: none;
}

.shofy-otp-step.active {
    display: block;
    animation: shofyAuthFadeIn 0.3s ease;
}

@keyframes shofyAuthFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.shofy-otp-sent-msg {
    background: var(--tp-grey-2, #ECF2F7);
    padding: 16px 18px;
    border-radius: 14px;
    font-size: 15px;
    margin-bottom: 24px;
    color: var(--tp-text-body, #55585B);
    line-height: 1.8;
    border: 1px solid var(--tp-border-primary, #EAEBED);
    text-align: right;
}

.shofy-otp-phone-display {
    direction: ltr;
    display: inline-block;
    font-weight: 700;
    color: var(--tp-heading-primary, #010F1C);
    unicode-bidi: embed;
}

.shofy-otp-change-phone {
    display: inline-block;
    margin-inline-start: 10px;
    color: var(--tp-theme-primary, #0989FF);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

.shofy-otp-change-phone:hover {
    text-decoration: underline;
}

.shofy-otp-timer-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-direction: row-reverse;
    font-size: 15px;
    color: var(--tp-text-1, #767A7D);
    margin-bottom: 20px;
    padding: 0 4px;
}

.shofy-otp-resend {
    color: var(--tp-theme-primary, #0989FF);
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
}

.shofy-otp-resend.disabled {
    pointer-events: none;
    opacity: 0.45;
}

/* ── Messages ── */
.shofy-otp-message {
    display: none;
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 15px;
    margin-top: 20px;
    line-height: 1.6;
    text-align: right;
}

.shofy-otp-message.is-error {
    display: block;
    background: #fff5f5;
    color: var(--tp-pink-1, #FD4B6B);
    border: 1px solid #ffcccc;
}

.shofy-otp-message.is-success {
    display: block;
    background: #e6f7ee;
    color: var(--tp-green-1, #31B757);
    border: 1px solid #b7e4c7;
}

.shofy-otp-message.is-loading {
    display: block;
    background: var(--tp-grey-2, #ECF2F7);
    color: var(--tp-text-body, #55585B);
    border: 1px solid var(--tp-border-primary, #EAEBED);
}

/* ── Email panel: inner login/register tabs ── */
.shofy-auth-email-tabs {
    display: flex;
    gap: 0;
    background: var(--tp-grey-1, #F6F7F9);
    border-radius: 12px;
    padding: 5px;
    margin-bottom: 24px;
    direction: rtl;
}

.shofy-auth-email-tab {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    color: var(--tp-text-1, #767A7D);
    cursor: pointer;
    transition: all 0.25s ease;
}

.shofy-auth-email-tab.active {
    background: var(--tp-common-white, #fff);
    color: var(--tp-heading-primary, #010F1C);
    box-shadow: 0 2px 8px rgba(1, 15, 28, 0.08);
}

.shofy-auth-email-panel {
    display: none;
}

.shofy-auth-email-panel.active {
    display: block;
    animation: shofyAuthFadeIn 0.3s ease;
}

/* WooCommerce forms inside modal */
.shofy-auth-email-body .tp-woo-input-field {
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
}

.shofy-auth-email-body .tp-woo-myaccount-login-title {
    display: none;
}

.shofy-auth-email-body .woocommerce-form-row {
    margin-bottom: 20px;
    text-align: right;
}

.shofy-auth-email-body .woocommerce-form-row label {
    font-size: 15px;
    font-weight: 600;
    color: var(--tp-text-body, #55585B);
    margin-bottom: 10px;
    display: block;
    text-align: right;
}

.shofy-auth-email-body .woocommerce-form-row .input-text {
    width: 100%;
    padding: 16px 18px;
    border: 1.5px solid var(--tp-border-primary, #EAEBED);
    border-radius: 0;
    background: var(--tp-grey-1, #F6F7F9);
    font-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    text-align: right;
    direction: rtl;
}

.shofy-auth-email-body .woocommerce-form-row .input-text[type="email"],
.shofy-auth-email-body .woocommerce-form-row .input-text[type="password"],
.shofy-auth-email-body .woocommerce-form-row .input-text#username {
    direction: ltr;
    text-align: left;
}

.shofy-auth-email-body .woocommerce-form-row .input-text:focus {
    border-color: var(--tp-theme-primary, #0989FF);
    box-shadow: 0 0 0 3px rgba(9, 137, 255, 0.12);
    background: var(--tp-common-white, #fff);
    outline: none;
}

.shofy-auth-email-body .woocommerce-form-login__rememberme {
    font-size: 15px;
    color: var(--tp-text-body, #55585B);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    flex-direction: row-reverse;
    justify-content: flex-end;
    gap: 10px;
    text-align: right;
}

.shofy-auth-email-body .woocommerce-form-login__submit,
.shofy-auth-email-body .woocommerce-form-register__submit,
.shofy-auth-email-body .tp-login-btn {
    width: 100%;
    padding: 18px 28px !important;
    font-size: 17px !important;
    font-weight: 600 !important;
    background-color: var(--tp-theme-primary, #0989FF) !important;
    color: var(--tp-common-white, #fff) !important;
    border: none !important;
    border-radius: 0 !important;
    cursor: pointer;
    transition: background-color 0.2s !important;
    height: auto !important;
    min-height: 54px;
    line-height: 1.5 !important;
}

.shofy-auth-email-body .woocommerce-form-login__submit:hover,
.shofy-auth-email-body .woocommerce-form-register__submit:hover,
.shofy-auth-email-body .tp-login-btn:hover {
    background-color: var(--tp-common-black, #010F1C) !important;
    color: var(--tp-common-white, #fff) !important;
}

.shofy-auth-email-body .woocommerce-LostPassword {
    text-align: center;
    margin-top: 16px;
    font-size: 15px;
    position: static !important;
}

.shofy-auth-email-body .woocommerce-LostPassword a {
    color: var(--tp-theme-primary, #0989FF);
    text-decoration: none;
    font-weight: 500;
}

.shofy-auth-email-body .woocommerce-LostPassword a:hover {
    text-decoration: underline;
}

.shofy-auth-email-body .row#customer_login {
    display: block;
    margin: 0;
    direction: rtl;
}

.shofy-auth-email-body .row#customer_login > [class*="col-"] {
    width: 100%;
    max-width: 100%;
    padding: 0;
}

.shofy-auth-email-body .form-row-first,
.shofy-auth-email-body .form-row-last {
    width: 100%;
    float: none;
}

.shofy-auth-email-body .woocommerce-form.login .form-row:not(.form-row-first):not(.form-row-last) {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

/* Body scroll lock */
body.shofy-auth-modal-open {
    overflow: hidden;
}

/* Responsive */
@media (max-width: 575px) {
    .shofy-auth-modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .shofy-auth-modal {
        max-width: 100%;
        border-radius: 24px 24px 0 0;
        max-height: 94vh;
        overflow-y: auto;
    }

    .shofy-auth-flipper {
        min-height: 500px;
    }

    .shofy-auth-face {
        min-height: 500px;
    }

    .shofy-auth-icon i {
        font-size: 30px;
    }

    .shofy-auth-title {
        font-size: 24px;
    }

    .shofy-auth-face-header {
        padding: 40px 28px 24px;
    }

    .shofy-auth-body {
        padding: 24px 28px 16px;
    }

    .shofy-auth-footer {
        padding: 16px 28px 28px;
    }
}

@media (min-width: 576px) {
    .shofy-auth-modal {
        max-width: 540px;
    }

    .shofy-auth-flipper,
    .shofy-auth-face {
        min-height: 580px;
    }
}
