/* ==========================================================================
   WC Mobile OTP Login — Front-end styles
   ========================================================================== */

/* ── Variables ────────────────────────────────────────────────────────────── */
:root {
    --wcmol-primary:   #7f54b3;
    --wcmol-primary-h: #6b44a0;
    --wcmol-radius:    10px;
    --wcmol-border:    #e2e2e2;
    --wcmol-shadow:    0 2px 18px rgba(0,0,0,.08);
    --wcmol-success-bg: #d4edda;
    --wcmol-success-fg: #155724;
    --wcmol-error-bg:   #f8d7da;
    --wcmol-error-fg:   #721c24;
}

/* ── Wrapper ──────────────────────────────────────────────────────────────── */
.wcmol-wrap {
    background: #fff;
    border: 1px solid var(--wcmol-border);
    border-radius: var(--wcmol-radius);
    padding: 28px 32px;
    max-width: 440px;
    margin: 16px auto 24px;
    box-shadow: var(--wcmol-shadow);
    box-sizing: border-box;
    font-family: inherit;
}

.wcmol-wrap[data-context="checkout"] {
    border-color: #c9b8e8;
    background: #faf7ff;
    max-width: 100%;
    margin-bottom: 28px;
}

.wcmol-wrap[data-context="myaccount"] {
    border-style: dashed;
    max-width: 100%;
    margin-top: 0;
}

/* Inside popup — no border/shadow (popup box handles it) */
#wcmol-popup-box .wcmol-wrap {
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
    max-width: 100%;
}

/* ── Typography ───────────────────────────────────────────────────────────── */
.wcmol-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 6px;
    color: #1a1a1a;
    line-height: 1.3;
}

.wcmol-subtitle {
    font-size: 14px;
    color: #666;
    margin: 0 0 20px;
    line-height: 1.5;
}

/* ── Phone row ────────────────────────────────────────────────────────────── */
.wcmol-phone-row {
    display: flex;
    align-items: stretch;
    border: 2px solid var(--wcmol-border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 14px;
    transition: border-color .2s;
}

.wcmol-phone-row:focus-within {
    border-color: var(--wcmol-primary);
}

.wcmol-cc {
    display: flex;
    align-items: center;
    padding: 0 14px;
    background: #f4f4f4;
    border-right: 1px solid var(--wcmol-border);
    font-weight: 600;
    font-size: 15px;
    color: #333;
    white-space: nowrap;
    user-select: none;
}

.wcmol-phone-input {
    flex: 1;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    padding: 0 14px;
    font-size: 17px;
    height: 50px;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
    color: inherit;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.wcmol-btn {
    width: 100%;
    padding: 14px 20px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 8px !important;
    cursor: pointer;
    transition: background .2s, opacity .2s, transform .1s;
    margin-top: 2px;
    border: none;
    -webkit-appearance: none;
}

.wcmol-btn:disabled,
.wcmol-btn[disabled] {
    opacity: .55;
    cursor: not-allowed;
}

.wcmol-btn:not(:disabled):active {
    transform: scale(.98);
}

/* ── OTP digit boxes ──────────────────────────────────────────────────────── */
.wcmol-digits {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 18px 0 14px;
}

.wcmol-digit {
    width: 50px !important;
    height: 58px !important;
    text-align: center;
    font-size: 24px !important;
    font-weight: 700;
    border: 2px solid var(--wcmol-border) !important;
    border-radius: 8px !important;
    outline: none !important;
    box-shadow: none !important;
    caret-color: transparent;
    transition: border-color .2s, transform .1s, background .2s;
    -webkit-appearance: none;
    appearance: none;
    padding: 0 !important;
    background: #fff;
    color: #1a1a1a;
}

.wcmol-digit:focus {
    border-color: var(--wcmol-primary) !important;
    transform: scale(1.06);
}

.wcmol-digit.is-filled {
    border-color: var(--wcmol-primary) !important;
    background: #f8f4ff;
}

/* ── Sent line & badge ────────────────────────────────────────────────────── */
.wcmol-sent-line {
    font-size: 14px;
    color: #555;
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.wcmol-phone-echo {
    font-weight: 700;
    color: #222;
}

.wcmol-change-phone {
    background: none;
    border: none;
    color: var(--wcmol-primary);
    font-size: 13px;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    font-family: inherit;
}

.wcmol-user-badge {
    font-size: 13px;
    font-weight: 600;
    padding: 7px 12px;
    border-radius: 6px;
    text-align: center;
    margin-bottom: 4px;
}

.wcmol-user-badge.is-new      { background: #fff3cd; color: #856404; }
.wcmol-user-badge.is-existing { background: #d1ecf1; color: #0c5460; }

/* ── Resend ───────────────────────────────────────────────────────────────── */
.wcmol-resend {
    text-align: center;
    margin-top: 14px;
    min-height: 24px;
    font-size: 13px;
}

.wcmol-resend-timer { color: #999; }

.wcmol-resend-btn {
    background: none;
    border: none;
    color: var(--wcmol-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    font-family: inherit;
}

/* ── Messages ─────────────────────────────────────────────────────────────── */
.wcmol-msg {
    margin-top: 12px;
    padding: 9px 14px;
    border-radius: 6px;
    font-size: 14px;
    display: none;
    line-height: 1.5;
}

.wcmol-msg.is-success { display: block; background: var(--wcmol-success-bg); color: var(--wcmol-success-fg); }
.wcmol-msg.is-error   { display: block; background: var(--wcmol-error-bg);   color: var(--wcmol-error-fg);   }

/* ── Required notice (checkout context) ───────────────────────────────────── */
.wcmol-required-notice {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-left: 4px solid #f0a500;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #664d03;
    margin-bottom: 18px;
    line-height: 1.5;
}

/* ── Hide WooCommerce built-in "Create account" block on checkout ──────────
   Our OTP form handles registration — WC's own block is redundant and
   would confuse customers. We hide it via CSS as a belt-and-suspenders guard
   alongside the PHP filter that removes the fields.
   ──────────────────────────────────────────────────────────────────────── */
.woocommerce-checkout .create-account,
.woocommerce-checkout .woocommerce-account-fields,
.woocommerce-checkout #createaccount,
.woocommerce-checkout .create-account-checkbox,
.woocommerce-checkout [name="createaccount"],
.woocommerce-checkout label[for="createaccount"],
.woocommerce-checkout #account_password_field,
.woocommerce-checkout #account_password-2_field,
.woocommerce-checkout #account_username_field,
.woocommerce-checkout .woocommerce-password-strength,
.woocommerce-checkout .woocommerce-password-hint {
    display: none !important;
}


.wcmol-or-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0 16px;
    color: #aaa;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.wcmol-or-divider::before,
.wcmol-or-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--wcmol-border);
}

/* ── Popup overlay ────────────────────────────────────────────────────────── */
#wcmol-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.52);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(2px);
}

#wcmol-popup-box {
    background: #fff;
    border-radius: 16px;
    padding: 36px 32px 28px;
    max-width: 440px;
    width: 100%;
    position: relative;
    box-shadow: 0 12px 48px rgba(0,0,0,.2);
    animation: wcmol-pop-in .22s cubic-bezier(.34,1.56,.64,1);
}

@keyframes wcmol-pop-in {
    from { opacity: 0; transform: scale(.93) translateY(-8px); }
    to   { opacity: 1; transform: scale(1)   translateY(0);    }
}

#wcmol-popup-close {
    position: absolute;
    top: 14px;
    right: 16px;
    background: #f0f0f0;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 20px;
    line-height: 32px;
    text-align: center;
    cursor: pointer;
    color: #555;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
}

#wcmol-popup-close:hover { background: #ddd; }

/* ── Checkout highlight pulse (when WC error fires) ───────────────────────── */
@keyframes wcmol-pulse {
    0%   { box-shadow: 0 0 0 0   rgba(127,84,179,.5); }
    50%  { box-shadow: 0 0 0 10px rgba(127,84,179,.0); }
    100% { box-shadow: 0 0 0 0   rgba(127,84,179,.0); }
}

.wcmol-wrap.wcmol-highlight {
    animation: wcmol-pulse 1s ease 2;
    border-color: var(--wcmol-primary) !important;
}

/* ── Shake animation (wrong OTP) ──────────────────────────────────────────── */
@keyframes wcmol-shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-5px); }
    40%       { transform: translateX(5px); }
    60%       { transform: translateX(-4px); }
    80%       { transform: translateX(4px); }
}

.wcmol-digit.is-shake {
    animation: wcmol-shake .45s ease;
    border-color: var(--wcmol-error-fg) !important;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .wcmol-wrap              { padding: 20px 14px; }
    #wcmol-popup-box         { padding: 28px 18px 22px; }

    .wcmol-digit {
        width: 42px !important;
        height: 50px !important;
        font-size: 20px !important;
    }

    .wcmol-digits { gap: 6px; }
}
