:root {
    --ri-def-border: rgba(212, 175, 55, 0.4);
    --ri-def-focus: #f1c40f;
    --ri-def-glow: rgba(212, 175, 55, 0.2);
    --ri-def-text: #e0d5a3;
    --ri-def-icon: #f1c40f;
    --ri-def-bg: rgba(0, 0, 0, 0.3);
    --ri-def-placeholder: #b8a050;
    --ri-def-label: rgba(255, 255, 255, 0.8);
}

.royal-input-wrapper {
    width: 100%;
    margin-bottom: 15px;
}

.ri-label-text {
    display: block;
    text-align: right;
    font-size: 0.85rem;
    margin-bottom: 5px;
    opacity: 0.9;
    font-weight: bold;
    color: var(--ri-label, var(--ri-def-label));
}

.ri-group {
    position: relative;
    border: 1px solid var(--ri-border, var(--ri-def-border));
    border-radius: 12px;
    padding: 4px 6px;
    display: flex;
    align-items: center;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 0px 12px rgba(0, 0, 0, 0.39);
}

.ri-group:focus-within,
.ri-group.ri-active {
    border-color: var(--ri-focus, var(--ri-def-focus));
    box-shadow: 0 0 18px var(--ri-glow, var(--ri-def-glow));
}

.ri-icon-box {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    color: var(--ri-icon, var(--ri-def-icon));
    border-radius: 10px;
    margin-left: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.ri-field {
    border: none;
    outline: none;
    background: transparent;
    flex-grow: 1;
    padding: 5px;
    font-weight: 600;
    color: var(--ri-text, var(--ri-def-text));
    text-align: right;
    min-width: 0;
    direction: rtl;
}

.ri-field[type="email"],
.ri-field.ltr-input {
    direction: ltr;
    text-align: right;
}

.ri-field::placeholder {
    color: var(--ri-placeholder, var(--ri-def-placeholder));
    font-weight: 400;
    font-size: 0.85rem;
    font-style: italic;
    opacity: 1;
}

.ri-field::-ms-input-placeholder {
    color: var(--ri-placeholder, var(--ri-def-placeholder));
    font-weight: 400;
    font-size: 0.85rem;
    font-style: italic;
}

.ri-clear-btn {
    display: none;
    cursor: pointer;
    color: var(--ri-icon, var(--ri-def-icon));
    opacity: 0.6;
    padding: 8px;
    font-size: 1rem;
    margin-right: 5px;
    z-index: 5;

    /* 🟢 التحريك النظيف مع إضافة منحنى (Spring) لإعطاء إحساس بالارتداد الفخم */
    transition: opacity 0.2s ease,
        color 0.2s ease,
        transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ri-clear-btn:hover {
    opacity: 1;
    color: #ff4d4d;
    transform: scale(1.1) translateZ(0);
}

.ri-clear-btn.show {
    display: block;
}

.ri-eye-btn {
    cursor: pointer;
    color: var(--ri-icon, var(--ri-def-icon));
    opacity: 0.7;
    padding: 8px;
    font-size: 1rem;
    /* 🟢 نفس التحريك النظيف للأداء العالي */
    transition: opacity 0.2s ease,
        color 0.2s ease,
        transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    margin-right: 2px;
    display: flex;
    align-items: center;
}

.ri-eye-btn:hover {
    opacity: 1;
    transform: scale(1.1) translateZ(0);
}

select.ri-field {
    display: block !important;
    bottom: 0;
    left: 0;
    padding: 0;
    margin: 0;
    border: none;
    opacity: 0 !important;
    position: absolute !important;
    z-index: -1 !important;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.ri-select-wrapper {
    position: relative;
    flex-grow: 1;
    display: flex;
    background: transparent !important;
    border: none !important;
}

.ri-select-trigger {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0 5px;
    cursor: pointer;
    font-weight: 600;
    color: var(--ri-text, var(--ri-def-text));
    height: 100%;
    min-height: 30px;
    user-select: none;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.ri-select-trigger.placeholder-style {
    color: var(--ri-placeholder, var(--ri-def-placeholder));
    font-weight: 400;
    font-size: 0.85rem;
    font-style: italic;
}

.ri-select-arrow {
    font-size: 0.8rem;
    color: var(--ri-icon, var(--ri-def-icon));
    opacity: 0.7;
    transition: transform 0.3s;
    margin-right: 8px;
    pointer-events: none;

    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;

    margin-top: 4px;
}

.ri-select-wrapper.open .ri-select-arrow {
    transform: rotate(180deg);
}

.ri-options-list {
    position: fixed;
    display: block;
    min-width: 230px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.95);
    
    /* 🚀 1. الأساس للأداء العالي (للهواتف): لون شبه صلب يغني عن التمويه */
    background: rgba(20, 15, 15, 0.98); 
    backdrop-filter: none; /* إيقاف التمويه افتراضياً */
    -webkit-backdrop-filter: none;

    /* 🚀 2. إجبار المتصفح على عزل العنصر في طبقة رسومية مستقلة (GPU Layer) */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;

    opacity: 0;
    visibility: hidden;
    contain: content;
    will-change: transform, opacity;
    -webkit-transform: translateZ(0);
    transform: translateZ(0) translateY(-15px) scale(0.96);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 99999 !important;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 260px;
    overscroll-behavior: contain;
    padding: 5px 0;
}

.ri-options-list.show {
    opacity: 1;
    visibility: visible;
    /* الحفاظ على translateZ(0) لضمان بقائه في الطبقة المسرعة رسومياً */
    transform: translateZ(0) translateY(0) scale(1);
}

/* 1. تنسيق العنصر الأساسي */
.ri-option-item {
    position: relative;
    display: block;
    padding: 14px 22px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.75);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    cursor: pointer;
    text-align: right;
    margin: 4px 5px;

    /* 🔴 منع التلوين المباشر لمنع إعادة الرسم (Paint) */
    background-color: transparent !important;
    z-index: 1;

    /* 🟢 تقييد الحركة لتكون على الـ Transform واللون فقط */
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease;
}

.ri-option-item:last-of-type {
    border-bottom: none;
}

/* 🚀 2. الحل المعماري: طبقة وهمية مخصصة للـ Hover (مسرعة رسومياً) */
.ri-option-item::before {
    content: '';
    position: absolute;
    inset: 0;
    /* تغطي العنصر بالكامل */
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.08);
    /* لون التحويم الخاص بك */
    opacity: 0;
    /* مخفية افتراضياً */
    z-index: -1;
    pointer-events: none;
    /* 🟢 الأنيميشن هنا على الشفافية فقط (كارت الشاشة سيتولى الأمر بـ 60 إطار في الثانية) */
    transition: opacity 0.2s ease;
}

/* 🚀 3. تفاعلات الماوس النظيفة */
.ri-option-item:hover {
    color: #f65e5e;
    /* استخدام translate3d يجبر كارت الشاشة على تفعيل مسرع الهاردوير */
    transform: translate3d(-6px, 0, 0);
}

.ri-option-item:hover::before {
    opacity: 1;
    /* إظهار الخلفية دون أي جهد على المعالج */
}

/* 🚀 4. حالة الاختيار (Selected) */
.ri-option-item.selected {
    color: #ff9999;
    font-weight: 700;
}

.ri-option-item.selected::before {
    background-color: rgba(142, 14, 0, 0.25);
    opacity: 1;
}

/* ========================================= */
/* 🎚️ تنسيق شريط التمرير الموحد والاحترافي (Cross-Browser) */
/* ========================================= */

/* 1. دعم المتصفحات القياسية (Firefox و الحديثة) */
.ri-options-list {
    scrollbar-width: thin;
    scrollbar-color: rgba(212, 175, 55, 0.4) transparent;
    /* ذهبي ملكي شفاف يتناسب مع الثيم */
}

/* 2. دعم متصفحات Webkit (Chrome, Safari, Edge) */
.ri-options-list::-webkit-scrollbar {
    width: 6px;
}

.ri-options-list::-webkit-scrollbar-track {
    background: transparent;
    border: none;
}

.ri-options-list::-webkit-scrollbar-thumb {
    background-color: rgba(212, 175, 55, 0.3);
    /* لون ذهبي خافت */
    border-radius: 10px;
    transition: background-color 0.3s ease;
}

.ri-options-list::-webkit-scrollbar-thumb:hover {
    background-color: rgba(212, 175, 55, 0.6);
    /* سطوع ذهبي عند تمرير الماوس */
}

.ri-field:-webkit-autofill,
.ri-field:-webkit-autofill:hover,
.ri-field:-webkit-autofill:focus,
.ri-field:-webkit-autofill:active {
    transition: background-color 50000s ease-in-out 0s;
    -webkit-text-fill-color: var(--ri-text, var(--ri-def-text)) !important;
}

/* --- تنسيق حقل البحث ليتطابق مع الثيم الملكي (Royal Theme) --- */
.ri-group.ri-gradient-mode {
    /* نفس التدرج اللوني لزر الترتيب: خمري داكن مع أسود */
    background: linear-gradient(145deg, rgba(0, 0, 0, 0.8), rgba(60, 10, 10, 0.8)) !important;

    /* حدود ذهبية خافتة */
    border: 1px solid rgba(212, 175, 55, 0.4) !important;

    /* حواف دائرية بالكامل */
    border-radius: 50px !important;

    /* ظل خفيف */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3) !important;

    /* لون النص داخله */
    color: var(--royal-gold) !important;
}

/* عند الضغط داخل الحقل (Focus) */
.ri-group.ri-gradient-mode:focus-within {
    /* إضاءة الحدود باللون الذهبي */
    border-color: var(--royal-gold) !important;
    /* توهج ذهبي خفيف */
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.2) !important;
}

/* تنسيق الأيقونة (العدسة) */
.ri-group.ri-gradient-mode .ri-icon-box {
    background: transparent !important;
    /* خلفية شفافة لتبدو مدمجة */
    border: none !important;
    color: var(--royal-gold) !important;
    /* لون ذهبي للأيقونة */
    padding-left: 15px;
    /* إزاحة بسيطة للجمالية */
}

/* تنسيق النص الذي يكتبه المستخدم */
.ri-group.ri-gradient-mode input {
    color: var(--royal-gold) !important;
    /* الكتابة باللون الذهبي */
    font-weight: 500;
}

/* لون النص التوضيحي (Placeholder) */
.ri-group.ri-gradient-mode input::placeholder {
    color: rgba(212, 175, 55, 0.5) !important;
    /* ذهبي شفاف */
}

/* ========================================= */
/* 👑 التنسيق الملكي المدمج لحقل البحث */
/* ========================================= */

/* الحاوية العلوية للبحث */
.ri-search-box {
    padding: 8px 10px;
    /* 🔴 تم تقليل مسافات الحشو لتقليل المساحة المأخوذة */
    position: sticky;
    top: -5px;
    margin-top: -5px;
    background: #140f0f;
    /* 🔴 نفس لون القائمة المنسدلة بالضبط (لون صلب لمنع تداخل النصوص) */
    z-index: 10;
    border-bottom: 1px solid rgba(212, 175, 55, 0.15);
    margin-bottom: 4px;
    /* 🔴 تقليل المسافة السفلية */
    border-radius: 16px 16px 0 0;
}

/* غلاف الحقل لتنظيم الأيقونة */
.ri-search-input-wrapper {
    position: relative;
    width: 100%;
}

/* حقل البحث (الكبسولة المدمجة) */
.ri-search-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(212, 175, 55, 0.3);
    color: #d4af37;
    font-weight: 600;
    border-radius: 50px;
    padding: 6px 30px 6px 12px;
    /* 🔴 تقليل ارتفاع الحقل نفسه */
    font-size: 0.85rem;
    /* 🔴 تصغير الخط قليلاً ليتناسب مع الحجم الجديد */
    outline: none;
    direction: rtl;
    transition: border-color 0.3s ease,
        background-color 0.3s ease,
        box-shadow 0.3s ease,
        transform 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* تأثير التوهج عند الضغط داخل الحقل (Focus) */
.ri-search-input:focus {
    border-color: #d4af37;
    background: rgba(40, 5, 5, 0.8);
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.25), inset 0 2px 4px rgba(0, 0, 0, 0.5);
    transform: translateY(-1px);
}

/* نص الملاحظة (Placeholder) */
.ri-search-input::placeholder {
    color: rgba(212, 175, 55, 0.4);
    font-weight: 400;
    font-style: italic;
}

/* أيقونة العدسة */
.ri-search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(212, 175, 55, 0.4);
    font-size: 0.85rem;
    pointer-events: none;
    transition: color 0.3s ease, filter 0.3s ease;
}

/* توهج الأيقونة باللون الذهبي عند التركيز */
.ri-search-input:focus~.ri-search-icon {
    color: #d4af37;
    filter: drop-shadow(0 0 4px rgba(212, 175, 55, 0.6));
}

/* 🔴 تنسيق رسالة "لا توجد نتائج" المضافة حديثاً */
.ri-no-results {
    padding: 20px 10px;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9rem;
    font-weight: bold;
}

.ri-no-results i {
    display: block;
    font-size: 2rem;
    margin-bottom: 10px;
    color: rgba(212, 175, 55, 0.3);
}
/* ========================================= */
/* 🛡️ المحرك التكيفي للأداء (Adaptive Performance Engine) */
/* ========================================= */

/* 1. تشغيل التأثير الزجاجي (Glassmorphism) فقط على الشاشات الكبيرة (الحواسيب) 
   التي تمتلك كروت شاشة قوية قادرة على معالجة التمويه براحة تامة */
@media (min-width: 1024px) {
    /* نتأكد أولاً أن المتصفح يدعم الخاصية أصلاً */
    @supports (backdrop-filter: blur(12px)) or (-webkit-backdrop-filter: blur(12px)) {
        .ri-options-list {
            background: rgba(20, 15, 15, 0.85); /* تخفيف العتامة للسماح للزجاج بالظهور */
            backdrop-filter: blur(12px) saturate(140%);
            -webkit-backdrop-filter: blur(12px) saturate(140%);
        }
    }
}

/* 2. وضع توفير الطاقة والأداء (Battery & Performance Saver)
   إذا كان المستخدم قد فعل وضع "تقليل الحركة" في إعدادات الويندوز أو الهاتف المحمول */
@media (prefers-reduced-motion: reduce) {
    .ri-options-list {
        /* نقتل الحركة تماماً ونكتفي بالظهور والاختفاء اللحظي (0 ثانية) */
        transition: none !important; 
        transform: translateZ(0) translateY(0) scale(1) !important;
    }
    
    /* إلغاء حركة الزر x والعين لضمان أقصى سرعة */
    .ri-clear-btn, .ri-eye-btn {
        transition: none !important;
    }
}