/* ============================================================================
   بوابة المواهب الموسمية — شركة الحلول التقنية المتكاملة
   نظام تصميم موحّد: هوية الشعار (تركوازي)، وضع ليلي كامل، خطوط عربية مستضافة ذاتياً.
   ============================================================================ */

@import url("/lib/fonts/fonts.css");

/* ---------------------------------------------------------------- الهوية */
:root {
    /* ألوان مستخرجة من شعار الشركة */
    --brand-900: #075971;
    --brand-700: #0e7a96;   /* التركوازي العميق — اللون الأساسي */
    --brand-500: #1596b4;
    --brand-300: #5fb4cf;   /* السماوي الفاتح — اللون الثانوي */
    --brand-100: #ddeff5;

    --ok: #0f9d58;
    --warn: #d98324;
    --err: #c0392b;

    /* أسطح ونصوص (الوضع النهاري) */
    --bg: #f4f7f9;
    --surface: #ffffff;
    --surface-2: #fbfcfd;
    --ink: #16242c;
    --ink-soft: #5b6b75;
    --line: #dfe7ec;
    --shadow: 0 1px 2px rgba(7, 89, 113, .05), 0 8px 24px -12px rgba(7, 89, 113, .18);

    --radius: 14px;
    --radius-sm: 10px;

    /* الخط الاساسي مطابق لمنصة وفادة: Almarai باوزان 300/400/700/800 */
    --font-body: "Almarai", "Tajawal", "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
    --font-display: "Almarai", "Tajawal", "Readex Pro", sans-serif;
}

/* ------------------------------------------------------- الوضع الليلي */
/* مهم: نعيد تعريف متغيّرات Bootstrap أيضاً وإلا بقيت الأدوات (text-muted،
   card، table، nav-tabs…) بألوان الوضع النهاري وتصبح غير مقروءة. */
[data-theme="dark"] {
    --bg: #0d1519;
    --surface: #14212a;
    --surface-2: #1b2b35;
    --ink: #e8f1f5;
    --ink-soft: #a7bcc7;
    --line: #2a4250;
    --brand-100: #17394a;
    --brand-300: #7cc7de;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .7);

    --bs-body-color: #e8f1f5;
    --bs-body-bg: #0d1519;
    --bs-secondary-color: #a7bcc7;
    --bs-tertiary-color: #8ba6b3;
    --bs-emphasis-color: #ffffff;
    --bs-border-color: #2a4250;
    --bs-heading-color: #e8f1f5;
    --bs-link-color: #7cc7de;
    --bs-link-hover-color: #a3d9e9;
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0d1519; --surface: #14212a; --surface-2: #1b2b35;
        --ink: #e8f1f5; --ink-soft: #a7bcc7; --line: #2a4250;
        --brand-100: #17394a; --brand-300: #7cc7de;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .7);
        --bs-body-color: #e8f1f5; --bs-body-bg: #0d1519;
        --bs-secondary-color: #a7bcc7; --bs-tertiary-color: #8ba6b3;
        --bs-emphasis-color: #fff; --bs-border-color: #2a4250;
        --bs-heading-color: #e8f1f5; --bs-link-color: #7cc7de;
        color-scheme: dark;
    }
}

/* في الوضع الليلي: أدوات Bootstrap النصية تتبع لوننا */
[data-theme="dark"] .text-muted,
[data-theme="dark"] .form-text { color: var(--ink-soft) !important; }
[data-theme="dark"] .alert-light { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
[data-theme="dark"] .btn-outline-secondary { color: var(--ink-soft); border-color: var(--line); }
[data-theme="dark"] .btn-outline-secondary:hover { background: var(--surface-2); color: var(--ink); }

/* ------------------------------------------------- الأساس + فوتر ثابت أسفل */
html, body { height: 100%; }
body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--ink);
    font-size: .95rem;
    /* الفوتر يلتصق بأسفل الشاشة دائماً مهما قلّ المحتوى */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background .25s ease, color .25s ease;
}
main { flex: 1 0 auto; }
.app-footer { flex-shrink: 0; }

h1, h2, h3, .display-font { font-family: var(--font-display); font-weight: 700; letter-spacing: -.01em; }
a { color: var(--brand-700); text-decoration: none; }
a:hover { color: var(--brand-500); text-decoration: underline; }
a.btn:hover, a.step:hover, a.navbar-brand:hover { text-decoration: none; }
/* الروابط النصية فقط — لا تطبق على الازرار ولا المراحل ولا عناصر التنقل،
   والا اخذت كلها لون الرابط فاختفى الفرق بين الصفحة الحالية وبقية العناصر */
[data-theme="dark"] a:not(.btn):not(.step):not(.navbar-brand):not(.nav-link) { color: var(--brand-300); }

body::before {
    content: ""; position: fixed; inset: 0; z-index: -1;
    background:
        radial-gradient(60rem 30rem at 85% -10%, color-mix(in srgb, var(--brand-300) 16%, transparent), transparent 60%),
        radial-gradient(50rem 26rem at -10% 10%, color-mix(in srgb, var(--brand-700) 10%, transparent), transparent 55%);
    pointer-events: none;
}

/* ------------------------------------------------------ الشريط العلوي */
.app-navbar {
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(140%) blur(10px);
    border-bottom: 1px solid var(--line);
    padding-block: .5rem;
}
.app-navbar .navbar-brand { display: flex; align-items: center; gap: .7rem; padding-block: .35rem; }
.app-navbar .navbar-brand img { height: 38px; width: auto; }
.app-navbar .brand-text {
    font-family: var(--font-display); font-weight: 700; font-size: 1rem;
    color: var(--ink); line-height: 1.35;
}
/* مسافة واضحة بين اسم النظام واسم الشركة */
.app-navbar .brand-text small {
    display: block; font-size: .72rem; color: var(--ink-soft);
    font-weight: 400; margin-top: .18rem; line-height: 1.3;
}

/* عناصر القائمة: تبدو قابلة للنقر من اول نظرة لا بعد مرور المؤشر.
   لكل عنصر اطار وخلفية خفيفة في وضع السكون، ويشتد التمييز عند المرور والتفعيل. */
.app-navbar .navbar-nav { gap: .4rem; align-items: center; }
/* تنقل نظيف بلا اطارات ولا تعبئة: نص واضح، ومؤشر الصفحة الحالية خط سفلي بلون
   الهوية — نفس فكرة خط عناوين شاشات الدخول، فيتوحد اسلوب التمييز في النظام كله.
   عند المرور يظهر الخط بشكل اخف، فيعرف المستخدم ان العنصر قابل للنقر. */
.app-navbar .nav-link {
    position: relative;
    color: var(--ink); font-weight: 600; font-size: .875rem;
    padding: .45rem .8rem .55rem; border: 0; background: transparent; line-height: 1.25;
    border-radius: 0;
    transition: color .15s;
}
.app-navbar .nav-link::after {
    content: ""; position: absolute; inset-inline: .8rem; bottom: 0;
    height: 3px; border-radius: 3px;
    background: linear-gradient(90deg, var(--brand-300), var(--brand-700), var(--brand-300));
    transform: scaleX(0); transform-origin: center;
    transition: transform .2s ease, opacity .2s ease;
    opacity: .55;
}
.app-navbar .nav-link i { opacity: .75; margin-inline-end: .35rem; }
.app-navbar .nav-link:hover { color: var(--brand-700); text-decoration: none; }
.app-navbar .nav-link:hover::after { transform: scaleX(1); }
.app-navbar .nav-link.active { color: var(--brand-900); font-weight: 700; }
.app-navbar .nav-link.active::after { transform: scaleX(1); opacity: 1; }
.app-navbar .nav-link.active i { opacity: 1; }
[data-theme="dark"] .app-navbar .nav-link { color: var(--ink); }
[data-theme="dark"] .app-navbar .nav-link:hover,
[data-theme="dark"] .app-navbar .nav-link.active { color: var(--brand-300); }

/* على الشاشات الصغيرة تفتح القائمة عموديا: الخط السفلي يصبح خطا جانبيا
   لان الخطوط السفلية المتتالية تبدو كفواصل لا كمؤشر صفحة */
@media (max-width: 991.98px) {
    .app-navbar .navbar-nav { align-items: stretch; margin-block: .6rem; gap: .1rem; }
    .app-navbar .nav-link { text-align: start; padding-block: .6rem; }
    .app-navbar .nav-link::after {
        inset-inline: auto; inset-inline-start: 0; top: .35rem; bottom: .35rem;
        width: 3px; height: auto;
        transform: scaleY(0); transform-origin: center;
    }
    .app-navbar .nav-link:hover::after,
    .app-navbar .nav-link.active::after { transform: scaleY(1); }
}

/* زر السمة بنفس حدة الاطراف لا دائرة، ليتناسق مع الازرار وعناصر التنقل */
.theme-toggle {
    border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-soft);
    width: 38px; height: 38px; border-radius: var(--radius-sm);
    display: inline-flex; align-items: center; justify-content: center;
    transition: background .15s, color .15s, border-color .15s; cursor: pointer; font-size: .95rem;
}
.theme-toggle:hover { color: var(--brand-700); border-color: var(--brand-300); background: var(--brand-100); }
[data-theme="dark"] .theme-toggle:hover { color: var(--brand-300); }

/* ------------------------------------------------------------ البطاقات */
.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    color: var(--ink);
}
.card-header {
    background: transparent; color: var(--ink);
    border-bottom: 1px solid var(--line);
    font-family: var(--font-display); font-weight: 700; font-size: .95rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius) var(--radius) 0 0 !important;
}
.card-body { padding: 1.25rem; }
/* الشريط اللوني رسم في خلفية البطاقة لا عنصر مطلق يحتاج overflow:hidden،
   لان القص كان يقطع القوائم المنسدلة المفتوحة داخل البطاقة. */
/* خط تدرج الهوية اعلى البطاقة — نفس مخرج بطاقات الدخول والشريط العلوي (اطراف شفافة)،
   والوانه من متغيرات الهوية فيتبدل مع لون كل شركة */
.card-accent { position: relative; overflow: hidden; }
.card-accent::before {
    content: ""; position: absolute; inset-inline: 0; top: 0; height: 3px;
    background: linear-gradient(90deg, transparent, var(--brand-300), var(--brand-700), var(--brand-300), transparent);
    pointer-events: none;
}

/* -------------------------------------------------- رأس الصفحة الموحّد */
.page-head { margin-bottom: 1.25rem; }
.page-head h1 {
    font-size: 1.3rem; font-weight: 700; color: var(--ink);
    margin: 0 0 .3rem; display: flex; align-items: center; gap: .6rem;
}
.page-head h1::before {
    content: ""; width: 4px; height: 1.1em; border-radius: 4px;
    background: linear-gradient(180deg, var(--brand-500), var(--brand-700));
}
.page-head p { color: var(--ink-soft); font-size: .875rem; margin: 0; }

.section-title {
    font-family: var(--font-display); font-size: .9rem; font-weight: 700;
    color: var(--brand-700);
    display: flex; align-items: center; gap: .6rem; margin: 0 0 1rem;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
[data-theme="dark"] .section-title { color: var(--brand-300); }

/* ------------------------------------------------------- مراحل الطلب */
.stepper { display: flex; gap: .5rem; flex-wrap: wrap; }
.stepper .step {
    flex: 1 1 150px; min-width: 150px;
    display: flex; align-items: center; gap: .65rem;   /* مسافة بين الرقم والنص */
    padding: .75rem .85rem; border-radius: var(--radius-sm);
    background: var(--surface-2); border: 1px solid var(--line);
    color: var(--ink-soft); font-size: .85rem; font-weight: 500;
    text-decoration: none; transition: .18s; cursor: pointer;
}
.stepper .step:hover {
    border-color: var(--brand-300); color: var(--brand-700);
    text-decoration: none; transform: translateY(-1px);
}
.stepper .step .step-num {
    flex: 0 0 26px; height: 26px; border-radius: 50%;
    display: grid; place-items: center; font-size: .78rem; font-weight: 700;
    background: var(--line); color: var(--ink-soft); transition: .18s;
}
/* مرحلة مكتملة */
.stepper .step.done { border-color: color-mix(in srgb, var(--ok) 40%, transparent); color: var(--ink); }
.stepper .step.done .step-num { background: var(--ok); color: #fff; }
/* المرحلة الحالية */
.stepper .step.current {
    background: var(--brand-100); border-color: var(--brand-500);
    color: var(--brand-900); font-weight: 700;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-300) 25%, transparent);
}
.stepper .step.current .step-num { background: var(--brand-700); color: #fff; }
[data-theme="dark"] .stepper .step.current { color: var(--brand-300); }
/* مرحلة متبقية */
.stepper .step.pending { opacity: .72; }

/* خطوات الصفحة الرئيسية — تصبح روابط بعد تسجيل الدخول */
.home-step {
    color: inherit; padding: .45rem .5rem; margin: -.45rem -.5rem;
    border-radius: var(--radius-sm); transition: background .15s, transform .15s;
}
.home-step:hover { background: var(--surface-2); transform: translateX(-2px); text-decoration: none; color: inherit; }
.home-step.is-static { pointer-events: none; }

/* ----------------------------------------------------- شارة حالة الطلب */
.status-hero { text-align: center; padding: .5rem 0 .25rem; }
.status-hero .status-pill {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .55rem 1.15rem; border-radius: 999px;
    background: var(--brand-100); color: var(--brand-900);
    border: 1px solid var(--brand-300);
    font-family: var(--font-display); font-weight: 700; font-size: 1rem;
}
[data-theme="dark"] .status-hero .status-pill { color: var(--brand-300); }
.status-hero .status-dot {
    width: 9px; height: 9px; border-radius: 50%; background: var(--brand-700);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-300) 35%, transparent);
}
.status-hero .status-sub { color: var(--ink-soft); font-size: .82rem; margin-top: .5rem; }

.badge-status {
    display: inline-block;
    font-size: .78rem; font-weight: 600; padding: .35rem .75rem;
    border-radius: 999px; background: var(--brand-100); color: var(--brand-900);
    border: 1px solid color-mix(in srgb, var(--brand-300) 55%, transparent);
}
[data-theme="dark"] .badge-status { color: var(--brand-300); }

/* ------------------------------------------------------------- النماذج */
label.form-label { font-weight: 600; font-size: .85rem; color: var(--ink-soft); margin-bottom: .35rem; }
/* ملاحظة: يستخدم background-color لا الاختصار background، لان الاختصار يصفر
   خصائص صورة الخلفية (repeat/size/position) فيتكرر سهم القائمة عبر الحقل كله. */
.form-control, .form-select {
    background-color: var(--surface-2); color: var(--ink);
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    /* مسافة داخلية مريحة حتى لا تلتصق القيمة بالاطار */
    padding: .65rem .9rem; min-height: 46px; font-size: .92rem;
    transition: border-color .15s, box-shadow .15s, background-color .15s;
}
/* سهم القائمة مرسوم مرة واحدة على جانب البداية، ولونه يتبع السمة */
.form-select {
    padding-inline-end: 2.4rem;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%235b6b75' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left .9rem center;
    background-size: 15px 11px;
}
.form-control::placeholder { color: color-mix(in srgb, var(--ink-soft) 60%, transparent); }
.form-control:focus, .form-select:focus {
    background-color: var(--surface); border-color: var(--brand-500); color: var(--ink);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-300) 32%, transparent);
}
.form-control:disabled, .form-control[readonly] { background-color: var(--bg); color: var(--ink-soft); }
.form-text { font-size: .78rem; color: var(--ink-soft); }
[data-theme="dark"] .form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23a7bcc7' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

/* ------------------------------------------------------------- الأزرار */
.btn { border-radius: var(--radius-sm); font-weight: 600; font-size: .9rem; padding: .6rem 1.25rem; }
.btn-brand {
    background: linear-gradient(180deg, var(--brand-500), var(--brand-700));
    border: none; color: #fff; box-shadow: 0 1px 3px rgba(7, 89, 113, .3);
}
.btn-brand:hover { background: linear-gradient(180deg, var(--brand-700), var(--brand-900)); color: #fff; }
.btn-outline-brand { border: 1px solid var(--brand-300); color: var(--brand-700); background: transparent; }
.btn-outline-brand:hover { background: var(--brand-100); color: var(--brand-900); }
[data-theme="dark"] .btn-outline-brand { color: var(--brand-300); }
[data-theme="dark"] .btn-outline-brand:hover { color: #fff; background: var(--brand-700); }
.btn-outline-brand.active {
    background: linear-gradient(180deg, var(--brand-500), var(--brand-700));
    border-color: var(--brand-700); color: #fff;
}
[data-theme="dark"] .btn-outline-brand.active { color: #fff; }

/* بطاقة جهة في شاشة «اختر الجهة» — الوان الهوية حصرا */
.company-choice {
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--ink); text-decoration: none;
}
.company-choice:hover {
    border-color: var(--brand-500); background: var(--brand-100); color: var(--brand-900);
    text-decoration: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-300) 25%, transparent);
}
[data-theme="dark"] .company-choice:hover { color: var(--brand-300); }
.company-choice img { width: 44px; height: 44px; object-fit: contain; flex-shrink: 0; }
.btn-sm { font-size: .82rem; padding: .4rem .85rem; min-height: 0; }

/* --------------------------------------------------------------- الجداول */
.table { color: var(--ink); --bs-table-bg: transparent; --bs-table-color: var(--ink); }
.table thead th {
    background: var(--surface-2); color: var(--ink-soft);
    font-size: .82rem; font-weight: 700; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td, .table th { border-color: var(--line); vertical-align: middle; padding: .7rem .8rem; }
.table tbody tr:hover { background: var(--surface-2); }

/* --------------------------------------------------------- تبويبات */
.nav-tabs { border-bottom-color: var(--line); gap: .25rem; }
.nav-tabs .nav-link {
    color: var(--ink-soft); border: 1px solid transparent; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    padding: .6rem 1.1rem; font-weight: 600; font-size: .9rem;
}
.nav-tabs .nav-link:hover { color: var(--brand-700); border-color: var(--line) var(--line) transparent; }
.nav-tabs .nav-link.active {
    color: var(--brand-900); background: var(--surface);
    border-color: var(--line) var(--line) var(--surface);
}
[data-theme="dark"] .nav-tabs .nav-link.active { color: var(--brand-300); }

/* -------------------------------------------------- بطاقة هوية المتقدم */
.id-card { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.id-card .id-main { flex: 1 1 260px; min-width: 0; }
.id-card .id-name { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; margin-bottom: .3rem; }

/* بيانات مفصولة بفواصل بصرية من CSS لا برموز نصية */
.id-facts { display: flex; flex-wrap: wrap; gap: .35rem .9rem; font-size: .82rem; color: var(--ink-soft); }
.id-facts span { display: inline-flex; align-items: center; gap: .35rem; }
.id-facts span + span { padding-inline-start: .9rem; position: relative; }
.id-facts span + span::before {
    content: ""; position: absolute; inset-inline-start: 0; top: 50%;
    width: 4px; height: 4px; margin-top: -2px; border-radius: 50%; background: var(--line);
}
.id-facts i { color: var(--brand-500); }

/* الصورة الشخصية: مموهة افتراضيا مع زر لاظهارها */
.avatar {
    position: relative; flex: 0 0 auto; width: 82px; height: 82px;
    border-radius: 12px; overflow: hidden;   /* اطراف اهدأ تناسب بقية البطاقات */
    background: var(--brand-100); color: var(--brand-700);
    display: grid; place-items: center; font-weight: 700; font-size: 1.6rem;
    box-shadow: 0 6px 18px -10px rgba(7, 89, 113, .55);
    border: 1px solid var(--line);
}
[data-theme="dark"] .avatar { color: var(--brand-300); }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; transition: filter .25s ease; }
.avatar.blurred img { filter: blur(7px) saturate(.85); }
.avatar .avatar-toggle {
    position: absolute; inset-block-end: 0; inset-inline: 0;
    border: 0; padding: .18rem 0; font-size: .7rem; line-height: 1;
    background: color-mix(in srgb, #000 55%, transparent); color: #fff; cursor: pointer;
}
.avatar .avatar-toggle:hover { background: color-mix(in srgb, #000 72%, transparent); }

/* --------------------------------------------------- جدول المستندات */
.doc-row {
    display: flex; align-items: center; gap: .9rem;
    padding: .8rem .95rem; border: 1px solid var(--line);
    border-radius: var(--radius-sm); background: var(--surface-2); transition: .18s;
}
.doc-row:hover { border-color: var(--brand-300); background: var(--surface); }
.doc-row.is-missing { border-style: dashed; }
.doc-row.is-expired { border-color: color-mix(in srgb, var(--warn) 55%, transparent); }
.doc-main { flex: 1 1 220px; min-width: 0; }
.doc-name { font-weight: 600; font-size: .92rem; display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.doc-sub { font-size: .78rem; color: var(--ink-soft); margin-top: .15rem; }
.doc-actions { display: flex; gap: .35rem; flex-shrink: 0; }
.doc-actions .btn { width: 36px; height: 36px; padding: 0; display: grid; place-items: center; }

.tag {
    font-size: .68rem; font-weight: 700; padding: .12rem .5rem; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--line); color: var(--ink-soft);
}
.tag-required { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, transparent); }
.tag-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.tag-expired { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
/* الوان الحالة الداكنة لا تقرأ على خلفية ليلية، فترفع نسبة التباين */
[data-theme="dark"] .tag-required { color: #ff9c8f; border-color: color-mix(in srgb, #ff9c8f 45%, transparent); }
[data-theme="dark"] .tag-ok { color: #6ee7a0; border-color: color-mix(in srgb, #6ee7a0 45%, transparent); }
[data-theme="dark"] .tag-expired { color: #f3b563; border-color: color-mix(in srgb, #f3b563 45%, transparent); }

/* ------------------------------------------------------------ الملفات */
.file-card {
    display: flex; align-items: center; gap: .9rem;
    padding: .85rem .95rem; border: 1px solid var(--line);
    border-radius: var(--radius-sm); background: var(--surface-2); transition: .18s;
}
.file-card:hover { border-color: var(--brand-300); background: var(--surface); }
.file-icon {
    flex: 0 0 44px; height: 44px; border-radius: 11px;
    display: grid; place-items: center; font-weight: 700; font-size: .7rem;
    background: var(--brand-100); color: var(--brand-700);
}
[data-theme="dark"] .file-icon { color: var(--brand-300); }
.file-icon.pdf { background: #fdecea; color: #c0392b; }
.file-icon.jpg, .file-icon.jpeg, .file-icon.png { background: #eaf6ec; color: #0f9d58; }
.file-meta { flex: 1; min-width: 0; }
.file-name { font-weight: 600; font-size: .92rem; }
.file-sub { font-size: .8rem; color: var(--ink-soft); }
.file-missing { border-style: dashed; opacity: .9; }

/* أسماء الملفات: عزل اتجاهي حتى لا يختلط الامتداد والأرقام بالعربية */
.file-label { unicode-bidi: isolate; direction: rtl; }
.file-label bdi { unicode-bidi: isolate; }

.dropzone {
    border: 2px dashed var(--line); border-radius: var(--radius);
    padding: 1.9rem 1rem; text-align: center; color: var(--ink-soft);
    background: var(--surface-2); cursor: pointer; transition: .18s;
}
.dropzone:hover, .dropzone.dragover {
    border-color: var(--brand-500); background: var(--brand-100); color: var(--brand-900);
}
[data-theme="dark"] .dropzone:hover, [data-theme="dark"] .dropzone.dragover { color: var(--brand-300); }

/* ------------------------------------------------ التحميل: شريط + حاجب */
#loadingBar {
    position: fixed; inset-block-start: 0; inset-inline-start: 0; height: 3px; width: 0;
    background: linear-gradient(90deg, var(--brand-300), var(--brand-700));
    z-index: 2100; transition: width .25s ease, opacity .3s ease; opacity: 0;
}
#loadingBar.active { opacity: 1; }

/* حاجب كامل الشاشة (نافذة SweetAlert2) يمنع اي تفاعل او ضغط مكرر اثناء الارسال.
   الشعار في سطر مستقل بمنتصف الصفحة، والنص تحته متوسط ايضا. */
.app-loader.swal2-popup {
    background: transparent; box-shadow: none; padding: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.app-loader .swal2-html-container {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    margin: 0; padding: 0; width: 100%;
}
.app-loader .loader-logo { margin: 0 auto; flex: 0 0 auto; }
.app-loader .loader-text { width: 100%; text-align: center; margin-top: .9rem; }
.swal2-container.swal2-backdrop-show { background: color-mix(in srgb, var(--bg) 78%, transparent); }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

.loader-logo { position: relative; width: 96px; height: 96px; display: grid; place-items: center; }
.loader-logo img { width: 58px; height: auto; animation: pulse 1.6s ease-in-out infinite; }
.loader-logo::before, .loader-logo::after {
    content: ""; position: absolute; inset: 0; border-radius: 50%;
    border: 3px solid transparent;
}
.loader-logo::before { border-top-color: var(--brand-700); animation: spin 1.1s linear infinite; }
.loader-logo::after { border-bottom-color: var(--brand-300); animation: spin 1.6s linear infinite reverse; }
.loader-text { color: var(--ink-soft); font-size: .88rem; font-weight: 500; }
@keyframes pulse { 0%, 100% { opacity: .95; transform: scale(1) } 50% { opacity: .6; transform: scale(.93) } }
@keyframes spin { to { transform: rotate(360deg) } }

.is-busy { pointer-events: none; opacity: .6; }

/* ------------------------------------------------ هياكل التحميل (skeleton) */
.sk-line {
    height: .78rem; border-radius: 6px; margin-bottom: .6rem;
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 37%, var(--surface-2) 63%);
    background-size: 400% 100%; animation: skshine 1.3s ease infinite;
}
.sk-line:last-child { margin-bottom: 0; }
@keyframes skshine { 0% { background-position: 100% 0 } 100% { background-position: 0 0 } }

/* اثناء تحميل نموذج: تظهر الحقول كهياكل بدل صناديق فارغة */
form.is-loading .form-control,
form.is-loading .form-select {
    color: transparent; pointer-events: none;
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 37%, var(--surface-2) 63%);
    background-size: 400% 100%; animation: skshine 1.3s ease infinite;
}
form.is-loading button[type=submit] { pointer-events: none; opacity: .55; }

/* ------------------------------- بطاقات الاختيار (بديل مربعات bootstrap) */
/* الاقرارات والاختيارات الثنائية تبقى radio/checkbox دلاليا (نص الاقرار جزء منها،
   وتحويلها لقوائم يخفي النص ويزيد النقرات) لكن تعرض كبطاقة كاملة قابلة للنقر. */
.choice {
    display: flex; align-items: flex-start; gap: .7rem;
    padding: .8rem 1rem; margin-bottom: .6rem;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--surface-2); cursor: pointer;
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.choice:hover { border-color: var(--brand-300); background: var(--surface); }
.choice input {
    flex: 0 0 auto; width: 1.1rem; height: 1.1rem; margin: .12rem 0 0;
    accent-color: var(--brand-700); cursor: pointer;
}
.choice .choice-text { font-size: .9rem; line-height: 1.7; color: var(--ink); }
.choice.is-checked {
    border-color: var(--brand-500);
    background: color-mix(in srgb, var(--brand-100) 55%, var(--surface));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-300) 20%, transparent);
}
.choice.is-checked .choice-text { font-weight: 600; color: var(--brand-900); }
[data-theme="dark"] .choice.is-checked .choice-text { color: var(--brand-300); }

/* صف بطاقات متجاورة (اختيار من عدة بدائل) */
.choice-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.choice-row .choice { flex: 1 1 240px; align-items: center; margin-bottom: 0; }

/* لوحة الاقرار والتعهد: تمييز بصري لانها اخر خطوة قبل الارسال */
.consent {
    border: 1px solid var(--brand-300); border-radius: var(--radius);
    background: color-mix(in srgb, var(--brand-100) 35%, var(--surface));
    padding: 1.1rem 1.2rem; margin-bottom: 1.25rem;
}
.consent .choice { background: var(--surface); }
.consent-title {
    display: flex; align-items: center; gap: .5rem;
    font-weight: 700; color: var(--brand-900); margin-bottom: .75rem; font-size: .95rem;
}
[data-theme="dark"] .consent-title { color: var(--brand-300); }

/* ------------------------------------------- تمييز الحقول الالزامية */
/* نجمة بلون التنبيه بعد كل تسمية حقل الزامي (وعناوين اعمدة الجداول الالزامية).
   تضاف تلقائيا من app.js للتسميات، وتكتب يدويا على عناوين الجداول. */
.is-required::after {
    content: "*"; color: var(--err); font-weight: 700;
    margin-inline-start: .25rem;
}
[data-theme="dark"] .is-required::after { color: #ff9c8f; }

/* -------------------------------------------- رسائل التحقق تحت الحقول */
.form-control.is-invalid, .form-select.is-invalid,
.ts-wrapper.is-invalid .ts-control {
    border-color: var(--err) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--err) 18%, transparent) !important;
}
[data-theme="dark"] .form-control.is-invalid,
[data-theme="dark"] .form-select.is-invalid,
[data-theme="dark"] .ts-wrapper.is-invalid .ts-control { border-color: #ff9c8f !important; }

.field-error {
    display: flex; align-items: center; gap: .35rem;
    color: var(--err); font-size: .78rem; margin-top: .3rem;
}
[data-theme="dark"] .field-error { color: #ff9c8f; }
.field-error i { font-size: .85em; }

/* ----------------------------------------------- قائمة نواقص المرحلة */
/* بالوان الهوية لا بالوان تحذير غريبة عنها */
.alert-missing {
    border: 1px solid var(--brand-300);
    border-inline-start: 4px solid var(--brand-700);
    background: color-mix(in srgb, var(--brand-100) 55%, var(--surface));
    color: var(--ink); border-radius: var(--radius-sm);
    padding: .85rem 1.05rem; font-size: .88rem; margin-bottom: 1rem;
}
[data-theme="dark"] .alert-missing {
    background: color-mix(in srgb, var(--brand-100) 60%, var(--surface));
    border-color: color-mix(in srgb, var(--brand-300) 45%, transparent);
}
.alert-missing .alert-missing-title {
    display: flex; align-items: center; gap: .5rem;   /* مسافة بين الايقونة والنص */
    font-weight: 700; color: var(--brand-900); margin-bottom: .45rem;
}
[data-theme="dark"] .alert-missing .alert-missing-title { color: var(--brand-300); }
.alert-missing .alert-missing-title i { color: var(--brand-700); font-size: .95em; }
[data-theme="dark"] .alert-missing .alert-missing-title i { color: var(--brand-300); }

/* مؤشر صلاحية الوثيقة في صفحة التحقق العامة (الامر 41 §5): سارية بلون --ok، وغير سارية بلون --warn */
.verify-state {
    display: inline-flex; align-items: center; gap: .55rem;
    padding: .55rem 1.2rem; border-radius: 999px;
    font-family: var(--font-display); font-weight: 700; font-size: 1.05rem;
    border: 1px solid currentColor;
}
.verify-state.is-valid   { color: var(--ok);   background: color-mix(in srgb, var(--ok) 10%, var(--surface)); }
.verify-state.is-invalid { color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, var(--surface)); }
.verify-facts dd { margin-bottom: .55rem; }

/* رقم الوثيقة (CT1-1448-000045) في «وثائقي» وتحت زر «اطلع على العقد» */
.doc-serial { font-family: var(--bs-font-monospace); font-size: .8rem; color: var(--ink-soft); }

.missing-list { margin: 0; padding-inline-start: 1.2rem; text-align: start; }
.missing-list li { margin-bottom: .25rem; }
.missing-list li::marker { color: var(--brand-500); }

/* ------------------------------------------------------- صفحات الدخول */
.auth-wrap { max-width: 440px; margin: 3rem auto; }
.auth-logo { display: block; height: 58px; margin: 0 auto 1.5rem; }
/* العنوان في منتصف البطاقة مع خط تمييز متوسط تحته */
.auth-title {
    font-family: var(--font-display); font-weight: 700; color: var(--ink);
    position: relative; display: block; text-align: center; padding-bottom: .65rem;
}
.auth-title::after {
    content: ""; position: absolute; bottom: 0; inset-inline: 0; margin-inline: auto;
    width: 88px; height: 3px; border-radius: 3px;
    background: linear-gradient(90deg, var(--brand-300), var(--brand-700), var(--brand-300));
}

/* ------------------------------------------------------------- التذييل */
.app-footer { border-top: 1px solid var(--line); background: var(--surface); margin-top: 2.5rem; }

/* ---------------------------------------------- ظهور متدرّج عند التحميل */
.reveal { animation: rise .45s cubic-bezier(.22, .9, .3, 1) both; }
.reveal:nth-child(2) { animation-delay: .06s; }
.reveal:nth-child(3) { animation-delay: .12s; }
.reveal:nth-child(4) { animation-delay: .18s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* --------------------------------------- مواءمة المكتبات مع الوضع الليلي */
.ts-control, .ts-dropdown {
    background: var(--surface-2) !important; color: var(--ink) !important;
    border-color: var(--line) !important; border-radius: var(--radius-sm) !important;
}
/* مسافة داخلية متساوية على الجانبين — تسبقها قواعد Tom Select الأعلى تخصيصاً
   لذا نرفع التخصيص هنا حتى لا تلتصق القيمة بإطار القائمة في وضع RTL */
.ts-wrapper .ts-control,
.ts-wrapper.single .ts-control,
.ts-wrapper.multi .ts-control {
    min-height: 46px; padding: .55rem .9rem !important; font-size: .92rem;
}
.ts-wrapper .ts-control > * { margin-inline: 0 !important; }
.ts-control input { color: var(--ink) !important; }
.ts-dropdown .option { padding: .5rem .9rem; }
.ts-dropdown .active { background: var(--brand-100) !important; color: var(--brand-900) !important; }
[data-theme="dark"] .ts-dropdown .active { color: var(--brand-300) !important; }
.ts-wrapper.focus .ts-control {
    border-color: var(--brand-500) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-300) 32%, transparent) !important;
}

/* flatpickr — منتقي التاريخ الموحد: الوان الهوية، خط الواجهة، ووضع ليلي متسق */
.flatpickr-calendar {
    direction: rtl;             /* المكتبة بلا دعم RTL: الاتجاه هنا يقلب الشبكة والاسهم معا */
    font-family: var(--font-body);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .12);
    background: var(--surface);
}
.flatpickr-months .flatpickr-month,
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-weekdays, span.flatpickr-weekday { background: transparent; color: var(--ink); }
.flatpickr-day.selected, .flatpickr-day.selected:hover,
.flatpickr-day.startRange, .flatpickr-day.endRange {
    background: var(--brand-700); border-color: var(--brand-700); color: #fff;
}
.flatpickr-day.today { border-color: var(--brand-300); }
.flatpickr-day.today:hover { background: var(--brand-100); color: var(--brand-900); }
.flatpickr-day:hover { background: var(--brand-100); border-color: var(--brand-100); }
.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg { fill: var(--brand-700); }
.hijri-hint { min-height: 1.25rem; }
[data-theme="dark"] .flatpickr-calendar { background: var(--surface); color: var(--ink); }
[data-theme="dark"] .flatpickr-day { color: var(--ink); }
[data-theme="dark"] .flatpickr-day.flatpickr-disabled,
[data-theme="dark"] .flatpickr-day.prevMonthDay,
[data-theme="dark"] .flatpickr-day.nextMonthDay { color: var(--ink-soft); }
[data-theme="dark"] .flatpickr-day:hover { background: var(--brand-100); color: var(--brand-300); }
[data-theme="dark"] .flatpickr-months .flatpickr-prev-month svg,
[data-theme="dark"] .flatpickr-months .flatpickr-next-month svg { fill: var(--ink); }

.swal2-popup { font-family: var(--font-body); border-radius: var(--radius); }
.swal2-title { font-family: var(--font-display); }
.swal2-styled.swal2-confirm { background: var(--brand-700) !important; border-radius: var(--radius-sm) !important; }
.swal2-styled.swal2-cancel { border-radius: var(--radius-sm) !important; }
[data-theme="dark"] .swal2-popup { background: var(--surface); color: var(--ink); }
[data-theme="dark"] .swal2-html-container,
[data-theme="dark"] .swal2-title { color: var(--ink) !important; }
[data-theme="dark"] .swal2-toast { background: var(--surface) !important; }

/* -------------------------------------------------- اشرطة التمرير بتدرج الهوية
   webkit اولا (كروم/ايدج/سفاري)؛ وscrollbar-color القياسية داخل @supports not
   selector(::-webkit-scrollbar) فقط — كروم الحديث يتجاهل تنسيقات webkit متى وجد
   scrollbar-color، فوضعهما معا يفقد التدرج. */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--surface-2, #f1f3f5); }
::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--brand-300), var(--brand-700));
    border-radius: 8px;
    border: 2px solid var(--surface-2, #f1f3f5);
}
::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--brand-500), var(--brand-900));
}
@supports not selector(::-webkit-scrollbar) {
    * { scrollbar-color: var(--brand-700) var(--surface-2, #f1f3f5); scrollbar-width: thin; }
}

/* -------------------------------------------------- تحسين شريط التنقل (2026-08-23)
   الشعار من هوية الشركة قد يصل باي ابعاد — يقيد بارتفاع الشريط ولا يمدده ابدا. */
.app-navbar .navbar-brand img {
    height: 44px;
    max-width: 150px;
    width: auto;
    object-fit: contain;
}
.app-navbar { padding-block: .45rem; }
.app-navbar .navbar-nav { gap: .15rem; }
.app-navbar .nav-link { padding-inline: .8rem; white-space: nowrap; }

/* شريحة هوية المستخدم: الرقم بايقونة في اطار هادئ بدل نص عائم */
.user-chip {
    align-items: center; gap: .45rem;
    padding: .3rem .7rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-2, #fbfcfd);
    color: var(--ink-soft, #5b6b73);
    font-size: .82rem;
    font-variant-numeric: tabular-nums;
    direction: ltr;
}
.user-chip i { color: var(--brand-500); }
[data-theme="dark"] .user-chip { background: var(--surface-2); color: var(--ink-soft); }

/* فاصل بصري رقيق بين الروابط ومجموعة المستخدم على الشاشات الواسعة */
@media (min-width: 992px) {
    .nav-user-cluster {
        margin-inline-start: .75rem;
        padding-inline-start: .9rem;
        border-inline-start: 1px solid var(--line);
    }
}

/* خط تدرج الهوية اسفل الشريط العلوي — نفس مخرج النظام الداخلي (app-topbar::after):
   يتلون تلقائيا بلوحة الشركة لان درجاته من متغيرات --brand-*. */
.app-navbar { position: sticky; }
.app-navbar::after {
    content: ""; position: absolute; inset-inline: 0; bottom: -2px; height: 2px;
    background: linear-gradient(90deg, transparent, var(--brand-300), var(--brand-700), var(--brand-300), transparent);
    opacity: .7; pointer-events: none;
}

/* ------------------------------------------- تحسين بطاقات الدخول (2026-08-23) */
/* خط تدرج الهوية اعلى البطاقة — نفس اسلوب خط الشريط العلوي وخط العنوان */
.auth-card { position: relative; overflow: hidden; }
.auth-card::before {
    content: ""; position: absolute; inset-inline: 0; top: 0; height: 3px;
    background: linear-gradient(90deg, transparent, var(--brand-300), var(--brand-700), var(--brand-300), transparent);
    pointer-events: none;
}
.auth-card .card-body { padding: 2rem 1.75rem 1.5rem; }
.auth-card .form-label { font-weight: 600; font-size: .85rem; }

/* مبدل غرض الدخول: بطاقتان مبوبتان بدل ازرار راديو عارية */
.purpose-seg { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.purpose-seg .purpose-input { position: absolute; opacity: 0; pointer-events: none; }
.purpose-opt {
    display: flex; flex-direction: column; align-items: center; gap: .3rem;
    text-align: center; cursor: pointer; margin: 0;
    padding: .8rem .6rem .7rem;
    border: 1.5px solid var(--line); border-radius: var(--radius-sm, 10px);
    background: var(--surface-2, #fbfcfd);
    transition: border-color .15s, background .15s, color .15s;
}
.purpose-opt i { font-size: 1.15rem; color: var(--ink-soft, #5b6b73); transition: color .15s; }
.purpose-opt .purpose-t { font-weight: 700; font-size: .84rem; color: var(--ink); line-height: 1.4; }
.purpose-opt .purpose-s { font-size: .72rem; color: var(--ink-soft, #6b7a82); line-height: 1.5; }
.purpose-opt:hover { border-color: var(--brand-300); }
.purpose-input:checked + .purpose-opt {
    border-color: var(--brand-500);
    background: color-mix(in srgb, var(--brand-100) 65%, var(--surface));
    box-shadow: 0 0 0 1px var(--brand-500) inset;
}
.purpose-input:checked + .purpose-opt i,
.purpose-input:checked + .purpose-opt .purpose-t { color: var(--brand-700); }
[data-theme="dark"] .purpose-input:checked + .purpose-opt i,
[data-theme="dark"] .purpose-input:checked + .purpose-opt .purpose-t { color: var(--brand-300); }
.purpose-input:focus-visible + .purpose-opt { outline: 2px solid var(--brand-500); outline-offset: 2px; }

/* الكابتشا في سطر واحد: زر التحديث + الصورة + الحقل */
.captcha-row { display: flex; align-items: stretch; gap: .5rem; }
.captcha-row img {
    height: 46px; width: auto; border-radius: var(--radius-sm, 10px);
    border: 1px solid var(--line);
}
.captcha-row .captcha-refresh {
    width: 46px; height: 46px; flex: 0 0 46px;
    display: grid; place-items: center;
    border: 1px solid var(--line); border-radius: var(--radius-sm, 10px);
    background: var(--surface-2, #fbfcfd); color: var(--ink-soft, #5b6b73);
    transition: color .15s, border-color .15s, background .15s;
}
.captcha-row .captcha-refresh:hover { color: var(--brand-700); border-color: var(--brand-300); background: var(--brand-100); }
.captcha-row input {
    flex: 1 1 auto; min-width: 0; height: 46px;
    text-align: center; letter-spacing: .3em; text-transform: uppercase;
}
