/* ============================================================================
   طيف (tayf) — شاشات المصادقة (تسجيل الدخول / نسيت كلمة السر)
   ============================================================================
   منقول عن تصميم tayf.ae الرسمي (css/variables.css + css/auth.css في مشروع
   الواجهة) مع ربطه بمنطق لوحة التحكم الفعلي.

   الشاشة مقسومة نصفين: لوحة النموذج الذهبية + لوحة الصورة. في الاتجاه RTL
   تظهر لوحة النموذج على اليمين ولوحة الصورة على اليسار تلقائيًا (أول عنصر في
   الـ flex يكون على اليمين).

   مصدر اللون الذهبي #F8CB25: مستخرج من ملف الشعار الرسمي.
   ============================================================================ */

:root {
    /* الهوية */
    --color-primary: #f8cb25;        /* الذهبي — لون الشعار الأساسي */
    --color-primary-600: #dcae0a;
    --color-brand-blue: #3164f5;     /* الأزرق — الأزرار والروابط */

    /* الحياد */
    --color-white: #ffffff;
    --color-ink-900: #0e0e14;
    --color-gray-500: #afafaf;

    /* دلالية */
    --color-success: #2fae60;
    --color-danger: #e11a2c;

    /* الخط */
    --font-primary: "Tajawal", "Tahoma", "Arial", sans-serif;

    /* المسافات */
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;

    /* الانحناءات والظلال */
    --radius-md: 14px;
    --radius-full: 999px;
    --shadow-md: 0 8px 24px rgba(20, 20, 28, 0.1);

    --transition-fast: 0.18s ease;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body.auth-body {
    margin: 0;
    min-height: 100vh;
    background: var(--color-primary);
    font-family: var(--font-primary);
    color: var(--color-ink-900);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

body.auth-body img {
    max-width: 100%;
    display: block;
}

/* بلا color:inherit هنا — كان يتغلّب على ألوان الروابط والأزرار الدائرية
   (specificity أعلى من .auth-fixed-btn و .auth-forgot-link) فيصيّرها سوداء.
   كل رابط في هذه الشاشات له لونه الصريح أدناه. */
body.auth-body a {
    text-decoration: none;
}

body.auth-body button {
    font-family: inherit;
    cursor: pointer;
}

/* -------------------------- زرّا الهوم/اللغة الثابتان -------------------------- */
/* inset-inline-start وليس end: لوحة النموذج الذهبية هي أول عنصر في الـ flex،
   أي أنها على اليمين في RTL وعلى اليسار في LTR — وبهذه الخاصية يبقى الزرّان
   فوقها في الاتجاهين، تمامًا كالتصميم المعتمد (أعلى يمين الشاشة بالعربية). */
.auth-fixed-actions {
    position: fixed;
    top: 20px;
    inset-inline-start: 20px;
    display: flex;
    gap: 8px;
    z-index: 100;
}

.auth-fixed-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--color-brand-blue);
    color: var(--color-white);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-fast);
}

.auth-fixed-btn:hover {
    transform: translateY(-2px);
    color: var(--color-white);
}

.auth-fixed-btn svg {
    width: 20px;
    height: 20px;
}

/* -------------------------------- الشاشة المقسومة --------------------------------
   على الجوال: عمود واحد — لوحة الصورة شريط علوي بارتفاع محدود ثم النموذج تحته.
   من 900px فأكثر: صف كامل الارتفاع (نموذج + صورة جنبًا إلى جنب). */
.auth-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.auth-form-panel {
    order: 2;
    width: 100%;
    background: var(--color-primary);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 28px 20px 40px;
}

.auth-form-card {
    width: 100%;
    max-width: 420px;
}

/* شارة صغيرة فوق العنوان — تُميّز الشاشة (مثل "دخول الموظفين") */
.auth-eyebrow {
    display: block;
    width: fit-content;
    margin: 0 auto var(--space-4);
    padding: 6px 16px;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.3px;
    color: var(--color-ink-900);
    background: rgba(20, 20, 28, 0.08);
    border-radius: var(--radius-full);
}

.auth-title {
    text-align: center;
    font-size: 1.4rem;
    font-weight: 800;
    margin: 0 0 var(--space-2);
}

.auth-subtitle {
    text-align: center;
    color: rgba(20, 20, 28, 0.65);
    margin: 0 0 var(--space-6);
    font-size: 0.92rem;
}

/* -------------------------------- الحقول -------------------------------- */
.auth-form-group {
    margin-bottom: var(--space-5);
    text-align: center;
}

.auth-label {
    display: block;
    text-align: center;
    font-weight: 700;
    margin-bottom: 8px;
    font-size: 0.92rem;
}

.auth-input {
    width: 100%;
    text-align: center;
    /* بلا حدّ ظاهر — الأبيض على الذهبي كافٍ للتمييز. الحدّ شفاف حتى لا تقفز
       أبعاد الحقل عند التركيز حين يظهر الحدّ الأزرق. */
    border: 2px solid transparent;
    border-radius: var(--radius-full);
    padding: 12px 24px;
    font-size: 1rem;
    font-family: inherit;
    background: var(--color-white);
    color: var(--color-ink-900);
    transition: border-color var(--transition-fast);
}

.auth-input:focus {
    outline: none;
    border-color: var(--color-brand-blue);
}

.auth-input::placeholder {
    color: var(--color-gray-500);
    text-align: center;
}

.auth-input.is-invalid {
    border-color: var(--color-danger);
}

/* حقل كلمة السر مع زر إظهار/إخفاء */
.auth-password-wrap {
    position: relative;
}

.auth-password-wrap .auth-input {
    padding-inline-end: 46px;
}

.auth-password-toggle {
    position: absolute;
    inset-inline-end: 18px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 0;
    line-height: 0;
    color: rgba(20, 20, 28, 0.45);
    transition: color var(--transition-fast);
}

.auth-password-toggle:hover {
    color: var(--color-ink-900);
}

.auth-password-toggle svg {
    width: 20px;
    height: 20px;
}

/* -------------------------------- الأزرار والروابط -------------------------------- */
.auth-btn {
    width: 100%;
    background: var(--color-brand-blue);
    color: var(--color-white);
    border: none;
    border-radius: var(--radius-full);
    padding: 14px;
    font-weight: 700;
    font-size: 1rem;
    text-align: center;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
}

.auth-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(49, 100, 245, 0.3);
    color: var(--color-white);
}

.auth-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.auth-link-row {
    text-align: center;
    margin-top: var(--space-5);
    margin-bottom: 0;
    font-size: 0.9rem;
    color: rgba(20, 20, 28, 0.75);
}

.auth-link-row a {
    color: var(--color-brand-blue);
    font-weight: 700;
}

.auth-link-row a:hover {
    text-decoration: underline;
    color: var(--color-brand-blue);
}

.auth-forgot-link {
    display: block;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-brand-blue);
    margin-top: -8px;
    margin-bottom: var(--space-6);
}

.auth-forgot-link:hover {
    text-decoration: underline;
    color: var(--color-brand-blue);
}

/* -------------------------------- التنبيهات -------------------------------- */
.auth-alert {
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: var(--space-5);
    font-size: 0.88rem;
    font-weight: 500;
    text-align: center;
}

.auth-alert-danger {
    background: rgba(225, 26, 44, 0.12);
    color: #8f0d19;
}

.auth-alert-success {
    background: rgba(47, 174, 96, 0.14);
    color: #1d6d3c;
}

.auth-alert div + div {
    margin-top: 4px;
}

/* -------------------------------- صفّ "تذكرني" و "نسيت كلمة السر؟" --------------------------------
   الاثنان على سطر واحد: تذكرني في بداية السطر (يمينًا بالعربية) ونسيت كلمة
   السر في نهايته (يسارًا بالعربية). */
.auth-form-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

.auth-form-meta .auth-checkbox-row,
.auth-form-meta .auth-forgot-link {
    margin: 0;
}

.auth-form-meta .auth-forgot-link {
    display: inline-block;
}

/* -------------------------------- تذكّرني -------------------------------- */
.auth-checkbox-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: var(--space-5);
    font-size: 0.88rem;
    font-weight: 500;
    color: rgba(20, 20, 28, 0.75);
}

.auth-checkbox-row input {
    width: 16px;
    height: 16px;
    accent-color: var(--color-brand-blue);
    flex-shrink: 0;
    margin: 0;
    cursor: pointer;
}

.auth-checkbox-row label {
    cursor: pointer;
    margin: 0;
}

/* -------------------------------- تحقّق Cloudflare -------------------------------- */
.auth-turnstile {
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-5);
}

/* -------------------------------- الكابتشا المصوّرة (شاشة الموظفين) -------------------------------- */
.auth-captcha {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: var(--space-5);
}

.auth-captcha .auth-input {
    flex: 1;
    min-width: 0;
    margin: 0;
}

.auth-captcha-image {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.auth-captcha-image img {
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--color-white);
}

.auth-captcha-refresh {
    background: none;
    border: none;
    padding: 4px;
    line-height: 0;
    color: rgba(20, 20, 28, 0.6);
}

.auth-captcha-refresh:hover {
    color: var(--color-ink-900);
}

.auth-captcha-refresh svg {
    width: 18px;
    height: 18px;
}

/* -------------------------------- لوحة الصورة -------------------------------- */
.auth-image-panel {
    order: 1;
    position: relative;
    overflow: hidden;
    height: 220px;
    flex-shrink: 0;
}

.auth-image-panel img.auth-bg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.auth-image-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

/* الشعار بجانب الشعار النصي أفقيًا (وليس فوقه) — نفس ترتيب الشاشة الفعلية */
.auth-image-content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    text-align: start;
    padding: var(--space-5);
}

.auth-image-content img {
    width: 130px;
    flex-shrink: 0;
}

.auth-image-tagline {
    color: var(--color-white);
    font-size: 1rem;
    font-weight: 700;
    max-width: 220px;
    margin: 0;
}

@media (min-width: 900px) {
    .auth-page {
        flex-direction: row;
    }

    .auth-form-panel {
        order: 0;
        width: 42%;
        min-width: 420px;
        min-height: 100vh;
        align-items: center;
        padding: 64px 24px;
    }

    .auth-image-panel {
        order: 0;
        flex: 1;
        height: auto;
        min-height: 100vh;
    }

    .auth-image-content {
        gap: var(--space-4);
    }

    .auth-image-content img {
        width: 190px;
    }

    .auth-image-tagline {
        font-size: 1.2rem;
        max-width: 260px;
    }
}

/* -------------------------------- الشاشة المعكوسة (دخول الموظفين) --------------------------------
   شاشة الموظفين مرآة لشاشة الأدمن: بالعربية تكون الصورة يمينًا والنموذج يسارًا
   (وبالإنجليزية العكس)، حتى تُميَّز الشاشتان عن بعضهما فورًا. */
@media (min-width: 900px) {
    .auth-page--reverse {
        flex-direction: row-reverse;
    }
}

/* الأزرار الثابتة تتبع لوحة النموذج، فتنتقل للطرف المقابل في الشاشة المعكوسة */
.auth-body--reverse .auth-fixed-actions {
    inset-inline-start: auto;
    inset-inline-end: 20px;
}

@media (max-width: 480px) {
    .auth-body--reverse .auth-fixed-actions {
        inset-inline-start: auto;
        inset-inline-end: 14px;
    }
}

/* -------------------------------- خطوات متعددة (نسيت كلمة السر) -------------------------------- */
.auth-step-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-6);
}

.auth-step-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(20, 20, 28, 0.12);
    color: var(--color-ink-900);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.auth-step-dot.active,
.auth-step-dot.done {
    background: var(--color-ink-900);
    color: var(--color-primary);
}

.auth-step-line {
    width: 28px;
    height: 2px;
    background: rgba(20, 20, 28, 0.15);
    flex-shrink: 0;
}

/* -------------------------------- حقول رمز التحقق (OTP) -------------------------------- */
.otp-inputs {
    display: flex;
    gap: 10px;
    justify-content: center;
    direction: ltr;
    margin-bottom: var(--space-6);
}

.otp-input {
    width: 52px;
    height: 52px;
    text-align: center;
    font-size: 1.3rem;
    font-weight: 800;
    border: 2px solid rgba(20, 20, 28, 0.15);
    border-radius: var(--radius-md);
    background: var(--color-white);
    font-family: inherit;
    color: var(--color-ink-900);
}

.otp-input:focus {
    outline: none;
    border-color: var(--color-brand-blue);
}

.auth-resend {
    text-align: center;
    font-size: 0.85rem;
    color: rgba(20, 20, 28, 0.6);
    margin-top: var(--space-4);
    margin-bottom: 0;
}

.auth-resend button,
.auth-resend a {
    background: none;
    border: none;
    color: var(--color-brand-blue);
    font-weight: 700;
    padding: 0;
}

.auth-resend button:disabled {
    color: rgba(20, 20, 28, 0.4);
    cursor: not-allowed;
}

/* -------------------------------- شاشة النجاح -------------------------------- */
.auth-success {
    text-align: center;
}

.auth-success-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(47, 174, 96, 0.12);
    color: var(--color-success);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-5);
}

.auth-success-icon svg {
    width: 30px;
    height: 30px;
}

@media (max-width: 480px) {
    .auth-form-panel {
        padding: 24px 16px 32px;
    }

    .otp-input {
        width: 44px;
        height: 44px;
    }

    .auth-fixed-actions {
        top: 14px;
        inset-inline-start: 14px;
    }

    .auth-fixed-btn {
        width: 42px;
        height: 42px;
    }
}
