/* ملف: assets/css/tm-otp-style.css */
/* Tajawal font: enqueue via wp_enqueue_style in PHP (do not @import here) */

:root {
    /* الألوان الجديدة: تدرجات الأرجواني الملكي */
    --tm-p: #8e44ad;       /* أرجواني أساسي */
    --tm-p2: #6c3483;      /* أرجواني داكن */
    --tm-p3: #9b59b6;      /* أرجواني فاتح */
    --tm-accent: #d7bde2;  /* ليلكي ناعم */
    --tm-ok: #27ae60;      /* أخضر للنجاح */
    --tm-ok2: #1e8449;
    --tm-err: #e74c3c;
    --tm-err2: #c0392b;
    --tm-bg: #ffffff;
    --tm-surface: #fdfaff;  /* خلفية مائلة للبنفسجي البارد */
    --tm-border: #ebdef0;  /* حدود متناسقة مع الأرجواني */
    --tm-text: #2e1a47;    /* نص داكن جداً بلمحة أرجوانية */
    --tm-muted: #8e849b;
    /* تحديث الظلال لتكون بتوهج أرجواني بدلاً من الأزرق */
    --tm-shadow: 0 20px 60px rgba(142, 68, 173, 0.12), 0 4px 16px rgba(142, 68, 173, 0.06);
    --tm-r: 20px;
    --tm-r-sm: 12px;
    --tm-ease: cubic-bezier(.4,0,.2,1);
}

/* عزل الحاوية الرئيسية لمنع التداخل */
#tm-otp-main-container {
    all: initial;
    /* all:initial يصفّر --tm-*؛ نعيد تعريفها هنا حتى يرثها الأبناء */
    --tm-p: #8e44ad;
    --tm-p2: #6c3483;
    --tm-p3: #9b59b6;
    --tm-accent: #d7bde2;
    --tm-ok: #27ae60;
    --tm-ok2: #1e8449;
    --tm-err: #e74c3c;
    --tm-err2: #c0392b;
    --tm-bg: #ffffff;
    --tm-surface: #fdfaff;
    --tm-border: #ebdef0;
    --tm-text: #2e1a47;
    --tm-muted: #8e849b;
    --tm-shadow: 0 20px 60px rgba(142, 68, 173, 0.12), 0 4px 16px rgba(142, 68, 173, 0.06);
    --tm-r: 20px;
    --tm-r-sm: 12px;
    --tm-ease: cubic-bezier(.4, 0, .2, 1);
    display: block;
    position: relative !important;
    font-family: 'Tajawal', sans-serif !important;
    overflow: hidden;
    box-sizing: border-box;
}
#tm-otp-popup-main-container.rtl { direction: rtl !important; text-align: right !important; }
#tm-otp-popup-main-container.ltr { direction: ltr !important; text-align: left !important; }

#tm-otp-popup-main-container * {
    box-sizing: border-box;
    font-family: 'Tajawal', sans-serif !important;
}

#tm-otp-popup-main-container svg,
#tm-otp-popup-main-container svg * {
    font-family: inherit !important;
}


.tm-otp-main-container.rtl { direction: rtl !important; text-align: right !important; }
.tm-otp-main-container.ltr { direction: ltr !important; text-align: left !important; }

.tm-otp-main-container * {
    box-sizing: border-box;
    font-family: 'Tajawal', sans-serif !important;
}

/* SVG stroke-draw breaks under RTL + border-box (often only the top half paints). */
.tm-otp-main-container svg,
.tm-otp-main-container svg * {
    box-sizing: content-box !important;
    direction: ltr !important;
    font-family: inherit !important;
}

/* التصميم الرئيسي للبطاقة */
.tm-otp-main-box {
    max-width: 420px !important;
    margin: 36px auto !important;
    padding: 0 !important;
    background: var(--tm-bg) !important;
    border: 1.5px solid var(--tm-border) !important;
    border-radius: var(--tm-r) !important;
    box-shadow: var(--tm-shadow) !important;
    position: relative !important;
    overflow: hidden !important;
    display: block !important;
}

/* التدرج العلوي للبطاقة */
.tm-otp-main-box::before {
    content: '';
    display: block;
    height: 5px;
    background: linear-gradient(90deg, var(--tm-p) 0%, var(--tm-p3) 50%, var(--tm-p2) 100%);
}

.tm-otp-ajax-form,
.tm-otp-main-container .tm-otp-chooser-wrap {
    padding: 28px 24px 22px !important;
    margin: 0 !important;
}

/* الأيقونة بتوهج أرجواني */
.tm-otp-icon {
    width: 48px !important;
    height: 48px !important;
    background: linear-gradient(135deg, var(--tm-p), var(--tm-p2)) !important;
    border-radius: 16px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 22px !important;
    line-height: 1 !important;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif !important;
    margin: 0 auto 14px !important;
    box-shadow: 0 8px 20px rgba(142, 68, 173, 0.25) !important;
    animation: tm-ping 2.4s ease-in-out infinite;
}

.tm-otp-main-container .tm-otp-step-title {
    text-align: center !important;
    color: var(--tm-text) !important;
    font-weight: 800 !important;
    font-size: 21px !important;
    line-height: 1.35 !important;
    margin: 0 0 6px !important;
    display: block !important;
}

.tm-otp-main-container .tm-otp-step-subtitle {
    text-align: center !important;
    color: var(--tm-muted) !important;
    font-size: 13.5px !important;
    line-height: 1.55 !important;
    max-width: 100% !important;
    margin: 0 auto 24px !important;
    display: block !important;
}

/* تنويه السبام (يظهر في قسم الإيميل فقط) */
.tm-otp-main-container .tm-otp-spam-hint {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 9px !important;
    text-align: center !important;
    background: var(--tm-surface) !important;
    border: 1px solid var(--tm-border) !important;
    border-radius: var(--tm-r-sm) !important;
    padding: 11px 14px !important;
    margin: -8px 0 22px !important;
    font-size: 12.5px !important;
    line-height: 1.6 !important;
    color: var(--tm-muted) !important;
}
.tm-otp-main-container .tm-otp-spam-hint-icon {
    font-size: 15px !important;
    line-height: 1.4 !important;
    flex-shrink: 0 !important;
}

/* المدخلات — نفس ارتفاع الزر الأساسي */
.tm-otp-main-container .tm-otp-input-field,
.tm-otp-main-container .tm-otp-select-field {
    width: 100% !important;
    height: auto !important;
    min-height: 50px !important;
    padding: 14px 16px !important;
    border: 2px solid var(--tm-border) !important;
    border-radius: var(--tm-r-sm) !important;
    background: var(--tm-surface) !important;
    color: var(--tm-text) !important;
    font-size: 16px !important;
    line-height: 1.35 !important;
    outline: none !important;
    margin: 0 !important;
    box-shadow: none !important;
    appearance: none !important;
}

/* التركيز على الحقل (Focus) */
.tm-otp-main-container .tm-otp-input-field:focus {
    border-color: var(--tm-p) !important;
    background: #fff !important;
    box-shadow: 0 0 0 3px rgba(142, 68, 173, 0.1) !important;
}

/* Password field with show/hide toggle */
.tm-otp-main-container .tm-otp-password-wrap {
    position: relative !important;
    display: block !important;
    width: 100% !important;
}

.tm-otp-main-container .tm-otp-password-wrap .tm-otp-password-input {
    padding-inline-end: 46px !important;
}

.tm-otp-main-container .tm-otp-password-toggle {
    position: absolute !important;
    top: 50% !important;
    inset-inline-end: 8px !important;
    transform: translateY(-50%) !important;
    width: 34px !important;
    height: 34px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 8px !important;
    background: transparent !important;
    color: var(--tm-muted) !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: color 0.15s ease, background 0.15s ease !important;
}

.tm-otp-main-container .tm-otp-password-toggle:hover,
.tm-otp-main-container .tm-otp-password-toggle:focus {
    color: var(--tm-p) !important;
    background: rgba(142, 68, 173, 0.08) !important;
    outline: none !important;
}

.tm-otp-main-container .tm-otp-password-toggle-icon {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 0 !important;
}

.tm-otp-main-container .tm-otp-password-toggle-icon[hidden] {
    display: none !important;
}

/* كود الـ OTP */
/* حاوية مربعات رمز التحقق الأربعة */
.tm-otp-main-container .tm-otp-code-boxes {
    display: flex !important;
    justify-content: center !important;
    gap: 10px !important;
    direction: ltr !important;
    margin: 4px 0 !important;
}

.tm-otp-main-container .tm-otp-code-box {
    width: 58px !important;
    height: 64px !important;
    padding: 0 !important;
    text-align: center !important;
    font-size: 28px !important;
    font-weight: 800 !important;
    font-family: 'Tajawal', sans-serif !important;
    color: var(--tm-p) !important;
    background: linear-gradient(135deg, #fdfaff, #f5eef8) !important;
    border: 2px solid var(--tm-border) !important;
    border-radius: var(--tm-r-sm) !important;
    transition: all 0.2s ease !important;
    box-shadow: none !important;
    -moz-appearance: textfield !important;
}

.tm-otp-main-container .tm-otp-code-box::-webkit-outer-spin-button,
.tm-otp-main-container .tm-otp-code-box::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
}

.tm-otp-main-container .tm-otp-code-box:focus {
    outline: none !important;
    border-color: var(--tm-p) !important;
    background: #fff !important;
    box-shadow: 0 0 0 4px rgba(142, 68, 173, 0.12) !important;
    transform: translateY(-1px) !important;
}

/* نجاح التحقق: خانات خضراء */
.tm-otp-main-container .tm-otp-code-box.is-success {
    border-color: var(--tm-ok) !important;
    background: #eafaf1 !important;
    color: var(--tm-ok2) !important;
    box-shadow: 0 0 0 4px rgba(39, 174, 96, 0.15) !important;
    transform: scale(1.04) !important;
}

/* خطأ التحقق: خانات حمراء */
.tm-otp-main-container .tm-otp-code-box.is-error {
    border-color: #e74c3c !important;
    background: #fdedec !important;
    color: #c0392b !important;
    box-shadow: 0 0 0 4px rgba(231, 76, 60, 0.14) !important;
}

/* اهتزاز عند الخطأ — keep !important so reduced-motion / theme CSS cannot zero it */
.tm-otp-main-container .tm-otp-code-boxes.is-shake {
    animation: tm-otp-shake 0.55s var(--tm-ease, cubic-bezier(.4, 0, .2, 1)) both !important;
    overflow: visible !important;
    will-change: transform;
}

@keyframes tm-otp-shake {
    0%, 100% { transform: translate3d(0, 0, 0); }
    15% { transform: translate3d(-8px, 0, 0); }
    30% { transform: translate3d(8px, 0, 0); }
    45% { transform: translate3d(-6px, 0, 0); }
    60% { transform: translate3d(6px, 0, 0); }
    75% { transform: translate3d(-3px, 0, 0); }
    90% { transform: translate3d(3px, 0, 0); }
}

.tm-otp-main-container .tm-otp-local-panel[hidden] {
    display: none !important;
}
.tm-otp-main-container .tm-otp-local-panel.is-active {
    display: block !important;
}
.tm-otp-main-container .tm-otp-pw-reg-panel[hidden] {
    display: none !important;
}
.tm-otp-main-container .tm-otp-pw-reg-panel.is-active {
    display: block !important;
}
.tm-otp-main-container .tm-otp-code-boxes {
    position: relative !important;
    min-height: 64px !important;
    align-items: center !important;
}

.tm-otp-main-container .tm-otp-ajax-form {
    position: relative !important;
}

.tm-otp-main-container .tm-otp-ajax-form.is-success-fade .tm-otp-icon,
.tm-otp-main-container .tm-otp-ajax-form.is-success-fade .tm-otp-step-title,
.tm-otp-main-container .tm-otp-ajax-form.is-success-fade .tm-otp-step-subtitle,
.tm-otp-main-container .tm-otp-ajax-form.is-success-fade .tm-otp-spam-hint,
.tm-otp-main-container .tm-otp-ajax-form.is-success-fade .tm-otp-field-wrapper,
.tm-otp-main-container .tm-otp-ajax-form.is-success-fade .tm-otp-code-boxes,
.tm-otp-main-container .tm-otp-ajax-form.is-success-fade .tm-otp-btn-main,
.tm-otp-main-container .tm-otp-ajax-form.is-success-fade .tm-otp-resend-wrapper,
.tm-otp-main-container .tm-otp-ajax-form.is-success-fade .tm-otp-footer-links,
.tm-otp-main-container .tm-otp-ajax-form.is-loading-fade .tm-otp-icon,
.tm-otp-main-container .tm-otp-ajax-form.is-loading-fade .tm-otp-step-title,
.tm-otp-main-container .tm-otp-ajax-form.is-loading-fade .tm-otp-step-subtitle,
.tm-otp-main-container .tm-otp-ajax-form.is-loading-fade .tm-otp-spam-hint,
.tm-otp-main-container .tm-otp-ajax-form.is-loading-fade .tm-otp-field-wrapper,
.tm-otp-main-container .tm-otp-ajax-form.is-loading-fade .tm-otp-code-boxes,
.tm-otp-main-container .tm-otp-ajax-form.is-loading-fade .tm-otp-btn-main,
.tm-otp-main-container .tm-otp-ajax-form.is-loading-fade .tm-otp-resend-wrapper,
.tm-otp-main-container .tm-otp-ajax-form.is-loading-fade .tm-otp-footer-links,
.tm-otp-main-container .tm-otp-ajax-form.is-notice-fade .tm-otp-icon,
.tm-otp-main-container .tm-otp-ajax-form.is-notice-fade .tm-otp-step-title,
.tm-otp-main-container .tm-otp-ajax-form.is-notice-fade .tm-otp-step-subtitle,
.tm-otp-main-container .tm-otp-ajax-form.is-notice-fade .tm-otp-spam-hint,
.tm-otp-main-container .tm-otp-ajax-form.is-notice-fade .tm-otp-field-wrapper,
.tm-otp-main-container .tm-otp-ajax-form.is-notice-fade .tm-otp-code-boxes,
.tm-otp-main-container .tm-otp-ajax-form.is-notice-fade .tm-otp-btn-main,
.tm-otp-main-container .tm-otp-ajax-form.is-notice-fade .tm-otp-resend-wrapper,
.tm-otp-main-container .tm-otp-ajax-form.is-notice-fade .tm-otp-footer-links {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.28s ease !important;
}

/* طبقة النجاح تغطي الفورم بالكامل */
.tm-otp-main-container .tm-otp-view--success {
    position: absolute !important;
    inset: 0 !important;
    z-index: 40 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 12px !important;
    text-align: center !important;
    padding: 24px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    background: #ffffff !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: translate3d(0, 0, 0) !important;
    transition: opacity 0.3s ease !important;
    backface-visibility: hidden !important;
    overflow: visible !important;
}

.tm-otp-main-container .tm-otp-view--success.tm-otp-view--success-pending {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.tm-otp-main-container .tm-otp-ajax-form.tm-otp-form--success .tm-otp-view--success,
.tm-otp-main-container .tm-otp-ajax-form.is-success-fade .tm-otp-view--success {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translate3d(0, 0, 0) !important;
    pointer-events: auto !important;
}

.tm-otp-main-container .tm-otp-success-badge {
    width: 96px !important;
    height: 96px !important;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: visible !important;
    background: rgba(39, 174, 96, 0.14) !important;
    backface-visibility: hidden !important;
}

/* Pop starts with --success; delay 0 so a late JS kick cannot skip it.
 * !important beats inline animation:none from kickCssAnimation. */
.tm-otp-main-container .tm-otp-ajax-form.tm-otp-form--success .tm-otp-success-badge {
    animation: tm-otp-pop 0.55s cubic-bezier(.22,.68,.36,1) 0s both !important;
}

.tm-otp-main-container .tm-otp-success-svg {
    width: 96px !important;
    height: 96px !important;
    min-width: 96px !important;
    min-height: 96px !important;
    display: block !important;
    overflow: visible !important;
    fill: none;
    flex-shrink: 0 !important;
}

/* Stroke color — dash draw is fully controlled in JS (hide → animate → reveal). */
.tm-otp-main-container .tm-otp-success-ring,
.tm-otp-main-container .tm-otp-notice-ring {
    fill: none;
    stroke: var(--tm-ok, #27ae60);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0;
}

.tm-otp-main-container .tm-otp-success-tick,
.tm-otp-main-container .tm-otp-notice-mark {
    fill: none;
    stroke: var(--tm-ok, #27ae60);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0;
}

.tm-otp-main-container .tm-otp-success-msg {
    margin: 0 !important;
    font-size: 17px !important;
    font-weight: 800 !important;
    color: #2e1a47 !important;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.3s ease 0.9s, transform 0.3s ease 0.9s;
}

.tm-otp-main-container .tm-otp-ajax-form.is-success-fade .tm-otp-success-msg,
.tm-otp-main-container .tm-otp-ajax-form.tm-otp-form--success .tm-otp-success-msg {
    opacity: 1;
    transform: translateY(0);
}

@keyframes tm-otp-pop {
    0% { transform: translate3d(0, 0, 0) scale(0.4); opacity: 0; }
    60% { transform: translate3d(0, 0, 0) scale(1.04); opacity: 1; }
    100% { transform: translate3d(0, 0, 0) scale(1); opacity: 1; }
}

/* Positioning host so the in-form loading overlay can cover this panel.
 * Do not change .tm-otp-main-container or .tm-otp-ajax-form (already relative). */
.tm-otp-content {
    position: relative !important;
}

/* In-form loading / notice overlays — same language as verify success */
.tm-otp-main-container .tm-otp-content.tm-otp-content--loading,
.tm-otp-main-container .tm-otp-content.tm-otp-content--notice {
    position: relative;
}

.tm-otp-main-container .tm-otp-view--loading,
.tm-otp-main-container .tm-otp-view--notice {
    position: absolute !important;
    inset: 0 !important;
    z-index: 40 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 14px !important;
    text-align: center !important;
    padding: 24px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    background: #ffffff !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translate3d(0, 0, 0) !important;
    transition: opacity 0.3s ease, transform 0.34s cubic-bezier(.22,.68,.36,1) !important;
    backface-visibility: hidden !important;
}

.tm-otp-main-container .tm-otp-ajax-form.tm-otp-form--loading .tm-otp-view--loading,
.tm-otp-main-container .tm-otp-content.tm-otp-content--loading .tm-otp-view--loading,
.tm-otp-main-container .tm-otp-ajax-form.tm-otp-form--notice .tm-otp-view--notice,
.tm-otp-main-container .tm-otp-content.tm-otp-content--notice .tm-otp-view--notice {
    opacity: 1 !important;
    transform: translate3d(0, 0, 0) !important;
    pointer-events: auto !important;
}

/* Error notice shares opacity:0 with loading — force paint when form/content is in notice mode */
.tm-otp-main-container .tm-otp-ajax-form.tm-otp-form--notice .tm-otp-view--notice.tm-otp-view--error,
.tm-otp-main-container .tm-otp-ajax-form.is-notice-fade .tm-otp-view--notice.tm-otp-view--error,
.tm-otp-main-container .tm-otp-content.tm-otp-content--notice .tm-otp-view--notice.tm-otp-view--error {
    opacity: 1 !important;
    transform: translate3d(0, 0, 0) !important;
    pointer-events: auto !important;
}

.tm-otp-main-container .tm-otp-view--loading {
    overflow: visible !important;
}

.tm-otp-main-container .tm-otp-view--notice,
.tm-otp-main-container .tm-otp-view--error {
    overflow: visible !important;
}

.tm-otp-main-container .tm-otp-view--error {
    cursor: pointer !important;
}

.tm-otp-main-container .tm-otp-notice-badge {
    position: relative !important;
    width: 96px !important;
    height: 96px !important;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: visible !important;
    animation: tm-otp-pop 0.55s cubic-bezier(.22,.68,.36,1) both !important;
    backface-visibility: hidden !important;
}

.tm-otp-main-container .tm-otp-loading-badge {
    position: relative !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    height: 72px !important;
    padding: 0 6px !important;
    background: none !important;
    overflow: visible !important;
    animation: tm-otp-pop 0.55s cubic-bezier(.22,.68,.36,1) both !important;
    backface-visibility: hidden !important;
}

.tm-otp-main-container .tm-otp-view--error .tm-otp-notice-badge {
    background: rgba(231, 76, 60, 0.14) !important;
}

.tm-otp-main-container .tm-otp-view--ok .tm-otp-notice-badge {
    background: rgba(39, 174, 96, 0.14) !important;
}

.tm-otp-main-container .tm-otp-ajax-form.tm-otp-form--loading .tm-otp-loading-badge,
.tm-otp-main-container .tm-otp-content.tm-otp-content--loading .tm-otp-loading-badge,
.tm-otp-main-container .tm-otp-ajax-form.tm-otp-form--notice .tm-otp-notice-badge,
.tm-otp-main-container .tm-otp-content.tm-otp-content--notice .tm-otp-notice-badge {
    animation-delay: 0.06s !important;
}

.tm-otp-main-container .tm-otp-notice-svg {
    position: relative !important;
    width: 96px !important;
    height: 96px !important;
    min-width: 96px !important;
    min-height: 96px !important;
    display: block !important;
    overflow: visible !important;
    fill: none;
    z-index: 1 !important;
    flex-shrink: 0 !important;
}

.tm-otp-main-container .tm-otp-view--error .tm-otp-notice-svg {
    fill: none;
}

.tm-otp-main-container .tm-otp-loading-wave {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 12px !important;
    height: 72px !important;
    direction: ltr !important;
    overflow: visible !important;
}

.tm-otp-main-container .tm-otp-loading-dot {
    display: block !important;
    width: 14px !important;
    height: 14px !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 50% !important;
    background: radial-gradient(circle at 32% 28%, #d7bde2 0%, var(--tm-p, #8e44ad) 52%, var(--tm-p2, #6c3483) 100%) !important;
    box-shadow: 0 8px 18px rgba(142, 68, 173, 0.32) !important;
    transform: translateZ(0);
    will-change: transform, opacity;
}

.tm-otp-main-container .tm-otp-form--loading .tm-otp-loading-dot,
.tm-otp-main-container .tm-otp-content--loading .tm-otp-loading-dot {
    animation: tm-otp-wave 1.15s cubic-bezier(.37, .01, .22, .99) infinite !important;
}

.tm-otp-main-container .tm-otp-loading-wave .tm-otp-loading-dot:nth-child(1) { animation-delay: 0s !important; }
.tm-otp-main-container .tm-otp-loading-wave .tm-otp-loading-dot:nth-child(2) { animation-delay: 0.14s !important; }
.tm-otp-main-container .tm-otp-loading-wave .tm-otp-loading-dot:nth-child(3) { animation-delay: 0.28s !important; }
.tm-otp-main-container .tm-otp-loading-wave .tm-otp-loading-dot:nth-child(4) { animation-delay: 0.42s !important; }

.tm-otp-main-container .tm-otp-notice-ring {
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tm-otp-main-container .tm-otp-view--error .tm-otp-notice-ring {
    fill: none;
    stroke: var(--tm-err, #e74c3c);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tm-otp-main-container .tm-otp-view--ok .tm-otp-notice-ring {
    stroke: var(--tm-ok, #27ae60);
}

.tm-otp-main-container .tm-otp-notice-mark {
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tm-otp-main-container .tm-otp-view--error .tm-otp-notice-mark {
    fill: none;
    stroke: var(--tm-err, #e74c3c);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tm-otp-main-container .tm-otp-view--ok .tm-otp-notice-mark {
    stroke: var(--tm-ok, #27ae60);
}

.tm-otp-main-container .tm-otp-notice-msg {
    margin: 0 !important;
    max-width: 280px !important;
    font-size: 17px !important;
    font-weight: 800 !important;
    line-height: 1.45 !important;
    color: var(--tm-text) !important;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.3s ease 0.9s, transform 0.3s ease 0.9s;
}

.tm-otp-main-container .tm-otp-view--error .tm-otp-notice-msg {
    color: var(--tm-err2, #c0392b) !important;
}

.tm-otp-main-container .tm-otp-view--ok .tm-otp-notice-msg {
    color: var(--tm-ok2, #1e8449) !important;
}

.tm-otp-main-container .tm-otp-ajax-form.tm-otp-form--notice .tm-otp-notice-msg,
.tm-otp-main-container .tm-otp-content.tm-otp-content--notice .tm-otp-notice-msg {
    opacity: 1;
    transform: translateY(0);
}

@keyframes tm-otp-wave {
    0%, 100% {
        transform: translate3d(0, 8px, 0) scale(0.82);
        opacity: 0.38;
    }
    50% {
        transform: translate3d(0, -12px, 0) scale(1.14);
        opacity: 1;
    }
}

/* Hide the legacy spinner card */
.tm-otp-main-container .tm-otp-status.is-loading:not([hidden]),
.tm-otp-main-container .tm-otp-status.is-error:not([hidden]),
.tm-otp-main-container .tm-otp-status.is-success:not([hidden]) {
    display: none !important;
}

@media (max-width: 480px) {
    .tm-otp-main-container .tm-otp-code-boxes { gap: 8px !important; }
    .tm-otp-main-container .tm-otp-code-box {
        width: 100% !important;
        max-width: 60px !important;
        height: 58px !important;
        font-size: 24px !important;
    }
    .tm-otp-main-container .tm-otp-success-badge,
    .tm-otp-main-container .tm-otp-success-svg,
    .tm-otp-main-container .tm-otp-notice-badge,
    .tm-otp-main-container .tm-otp-notice-svg {
        width: 84px !important;
        height: 84px !important;
        min-width: 84px !important;
        min-height: 84px !important;
    }
}

/* الأزرار */
.tm-otp-main-container .tm-otp-btn-main {
    display: block !important;
    width: 100% !important;
    padding: 14px 20px !important;
    border: none !important;
    border-radius: var(--tm-r-sm) !important;
    font-weight: 800 !important;
    font-size: 16px !important;
    cursor: pointer !important;
    text-decoration: none !important;
    text-align: center !important;
    margin-top: 10px !important;
    min-height: 50px !important;
    position: relative !important;
}

.tm-otp-main-container .tm-otp-btn-main.tm-otp-btn-loading {
    cursor: wait !important;
    opacity: 0.95 !important;
    pointer-events: none !important;
}

.tm-otp-main-container .tm-otp-btn-spinner {
    display: inline-block !important;
    width: 22px !important;
    height: 22px !important;
    border: 3px solid rgba(255,255,255,0.35) !important;
    border-top-color: #fff !important;
    border-radius: 50% !important;
    vertical-align: middle !important;
    animation: tm-otp-spin 0.7s linear infinite !important;
    backface-visibility: hidden !important;
}

@keyframes tm-otp-spin {
    from { transform: translate3d(0, 0, 0) rotate(0deg); }
    to { transform: translate3d(0, 0, 0) rotate(360deg); }
}

.tm-otp-btn-purple {
    background: linear-gradient(135deg, var(--tm-p) 0%, var(--tm-p2) 100%) !important;
    color: #fff !important;
    transition: opacity 0.3s ease;
}

.tm-otp-btn-purple:hover { opacity: 0.9; }

.tm-otp-btn-green {
    background: linear-gradient(135deg, var(--tm-ok) 0%, #58d68d 100%) !important;
    color: #fff !important;
}

/* التبويبات (Tabs) */
.tm-otp-tabs {
    display: flex !important;
    background: var(--tm-surface) !important;
    border: 2px solid var(--tm-border) !important;
    border-radius: var(--tm-r-sm) !important;
    padding: 4px !important;
    margin-bottom: 20px !important;
}

.tm-otp-tab {
    flex: 1 !important;
    background: transparent !important;
    border: none !important;
    padding: 9px 8px !important;
    font-size: 13.5px !important;
    font-weight: 700 !important;
    color: var(--tm-muted) !important;
    cursor: pointer !important;
}

.tm-otp-tab.active {
    background: #fff !important;
    color: var(--tm-p) !important;
    border-radius: 9px !important;
    box-shadow: 0 2px 10px rgba(142, 68, 173, 0.15) !important;
}

/* طبقة الحالة (تحميل / نجاح / خطأ) */
.tm-otp-main-container .tm-otp-status[hidden] {
    display: none !important;
}
.tm-otp-main-container .tm-otp-status:not([hidden]) {
    display: flex !important;
    position: absolute !important;
    inset: 0 !important;
    z-index: 99 !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 20px !important;
    background: rgba(255, 255, 255, 0.5) !important;
    backdrop-filter: blur(10px) saturate(1.15) !important;
    -webkit-backdrop-filter: blur(10px) saturate(1.15) !important;
}
.tm-otp-main-container .tm-otp-status.is-error:not([hidden]) {
    cursor: pointer !important;
}

.tm-otp-main-container .tm-otp-status-card {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 14px !important;
    min-width: 176px !important;
    max-width: 280px !important;
    padding: 26px 22px 22px !important;
    background: rgba(255, 255, 255, 0.92) !important;
    border: 1px solid var(--tm-border) !important;
    border-radius: 16px !important;
    box-shadow: 0 16px 40px rgba(46, 26, 71, 0.12) !important;
    text-align: center !important;
}

.tm-otp-main-container .tm-otp-status-icon {
    width: 52px !important;
    height: 52px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
}

.tm-otp-main-container .tm-otp-status-spinner,
.tm-otp-main-container .tm-otp-status-check,
.tm-otp-main-container .tm-otp-status-cross {
    display: none !important;
}

.tm-otp-main-container .tm-otp-status.is-loading .tm-otp-status-spinner {
    display: block !important;
    width: 44px !important;
    height: 44px !important;
    position: relative !important;
}
.tm-otp-main-container .tm-otp-status.is-loading .tm-otp-status-spinner::before,
.tm-otp-main-container .tm-otp-status.is-loading .tm-otp-status-spinner::after {
    content: "" !important;
    position: absolute !important;
    border-radius: 50% !important;
    border-style: solid !important;
    border-color: transparent !important;
    box-sizing: border-box !important;
}
.tm-otp-main-container .tm-otp-status.is-loading .tm-otp-status-spinner::before {
    inset: 0 !important;
    border-width: 3px !important;
    border-top-color: var(--tm-p) !important;
    border-right-color: var(--tm-p) !important;
    animation: tm-otp-spin 0.85s linear infinite !important;
}
.tm-otp-main-container .tm-otp-status.is-loading .tm-otp-status-spinner::after {
    inset: 7px !important;
    border-width: 3px !important;
    border-bottom-color: var(--tm-p2) !important;
    border-left-color: var(--tm-p2) !important;
    animation: tm-otp-spin 1.15s linear infinite reverse !important;
}

.tm-otp-main-container .tm-otp-status.is-success .tm-otp-status-check {
    display: block !important;
    width: 36px !important;
    height: 36px !important;
    border: 2.5px solid var(--tm-ok) !important;
    border-radius: 50% !important;
    position: relative !important;
    animation: tmStatusPop 0.28s var(--tm-ease) !important;
}
.tm-otp-main-container .tm-otp-status.is-success .tm-otp-status-check::after {
    content: "" !important;
    position: absolute !important;
    left: 12px !important;
    top: 6px !important;
    width: 8px !important;
    height: 15px !important;
    border: solid var(--tm-ok) !important;
    border-width: 0 2.5px 2.5px 0 !important;
    transform: rotate(45deg) !important;
}

.tm-otp-main-container .tm-otp-status.is-error .tm-otp-status-cross {
    display: block !important;
    width: 36px !important;
    height: 36px !important;
    border: 2.5px solid #e05252 !important;
    border-radius: 50% !important;
    position: relative !important;
    animation: tmStatusPop 0.28s var(--tm-ease) !important;
}
.tm-otp-main-container .tm-otp-status.is-error .tm-otp-status-cross::before,
.tm-otp-main-container .tm-otp-status.is-error .tm-otp-status-cross::after {
    content: "" !important;
    position: absolute !important;
    left: 16px !important;
    top: 8px !important;
    width: 2.5px !important;
    height: 16px !important;
    background: #e05252 !important;
    border-radius: 1px !important;
}
.tm-otp-main-container .tm-otp-status.is-error .tm-otp-status-cross::before {
    transform: rotate(45deg) !important;
}
.tm-otp-main-container .tm-otp-status.is-error .tm-otp-status-cross::after {
    transform: rotate(-45deg) !important;
}

.tm-otp-main-container .tm-otp-status-text {
    margin: 0 !important;
    font-size: 14.5px !important;
    font-weight: 700 !important;
    line-height: 1.5 !important;
    color: var(--tm-text) !important;
}
.tm-otp-main-container .tm-otp-status.is-success .tm-otp-status-text {
    color: var(--tm-ok2, #1e8449) !important;
}
.tm-otp-main-container .tm-otp-status.is-error .tm-otp-status-text {
    color: #9b2c2c !important;
}

@keyframes tmStatusPop {
    from { opacity: 0; transform: scale(0.72); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes tm-ping { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

/* استثناءات للهواتف */
@media (max-width: 480px) {
    .tm-otp-main-box { margin: 10px !important; border-radius: 15px !important; }
}

/* صندوق الهاتف الموحّد (مفتاح + رقم محلي) */
.tm-otp-main-container .tm-otp-phone-box,
.tm-otp-main-container .tm-otp-field-wrapper > .tm-otp-phone-input {
    max-width: 248px !important;
    width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

.tm-otp-main-container .tm-otp-phone-box {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    min-height: 50px !important;
    direction: ltr !important;
    border: 2px solid var(--tm-border) !important;
    border-radius: var(--tm-r-sm) !important;
    background: var(--tm-surface) !important;
    overflow: hidden !important;
}
.tm-otp-main-container .tm-otp-phone-box:focus-within {
    border-color: var(--tm-p) !important;
    background: #fff !important;
    box-shadow: 0 0 0 3px rgba(142, 68, 173, 0.1) !important;
}

.tm-otp-main-container .tm-otp-phone-prefix {
    display: flex !important;
    align-items: center !important;
    flex-shrink: 0 !important;
    direction: ltr !important;
    padding: 0 2px 0 10px !important;
    border-right: 1px solid var(--tm-border) !important;
    background: rgba(142, 68, 173, 0.05) !important;
    font-weight: 700 !important;
    font-size: 16px !important;
    color: var(--tm-text) !important;
}

.tm-otp-main-container .tm-otp-phone-prefix-text {
    display: block !important;
    padding: 0 6px 0 0 !important;
    line-height: 1 !important;
    white-space: nowrap !important;
}

.tm-otp-main-container .tm-otp-phone-prefix-select {
    appearance: auto !important;
    -webkit-appearance: menulist !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    min-height: 50px !important;
    max-width: 86px !important;
    padding: 0 2px !important;
    margin: 0 !important;
    font-weight: 700 !important;
    font-size: 16px !important;
    color: var(--tm-text) !important;
    cursor: pointer !important;
    outline: none !important;
}

.tm-otp-main-container .tm-otp-phone-box .tm-otp-phone-local,
.tm-otp-main-container .tm-otp-phone-box .tm-otp-phone-input,
.tm-otp-main-container .tm-otp-phone-box .tm-otp-input-field {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    width: auto !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    min-height: 50px !important;
    padding: 14px 12px !important;
    font-size: 16px !important;
    line-height: 1.35 !important;
    text-align: left !important;
}

.tm-otp-main-container .tm-otp-field-wrapper > .tm-otp-phone-input.tm-otp-phone-free {
    text-align: left !important;
}
.tm-otp-main-container .tm-otp-phone-box .tm-otp-input-field:focus {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
}

/* زر إعادة إرسال الرمز */
.tm-otp-main-container .tm-otp-resend-wrapper {
    text-align: center !important;
    margin-top: 15px !important;
}

.tm-otp-main-container .tm-otp-btn-resend {
    background: transparent !important;
    border: none !important;
    color: var(--tm-p) !important;
    font-size: 14.5px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    padding: 8px 16px !important;
    border-radius: var(--tm-r-sm) !important;
    transition: all 0.3s ease !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
}

.tm-otp-main-container .tm-otp-btn-resend:not(:disabled):hover {
    background: #f5eef8 !important; /* خلفية ليلكية خفيفة جداً عند المرور */
    color: var(--tm-p2) !important;
}

.tm-otp-main-container .tm-otp-btn-resend:disabled {
    color: var(--tm-muted) !important;
    cursor: not-allowed !important;
    opacity: 0.6 !important;
}

/* الروابط السفلية */
.tm-otp-main-container .tm-otp-footer-links {
    text-align: center !important;
    margin-top: 18px !important;
    padding-top: 16px !important;
    border-top: 1px solid var(--tm-border) !important;
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: 6px 14px !important;
}

.tm-otp-main-container .tm-otp-btn-link {
    background: transparent !important;
    border: none !important;
    color: var(--tm-muted) !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    padding: 4px 8px !important;
}

.tm-otp-main-container .tm-otp-btn-link:hover {
    color: var(--tm-p) !important;
    text-decoration: underline !important;
}
/* ===== شاشة اختيار طريقة الدخول ===== */
.tm-otp-main-container .tm-otp-method-buttons {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    margin-top: 22px !important;
}

.tm-otp-main-container .tm-otp-method-btn {
    display: flex !important;
    align-items: center !important;
    gap: 14px !important;
    width: 100% !important;
    padding: 13px 16px !important;
    background: var(--tm-surface) !important;
    border: 2px solid var(--tm-border) !important;
    border-radius: var(--tm-r-sm) !important;
    cursor: pointer !important;
    text-align: start !important;
    line-height: 1.3 !important;
    transition: all 0.25s ease !important;
}

.tm-otp-main-container .tm-otp-method-btn:hover {
    border-color: var(--tm-p) !important;
    background: #fff !important;
    box-shadow: 0 4px 18px rgba(142, 68, 173, 0.12) !important;
    transform: translateY(-1px) !important;
}

.tm-otp-main-container .tm-otp-method-btn-icon {
    flex-shrink: 0 !important;
    width: 46px !important;
    height: 46px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: linear-gradient(135deg, var(--tm-p) 0%, var(--tm-p2) 100%) !important;
    border-radius: 12px !important;
    color: #fff !important;
}

.tm-otp-main-container .tm-otp-method-btn-icon .tm-otp-emoji {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 22px !important;
    line-height: 1 !important;
    font-style: normal !important;
    font-weight: 400 !important;
    /* Override Tajawal on * so emoji glyphs center by their own metrics */
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif !important;
}

.tm-otp-main-container .tm-otp-method-btn-text {
    flex: 1 !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    gap: 2px !important;
    text-align: start !important;
}

.tm-otp-main-container .tm-otp-method-btn-text strong {
    font-size: 15px !important;
    font-weight: 800 !important;
    color: var(--tm-text) !important;
}

.tm-otp-main-container .tm-otp-method-btn-text small {
    font-size: 12px !important;
    color: var(--tm-muted) !important;
    font-weight: 500 !important;
}

/* ===== روابط مساعدة (نسيت كلمة السر / حساب جديد) ===== */
.tm-otp-main-container .tm-otp-form-meta-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px 16px !important;
    width: 100% !important;
    margin: 2px 0 14px !important;
    flex-wrap: wrap !important;
}

.tm-otp-main-container .tm-otp-meta-link {
    display: inline !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    font-family: inherit !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: var(--tm-muted) !important;
    text-decoration: none !important;
    cursor: pointer !important;
    line-height: 1.4 !important;
    white-space: nowrap !important;
}

.tm-otp-main-container .tm-otp-meta-link--accent {
    color: var(--tm-p) !important;
    font-weight: 700 !important;
}

.tm-otp-main-container .tm-otp-meta-link:hover {
    color: var(--tm-p) !important;
    text-decoration: underline !important;
}

/* Legacy aliases */
.tm-otp-main-container .tm-otp-forgot-wrap {
    text-align: start !important;
    width: 100% !important;
    margin: -4px 0 6px !important;
}

.tm-otp-main-container .tm-otp-forgot-link {
    display: inline !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    font-family: inherit !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: var(--tm-p) !important;
    text-decoration: none !important;
    cursor: pointer !important;
}

.tm-otp-main-container .tm-otp-forgot-link:hover {
    text-decoration: underline !important;
}

.tm-otp-main-container .tm-otp-register-cta {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    margin-top: 12px !important;
    font-size: 13px !important;
    color: var(--tm-muted) !important;
    flex-wrap: wrap !important;
}

.tm-otp-main-container .tm-otp-btn-outline {
    background: transparent !important;
    border: 2px solid var(--tm-p) !important;
    color: var(--tm-p) !important;
    font-weight: 800 !important;
    font-size: 13.5px !important;
    padding: 8px 18px !important;
    border-radius: var(--tm-r-sm) !important;
    cursor: pointer !important;
    transition: all 0.25s ease !important;
}

.tm-otp-main-container .tm-otp-btn-outline:hover {
    background: linear-gradient(135deg, var(--tm-p) 0%, var(--tm-p2) 100%) !important;
    color: #fff !important;
}

/* Utility classes used by templates */
.tm-otp-main-container .tm-otp-field-wrapper {
    text-align: start !important;
    width: 100% !important;
}

.tm-otp-main-container .tm-otp-field-wrapper .tm-otp-input-field,
.tm-otp-main-container .tm-otp-field-wrapper .tm-otp-select-field {
    text-align: start !important;
}

.tm-otp-main-container .tm-otp-field-wrapper .tm-otp-ltr {
    direction: ltr !important;
    text-align: left !important;
}

.tm-otp-main-container .tm-otp-label-secondary {
    display: block !important;
    width: 100% !important;
    text-align: start !important;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--tm-text);
    margin: 0 0 8px;
}

.tm-otp-main-container.rtl .tm-otp-label-secondary {
    text-align: right !important;
}

.tm-otp-main-container.ltr .tm-otp-label-secondary {
    text-align: left !important;
}

.tm-otp-main-container .tm-otp-help-text {
    display: block !important;
    width: 100% !important;
    text-align: start !important;
    font-size: 12px;
    color: var(--tm-muted);
    margin-top: 6px;
    line-height: 1.5;
}

.tm-otp-main-container.rtl .tm-otp-help-text {
    text-align: right !important;
}

.tm-otp-main-container.ltr .tm-otp-help-text {
    text-align: left !important;
}

.tm-otp-main-container .tm-otp-ltr {
    direction: ltr !important;
    text-align: left !important;
}

.tm-otp-main-container .tm-fade-in,
.tm-fade-in {
    animation: tmFadeIn 0.22s ease;
}

@keyframes tmFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.tm-otp-main-container .tm-otp-already-logged {
    text-align: center;
    padding: 24px 16px;
    color: var(--tm-muted);
    font-size: 15px;
    font-weight: 600;
    margin: 0;
}

/*
 * Reduced motion: decorative ping only (`.tm-otp-icon` / tm-ping).
 * Loader wave, success/notice SVG draw, overlay fade-in, button spinner,
 * and OTP box shake stay on — they are functional feedback.
 * (Windows often sets prefers-reduced-motion via Animation effects.)
 */
@media (prefers-reduced-motion: reduce) {
    .tm-otp-icon {
        animation: none !important;
    }

    /* Functional error feedback — Windows often reports reduced-motion */
    .tm-otp-main-container .tm-otp-code-boxes.is-shake {
        animation: tm-otp-shake 0.55s var(--tm-ease, cubic-bezier(.4, 0, .2, 1)) both !important;
    }
}
