/* ملف: assets/css/tm-otp-style.css */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800&display=swap');

:root {
    /* الألوان الجديدة: تدرجات الأرجواني الملكي */
    --tm-p: #8e44ad;       /* أرجواني أساسي */
    --tm-p2: #6c3483;      /* أرجواني داكن */
    --tm-p3: #9b59b6;      /* أرجواني فاتح */
    --tm-accent: #d7bde2;  /* ليلكي ناعم */
    --tm-ok: #27ae60;      /* أخضر للنجاح */
    --tm-ok2: #1e8449;
    --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;
    display: block;
    font-family: 'Tajawal', sans-serif !important;
    transition: height .35s var(--tm-ease);
    overflow: hidden;
    box-sizing: border-box;
}

#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;
}

/* التصميم الرئيسي للبطاقة */
.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: 32px 28px 26px !important;
    margin: 0 !important;
}

/* الأيقونة بتوهج أرجواني */
.tm-otp-icon {
    width: 56px !important;
    height: 56px !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: 26px !important;
    margin: 0 auto 18px !important;
    box-shadow: 0 8px 20px rgba(142, 68, 173, 0.25) !important;
    animation: tm-ping 2.4s ease-in-out infinite;
}

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

.tm-otp-step-subtitle {
    text-align: center !important;
    color: var(--tm-muted) !important;
    font-size: 13.5px !important;
    margin: 0 0 24px !important;
    display: block !important;
}

/* تنويه السبام (يظهر في قسم الإيميل فقط) */
#tm-otp-main-container .tm-otp-spam-hint {
    display: flex !important;
    align-items: flex-start !important;
    gap: 9px !important;
    text-align: start !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: 48px !important;
    padding: 13px 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: 15px !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 4px rgba(142, 68, 173, 0.1) !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;
}

@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-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: 15.5px !important;
    cursor: pointer !important;
    text-decoration: none !important;
    text-align: center !important;
    margin-top: 10px !important;
}

.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;
}

/* الـ Loader */
.tm-otp-loader-overlay {
    display: none;
    position: absolute !important;
    inset: 0 !important;
    background: rgba(255,255,255,.9) !important;
    backdrop-filter: blur(4px) !important;
    z-index: 99 !important;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.tm-otp-spinner {
    width: 40px; height: 40px;
    border: 4px solid rgba(142, 68, 173, 0.1);
    border-top-color: var(--tm-p);
    border-radius: 50%;
    animation: tm-spin 0.8s linear infinite;
}

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

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

/* حقل الإدخال المشترك */
#tm-otp-main-container .tm-otp-input-group {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 10px !important;
    width: 100% !important;
    /* تثبيت الاتجاه دائماً من اليسار لليمين لمنع تبدل مكان الحقول */
    direction: ltr !important;
}

#tm-otp-main-container .tm-otp-input-group .tm-otp-flex-1 {
    flex: 1 !important;
    /* استعادة اتجاه النص الصحيح داخل حقل الهاتف */
    direction: inherit;
}

/* كود الدولة دائماً على اليسار (order: 1) */
#tm-otp-main-container .tm-otp-input-group select.tm-otp-w-100 {
    width: 110px !important;
    flex-shrink: 0 !important;
    order: 1 !important;
}

/* حقل الهاتف دائماً على اليمين (order: 2) */
#tm-otp-main-container .tm-otp-input-group .tm-otp-flex-1 {
    order: 2 !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: 24px !important;
    padding-top: 16px !important;
    border-top: 1px solid var(--tm-border) !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: 16px 18px !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;
    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;
    font-size: 24px !important;
    width: 46px !important;
    height: 46px !important;
    display: 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-text {
    flex: 1 !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !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-forgot-wrap {
    text-align: start !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: center !important;
    gap: 8px !important;
    margin-top: 16px !important;
    font-size: 13.5px !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;
}

/* ===== رسائل التنبيه (بدون إيموجي) ===== */
#tm-otp-main-container #tm-otp-feedback {
    margin-bottom: 6px !important;
}

#tm-otp-main-container .tm-otp-msg {
    position: relative !important;
    padding: 13px 16px 13px 16px !important;
    border-radius: var(--tm-r-sm) !important;
    font-size: 13.5px !important;
    font-weight: 600 !important;
    line-height: 1.6 !important;
    text-align: start !important;
    overflow: hidden !important;
    animation: tmMsgIn 0.22s ease !important;
}

/* شريط لوني جانبي يميّز نوع الرسالة */
#tm-otp-main-container .tm-otp-msg::before {
    content: "" !important;
    position: absolute !important;
    inset-inline-start: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    width: 4px !important;
    border-radius: 4px !important;
}

#tm-otp-main-container .tm-otp-msg-error {
    color: #9b2c2c !important;
    background: #fdf2f2 !important;
    border: 1px solid #f7d7d7 !important;
}
#tm-otp-main-container .tm-otp-msg-error::before {
    background: #e05252 !important;
}

#tm-otp-main-container .tm-otp-msg-success {
    color: #05614a !important;
    background: #f0fbf6 !important;
    border: 1px solid #c3ecd9 !important;
}
#tm-otp-main-container .tm-otp-msg-success::before {
    background: var(--tm-ok, #27ae60) !important;
}

#tm-otp-main-container .tm-otp-msg-text {
    display: block !important;
    padding-inline-start: 10px !important;
}

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