/* ==========================================================================
   إصلاح وتطوير النوافذ المنبثقة العائمة المطور والمحمي (MODALS) - النسخة الاحترافية
   ========================================================================== */

:root {
    --modal-primary: #412E6D;
    --modal-primary-light: #6D5797;
    --modal-secondary: #63C1A3;
    --modal-border: #ECEEF5;
    --modal-text-dark: #1E1433;
    --modal-bg-light: #FCFBFF;
}

/* إجبار الغطاء الخلفي على عزل الشاشة بالكامل فوق عناصر الجدول */
.modal-overlay, #importModal {
    display: none; 
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(30, 20, 51, 0.6) !important; /* درجة بنفسجية مظلمة شفافة متناسقة مع السايد بار */
    backdrop-filter: blur(4px) !important; /* تأثير زجاجي ضبابي ناعم وعصري */
    z-index: 9999 !important; /* ضمان الظهور فوق كافة عناصر ومحتويات الجداول */
    align-items: center !important;
    justify-content: center !important;
    padding: 16px;
    box-sizing: border-box;
}

/* تفعيل الظهور المرن عند إضافة كلاس open عبر الجافاسكربت */
.modal-overlay.open, #importModal.open {
    display: flex !important;
    animation: fadeInModal 0.25s ease-out forwards;
}

/* صندوق النافذة الداخلي المنبثق المطور */
.modal-box {
    background: #ffffff;
    border-radius: 16px;
    padding: 30px;
    width: 100%;
    max-width: 520px; /* عرض متناسق ومريح للعين يطبق فقط على الصندوق المنبثق */
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(65, 46, 109, 0.2);
    border: 1px solid var(--modal-border);
    position: relative;
    box-sizing: border-box;
    transform: translateY(20px);
    animation: slideUpModal 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* تنسيق ترويسة النافذة المنبثقة */
.modal-box h3 {
    font-size: 18px;
    font-weight: 800;
    color: var(--modal-primary); /* لون هويتك البنفسجي الداكن */
    margin-top: 0;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #F0EDF8;
    padding-bottom: 12px;
}

/* ── توحيد وتجميل عناصر النماذج والحقول بداخل الصناديق المنبثقة ديناميكياً ── */
.modal-box .form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
    width: 100%;
    box-sizing: border-box;
}

.modal-box .form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--modal-primary-light);
}

.modal-box .form-group input, 
.modal-box .form-group select, 
.modal-box .form-group textarea {
    padding: 10px 14px;
    border: 1.5px solid #E0E0E0;
    border-radius: 8px;
    font-size: 13.5px;
    font-family: inherit;
    outline: none;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
    box-sizing: border-box;
}

.modal-box .form-group input:focus, 
.modal-box .form-group select:focus, 
.modal-box .form-group textarea:focus {
    border-color: var(--modal-primary-light);
    box-shadow: 0 0 0 3px rgba(109, 87, 151, 0.1);
}

.modal-box .form-group select {
    cursor: pointer;
}

/* تحسين شكل حقول رفع الملفات المدخلة */
.modal-box input[type="file"] {
    background: var(--modal-bg-light);
    border: 2px dashed #E2DDF0;
    padding: 16px;
    border-radius: 10px;
    width: 100%;
    cursor: pointer;
    box-sizing: border-box;
    transition: all 0.2s ease-in-out;
}

.modal-box input[type="file"]:hover {
    border-color: var(--modal-secondary);
    background: #F8FFF9;
}

/* شريط الإجراءات والأزرار بالأسفل الخاص بالنافذة المنبثقة */
.modal-actions, 
.modal-box div[style*="justify-content:flex-end"] {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #F0EDF8;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* تحسين شكل الأزرار بداخل المودال لضمان الفخامة البصرية */
.modal-actions button, 
.modal-actions .btn {
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* تأثيرات الحركة الانسيابية اللطيفة للظهور */
@keyframes fadeInModal {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUpModal {
    from { opacity: 0; transform: translateY(25px); }
    to { opacity: 1; transform: translateY(0); }
}

/* دعم شاشات الهواتف المتناهية الصغر لضمان عدم انكسار الحواف */
@media (max-width: 480px) {
    .modal-box {
        padding: 20px;
        border-radius: 12px;
    }
    .modal-actions {
        flex-direction: column-reverse;
        gap: 8px;
    }
    .modal-actions button, 
    .modal-actions .btn {
        width: 100%;
        justify-content: center;
    }
}