/* =================================== */
/* GLOBAL STYLES & VARIABLES - Final V14 */
/* =================================== */
:root {
  --primary-color: #C8102E; /* أحمر تيرنكي */
  --secondary-color: #2C2A29; /* أسود تيرنكي */
  --light-gray: #f8f9fa; 
  --medium-gray: #dee2e6; 
  --dark-gray: #495057; 
  --success-green: #28a745;
  --error-red: #dc3545;
  --white-bg: #ffffff;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  --input-height: 42px; 
}

/* 1. الخط Cairo */
* { 
    box-sizing: border-box; margin: 0; padding: 0; 
    font-family: 'Cairo', sans-serif; 
}

html, body { height: 100%; }
body { 
    background-color: var(--light-gray); 
    direction: rtl; text-align: right; 
    overflow-x: hidden; font-size: 0.95rem; 
    display: flex; flex-direction: column; 
}

/* --- LOADER --- */
#loader-overlay { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(2px);
    display: none; justify-content: center; align-items: center; 
    z-index: 9999; flex-direction: column; 
}
.spinner { 
    border: 5px solid var(--medium-gray); border-top: 5px solid var(--primary-color); 
    border-radius: 50%; width: 50px; height: 50px; animation: spin 1s linear infinite; 
}
#loader-overlay p { color: var(--secondary-color); font-size: 1.1rem; margin-top: 15px; font-weight: 600;}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* ========================================= */
/* --- 2. LOGIN SCREEN (Split Screen) --- */
/* ========================================= */
.split-screen { display: flex; width: 100%; min-height: 100vh; background-color: #fff; overflow: hidden; }

.left-pane { flex: 0 0 40%; display: flex; align-items: center; justify-content: center; padding: 20px; background-color: #fff; position: relative; z-index: 2; }
.login-container { width: 100%; max-width: 380px; text-align: center; }
.login-container .logo { max-width: 240px; margin-bottom: 25px; }
.login-container h3 { 
    color: var(--secondary-color); margin-bottom: 15px; font-size: 1.8rem; 
    font-weight: 800; letter-spacing: -0.5px; text-transform: uppercase; position: relative; display: inline-block;
}
.login-container h3::after {
    content: ''; display: block; width: 50px; height: 4px; 
    background: var(--primary-color); margin: 8px auto 0; border-radius: 2px;
}
.welcome-text { color: #666; margin-bottom: 35px; font-size: 1rem; font-weight: 600; }

#login-form .form-group { margin-bottom: 20px; text-align: left; }
#login-form .form-group label { display: block; margin-bottom: 8px; font-weight: 700; color: #555; }
#login-form .form-group input { 
    width: 100%; padding: 12px 15px; border: 1px solid #ddd; border-radius: 8px; 
    font-size: 1rem; transition: all 0.3s; background-color: #fcfcfc;
    font-weight: 400; 
}
#login-form .form-group input:focus { border-color: var(--primary-color); background-color: #fff; outline: none; box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.1); }

.right-pane {
    flex: 1; background: linear-gradient(135deg, var(--primary-color) 0%, #a71d2a 100%);
    color: #fff; display: flex; align-items: center; justify-content: center; 
    padding: 60px 40px 40px 40px; position: relative; overflow: hidden; height: 100vh;
}
.right-pane::before {
    content: ''; position: absolute; top: -10%; right: -10%; width: 400px; height: 400px;
    background: rgba(255, 255, 255, 0.05); border-radius: 50%;
}

.lang-btn {
    position: absolute;
    top: 25px;
    /* الوضع الافتراضي (إنجليزي) -> يمين */
    right: 25px; 
    left: auto; 
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff; 
    padding: 6px 15px;
    border-radius: 20px; 
    cursor: pointer; 
    font-weight: 600; 
    transition: all 0.3s ease;
    z-index: 10; 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    font-size: 0.9rem;
}

.lang-btn:hover { background: #fff; color: var(--primary-color); }

/* الوضع العربي (عند التحويل) -> شمال */
.lang-btn.ar-pos {
    right: auto !important; /* إلغاء اليمين */
    left: 25px !important;  /* تفعيل اليسار */
    flex-direction: row-reverse; /* عكس الأيقونة والنص */
}

.info-content { max-width: 650px; width: 100%; z-index: 2; text-align: left; }
#content-en { direction: ltr; text-align: left; }
#content-ar { direction: rtl; text-align: right; }
.fade-in { animation: fadeIn 0.5s ease-in-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.info-content h1 { font-size: 2rem; font-weight: 700; margin-bottom: 15px; border-bottom: 2px solid rgba(255,255,255,0.3); padding-bottom: 10px; display: inline-block; }
.intro-text { font-size: 0.95rem; line-height: 1.6; margin-bottom: 25px; opacity: 0.95; background: rgba(0,0,0,0.1); padding: 15px; border-radius: 8px; font-weight: 400; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.info-box h4 { font-size: 1rem; margin-bottom: 10px; color: #fff; text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
#content-en .info-box h4 { border-left: 3px solid rgba(255,255,255,0.6); padding-left: 10px; }
#content-ar .info-box h4 { border-right: 3px solid rgba(255,255,255,0.6); padding-right: 10px; }
.info-box ul { list-style: none; padding: 0; }
.info-box ul li { margin-bottom: 5px; font-size: 0.9rem; opacity: 0.9; position: relative; font-weight: 400; }
#content-en .info-box ul li { padding-left: 15px; }
#content-en .info-box ul li::before { content: '•'; position: absolute; left: 0; font-weight: 600; }
#content-ar .info-box ul li { padding-right: 15px; }
#content-ar .info-box ul li::before { content: '•'; position: absolute; right: 0; font-weight: 600; }
.footer-note { margin-top: 20px; padding-top: 15px; border-top: 1px solid rgba(255, 255, 255, 0.2); }
.footer-note p { font-size: 0.85rem; line-height: 1.4; font-style: italic; opacity: 0.85; margin: 0; font-weight: 400; }

/* ========================================= */
/* --- 3. APP LAYOUT & SIDEBAR --- */
/* ========================================= */
#app-wrapper { display: none; flex: 1; width: 100%; align-items: stretch; }
#sidebar { min-width: 250px; max-width: 250px; background: var(--white-bg); color: var(--secondary-color); display: flex; flex-direction: column; border-left: 1px solid #e0e0e0; transition: margin-right 0.3s; }
.sidebar-header { padding: 15px; background: #fdfdfd; text-align: center; border-bottom: 1px solid #e0e0e0; }
.sidebar-header .logo { max-width: 200px; margin-bottom: 10px; }
.sidebar-header h3 { font-size: 1rem; color: var(--secondary-color); margin: 0; font-weight: 600; }
.sidebar-header p { font-size: 0.8rem; color: var(--dark-gray); margin: 0; }
#sidebar-menu { padding: 10px 0; flex-grow: 1; list-style: none; margin: 0; overflow-y: auto; }
#sidebar-menu a { padding: 10px 20px; font-size: 0.95rem; display: block; color: var(--dark-gray); text-decoration: none; transition: all 0.3s; border-right: 4px solid transparent; font-weight: 500; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sidebar-menu a:hover { background: #fdf0f2; color: var(--primary-color); border-right-color: var(--primary-color); }
#sidebar-menu a.active { background: var(--primary-color); color: #ffffff; font-weight: 600; border-right-color: transparent; }
#sidebar-menu a i { margin-left: 10px; width: 20px; text-align: center; }
#sidebar-menu li a.menu-toggle { display: flex; justify-content: space-between; align-items: center; }
#sidebar-menu li a.menu-toggle .fa-chevron-down { transition: transform 0.3s ease; font-size: 0.8em; }
#sidebar-menu li a.menu-toggle.expanded .fa-chevron-down { transform: rotate(180deg); }
.submenu { list-style: none; padding: 0; margin: 0; background-color: #f9f9f9; display: none; box-shadow: inset 0 3px 5px rgba(0,0,0,0.05); }
.submenu.show { display: block; }
.submenu li a { padding-right: 45px !important; font-size: 0.95rem; border-bottom: 1px solid #eee; }
.submenu li a:hover { background-color: #f1f1f1; }
.sidebar-footer { padding: 10px; background: #fdfdfd; border-top: 1px solid #e0e0e0; flex-shrink: 0; }
.sidebar-footer a { color: var(--dark-gray); text-decoration: none; display: block; text-align: center; transition: color 0.3s; font-weight: 500; font-size: 0.9rem;}
.sidebar-footer a:hover { color: var(--primary-color); }

/* ========================================= */
/* --- 4. MAIN CONTENT & FORMS --- */
/* ========================================= */
#content { flex-grow: 1; padding: 20px; min-height: 100vh; background: var(--light-gray); transition: margin-right 0.3s; box-sizing: border-box; overflow-y: auto; }

.page-section { background: var(--white-bg); padding: 25px; border-radius: 8px; box-shadow: var(--shadow); margin-bottom: 20px; }
.page-section h2 { 
    color: var(--primary-color); 
    border-bottom: 2px solid var(--light-gray); 
    padding-bottom: 10px; margin: 0 0 25px 0; 
    font-size: 1.4rem; 
    font-weight: 800; /* (هام) عنوان القسم عريض */
}
.page-section h2 i { margin-left: 10px; }

.app-form { display: flex; flex-direction: column; }
.form-row { display: flex; gap: 20px; width: 100%; flex-wrap: wrap; }
.app-form .form-group { width: 100%; margin-bottom: 1rem; flex-grow: 1; min-width: 200px; }
.form-row > .form-group { flex-basis: calc(50% - 10px); }

/* (تعديل) Labels متوسطة */
.app-form label { 
    display: block; margin-bottom: 6px; 
    font-weight: 600; /* (هام) متوسط */
    color: var(--secondary-color); font-size: 0.95rem; 
}
.required::after { content: " *"; color: red; }

/* (تعديل) Inputs عادية */
.app-form input, .app-form select, .app-form textarea { 
    width: 100%; height: var(--input-height); 
    padding: 6px 12px; border: 1px solid var(--medium-gray); 
    border-radius: 5px; box-sizing: border-box; font-family: inherit; 
    font-size: 0.95rem; 
    font-weight: 400; /* (هام) عادي */
    transition: border-color 0.3s, box-shadow 0.3s; background-color: white; 
}
.app-form textarea { height: auto; padding: 10px; }
.app-form input:focus, .app-form select:focus, .app-form textarea:focus { border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.1); outline: none; }
.app-form input[readonly] { background: #e9ecef !important; cursor: not-allowed; color: #555; }

/* --- BUTTONS --- */
.btn { 
    height: var(--input-height);
    background-color: var(--primary-color); color: white; padding: 0 25px; 
    border: none; border-radius: 6px; cursor: pointer; font-size: 1rem; 
    font-weight: 600; transition: all 0.2s ease; display: inline-flex; 
    align-items: center; justify-content: center; box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.btn:hover { background-color: #a00d23; transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.15); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn:disabled { background-color: #ccc; cursor: not-allowed; transform: none; box-shadow: none; }
.btn i { margin-left: 8px; }

/* (تعديل) توحيد الألوان */
.btn-secondary { background-color: var(--primary-color); color: white; }
.btn-secondary:hover { background-color: #a00d23; }
.btn-danger { background-color: #dc3545; }
.btn-small { padding: 6px 12px; font-size: 0.85rem; font-weight: 500; }

/* Add/Remove Buttons */
#haz-add-action-btn, #ppe-add-item-btn, #trn-add-btn, .btn-add-inline { width: 50px; padding: 0; font-size: 1.2rem; margin-bottom: 2px; }
.btn-small.btn-danger { width: 28px; height: 28px; border-radius: 50%; background-color: #ffebee; color: #c62828; border: 1px solid #ffcdd2; padding: 0; display: flex; align-items: center; justify-content: center; box-shadow: none; font-size: 0.9rem; }
.btn-small.btn-danger:hover { background-color: #c62828; color: white; transform: scale(1.1); border-color: #c62828; }

.error-message { color: var(--error-red); font-weight: 600; margin-top: 10px; display: none; text-align: center;}
.success-message { color: var(--success-green); font-weight: 600; margin-top: 10px; display: none; white-space: pre-wrap; text-align: center;}

/* --- MODULES --- */
/* (تعديل) تنسيق فلاتر البحث */
.filter-controls { 
    background-color: #fdfdfd; 
    padding: 15px 20px; 
    border: 1px solid var(--medium-gray); 
    border-radius: 6px; 
    margin-bottom: 20px; 

    /* المحاذاة العامة */
    display: flex; 
    align-items: flex-end; 
    gap: 15px; 
    flex-wrap: nowrap; /* منع نزول العناصر لسطر جديد */
}

.filter-controls .form-group { 
    margin-bottom: 0; 
    min-width: 150px; 
    flex: 1; 
}

/* (هام) تنسيق مجموعة التاريخ (من - إلى) */
.filter-controls .form-row { 
    display: flex; 
    gap: 10px; 
    flex: 2;         /* تأخذ مساحة أكبر */
    width: auto; 
    margin: 0; 

    /* (*** الحل هنا ***) */
    flex-wrap: nowrap !important; /* إجبار الخانتين على البقاء في سطر واحد */
    align-items: flex-end;
}

/* تقليل عرض خانة التاريخ قليلاً لضمان عدم النزول */
.filter-controls .form-row .form-group {
    min-width: 120px; 
}

.filter-controls .btn { 
    height: 42px; 
    margin-top: 0; 
    min-width: 100px; 
    flex-shrink: 0; 
}

/* (تعديل) تشيك بوكس */
.filter-controls .checkbox-group { 
    display: flex; align-items: center; height: 42px; 
    background: #fff; border: 1px solid var(--medium-gray); border-radius: 5px; 
    padding: 0 15px; margin-bottom: 0; white-space: nowrap; flex-shrink: 0; 
}
.checkbox-group { display: flex; align-items: center; justify-content: flex-start; gap: 10px; margin-bottom: 15px; width: auto !important; flex-grow: 0 !important; }
.checkbox-group input[type="checkbox"] { width: 16px !important; height: 16px !important; margin: 0; cursor: pointer; flex-shrink: 0; display: inline-block; margin-left: 8px; }
.checkbox-group label { margin: 0; font-weight: 500; cursor: pointer; font-size: 0.9rem; display: inline-block; }

/* (إضافة) تفعيل السكرول الأفقي لجميع الجداول في الموبايل */
.results-table-container {
    overflow-x: auto !important; /* إجبار السكرول الأفقي */
    -webkit-overflow-scrolling: touch; /* سكرول ناعم للموبايل */
    width: 100%;
    display: block;
    margin-top: 15px;
    border: 1px solid var(--medium-gray); /* تأكيد الحدود */
}

/* (إضافة) إجبار الجدول على أن يكون عريضاً */
.results-table {
    min-width: 600px; /* الجدول سيكون أعرض من شاشة الموبايل فيظهر السكرول */
    width: 100%;
}
.results-table th, .results-table td { border-bottom: 1px solid var(--medium-gray); padding: 12px; text-align: right; vertical-align: middle; }
.results-table th { background-color: #f1f1f1; font-weight: 700; white-space: nowrap; color: var(--primary-color); }
.results-table tbody tr:nth-child(even) { background-color: #fcfcfc; }
.results-table tbody tr:hover { background-color: #fff5f6; }
/* (جديد) حالة التصاريح */
.badge { padding: 4px 8px; border-radius: 4px; font-size: 0.85rem; font-weight: 600; }
.badge.bg-danger { background-color: #ffebee; color: #c62828; }
.badge.bg-success { background-color: #e8f5e9; color: #2e7d32; }

.kpi-card { background: var(--white-bg); border: 1px solid var(--medium-gray); border-radius: 8px; padding: 15px; display: flex; flex-wrap: wrap; gap: 15px; align-items: center; justify-content: space-between; box-shadow: 0 2px 5px rgba(0,0,0,0.03); }
.kpi-card-info h4 { margin: 0 0 5px 0; font-size: 1rem; color: var(--secondary-color); font-weight: 600; }
.kpi-card-info p { margin: 0; font-size: 0.85rem; color: #666; }
.kpi-card-info p span { color: var(--primary-color); font-weight: 600; }
.kpi-score-input { color: var(--primary-color); font-weight: 700; font-size: 1.2em; text-align: center; width: 80px !important; border: 2px solid var(--medium-gray); border-radius: 4px; height: 40px; }
.kpi-score-input:focus { border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.15); }

#haz-actions-list, #ppe-cart-container, #trn-list-container { border: 1px dashed #ccc; min-height: 50px; padding: 10px; border-radius: 6px; background: #fafafa; margin-top: 10px; }
.ppe-dynamic-group { border: 1px solid #eee; padding: 20px; margin-bottom: 15px; border-radius: 8px; background-color: #fdfdfd; }
.ppe-cart-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 15px; background: #fff; border: 1px solid #eee; border-radius: 5px; margin-bottom: 8px; font-weight: 500; font-size: 0.95rem; box-shadow: 0 1px 2px rgba(0,0,0,0.03); }
.input-with-button { display: flex; gap: 10px; width: 100%;}
.input-with-button input { flex-grow: 1; }
.input-with-button button { width: auto; padding: 0 15px; }

/* --- SCROLLBAR --- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 5px; }
::-webkit-scrollbar-thumb { background: var(--primary-color); border-radius: 5px; border: 2px solid #f1f1f1; }
::-webkit-scrollbar-thumb:hover { background: #a00d23; }

/* ========================================= */
/* --- 7. MOBILE RESPONSIVENESS (Fixed Arabic Alignment) --- */
/* ========================================= */
@media (max-width: 992px) {
    .split-screen { flex-direction: column; height: auto; overflow-y: auto; }
    .left-pane { flex: none; padding: 40px 20px; order: 1; width: 100%; }

    .right-pane { 
        flex: none; order: 2; width: 100%; height: auto; 
        padding: 60px 20px 40px 20px; text-align: center; 
        overflow: visible; display: block;
    }

    .info-content { max-width: 100%; }

    /* (تعديل هام) جعل المحاذاة تتبع اتجاه اللغة */
    .info-grid { grid-template-columns: 1fr; gap: 20px; }
    #content-en .info-grid { text-align: left; }
    #content-ar .info-grid { text-align: right; }

    .info-content h1 { font-size: 1.8rem; }

    /* (تعديل) زر اللغة للموبايل */
    .lang-btn { 
        top: 15px; 
        right: 15px; 
        left: auto; 
        background: rgba(255,255,255,0.25);

        /* منع التمدد */
        width: auto !important; 
        min-width: auto !important;
        display: inline-flex !important;
        padding: 6px 12px;
    }

    .lang-btn.ar-pos { 
        left: 15px !important; 
        right: auto !important; 
    }

    /* فلاتر الموبايل */
    .filter-controls { flex-wrap: wrap !important; }
    .filter-controls .form-group, .filter-controls .form-row, .filter-controls .btn, .filter-controls .checkbox-group { flex: 1 1 100%; width: 100%; }
    .filter-controls .form-row { flex-direction: row; }
    .results-table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        display: block;
        border: 1px solid var(--medium-gray);
    }
    .results-table {
        min-width: 600px; /* العرض الإجباري */
    }
}

@media (max-width: 768px) {
    body { display: block; }
    #app-wrapper { display: none; flex-direction: column; }
    #sidebar { position: fixed; top: 0; right: 0; height: 100%; z-index: 1000; margin-right: -260px; box-shadow: -5px 0 15px rgba(0,0,0,0.1); }
    #sidebar.active { margin-right: 0; }
    #content { margin-right: 0 !important; padding: 15px; padding-top: 60px; }
    .mobile-header { display: flex; background: var(--white-bg); color: var(--secondary-color); padding: 10px 15px; align-items: center; box-shadow: 0 2px 4px rgba(0,0,0,0.05); border-bottom: 1px solid var(--medium-gray); position: fixed; width: 100%; top: 0; z-index: 900; }
    .mobile-header .btn { background: transparent; color: var(--primary-color); font-size: 1.4rem; padding: 5px; box-shadow: none; }
    .form-row > .form-group { flex-basis: 100%; }
    .results-table th, .results-table td { white-space: nowrap; font-size: 0.85rem; }
}
@media (min-width: 769px) {
    #app-wrapper { flex-direction: row; }
    #sidebar { margin-right: 0 !important; position: static !important; height: auto !important; box-shadow: none !important; }
    .mobile-header { display: none !important; }
}
/* تنسيق رابط العودة للداشبورد */
.back-link {
    display: inline-block;
        margin-bottom: 20px;
        color: var(--primary-color);
        text-decoration: none;
        font-weight: 600;
        font-size: 0.95rem;
        transition: all 0.3s ease;
        border-bottom: 1px solid transparent;
        margin-top: 40px;
}

.back-link:hover {
    color: #a00d23; /* لون أغمق عند الوقوف عليه */
    border-bottom-color: #a00d23; /* ظهور الخط */
    transform: translateX(-5px); /* حركة بسيطة لليسار (اتجاه السهم) */
}

.back-link i {
    margin-right: 5px; /* مسافة بين السهم والكلمة */
}

/* ========================================= */
/* --- زر العودة للداشبورد (داخل السايدبار) --- */
/* ========================================= */

.sidebar-footer {
    display: flex;
    flex-direction: column; /* لترتيب الأزرار فوق بعض */
    gap: 5px; /* مسافة بين الزرين */
}

.back-to-dash-btn {
    color: var(--primary-color) !important; /* لون أحمر مميز */
    font-weight: 700 !important;
    border-bottom: 1px solid #eee; /* خط فاصل خفيف تحته */
    padding-bottom: 15px !important; /* مسافة قبل الخط */
    margin-bottom: 5px;
}

.back-to-dash-btn:hover {
    background-color: #fdf0f2; /* خلفية حمراء خفيفة جداً عند اللمس */
}

.back-to-dash-btn i {
    margin-left: 10px; /* مسافة للأيقونة */
    transform: scaleX(1); /* اتجاه السهم */
}

/* (اختياري) تحريك السهم عند الوقوف عليه */
.back-to-dash-btn:hover i {
    transform: translateX(-3px); 
    transition: transform 0.2s;
}

/* ========================================= */
/* --- تنسيقات لوحة التحكم (Dashboard) --- */
/* ========================================= */

.welcome-card {
    background: linear-gradient(135deg, #ffffff 70%, #fff5f6 100%);
    border: 1px solid var(--medium-gray);
    border-radius: 12px;
    padding: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    min-height: 250px;
}

.welcome-text-content {
    flex: 1;
}

/* عنوان الترحيب */
.welcome-text-content h2 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 15px;
    border-bottom: none !important; /* إزالة الخط الافتراضي */
    padding-bottom: 0 !important;
}

/* النصوص الفرعية */
.dash-role, .dash-date {
    font-size: 1.1rem;
    color: var(--secondary-color);
    margin-bottom: 10px;
    font-weight: 600;
}

.dash-role i, .dash-date i {
    color: var(--primary-color);
    margin-left: 8px;
    width: 20px;
    text-align: center;
}

.dash-role span, .dash-date span {
    color: #555;
    font-weight: 500;
}

/* الشعار */
.dash-quote {
    margin-top: 25px;
    padding: 10px 15px;
    background-color: #fdfdfd;
    border-right: 4px solid var(--primary-color);
    font-style: italic;
    color: var(--dark-gray);
    font-weight: 600;
    display: inline-block;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}

/* الصورة */
.welcome-image-content {
    flex: 0 0 300px; /* عرض ثابت للصورة */
    text-align: center;
}

.dash-img {
    max-width: 100%;
    height: auto;
    max-height: 200px;
    object-fit: contain;
    /* تأثير ظل خفيف للصورة */
    filter: drop-shadow(0 10px 10px rgba(0,0,0,0.1));
    transition: transform 0.3s ease;
}

.dash-img:hover {
    transform: scale(1.05);
}

/* موبايل */
@media (max-width: 768px) {
    .welcome-card {
        flex-direction: column-reverse; /* الصورة فوق والكلام تحت */
        text-align: center;
        padding: 20px;
    }
    .welcome-image-content {
        flex: none;
        margin-bottom: 20px;
    }
    .dash-img {
        max-height: 150px;
    }
    .dash-quote {
        width: 100%;
    }
}

/* ========================================= */
/* --- (تحديث) تحسينات قسم تقرير المخازن --- */
/* ========================================= */

/* 1. تحسين حاوية الجدول */
#stock-report-results-table {
    margin-top: 25px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05); /* ظل ناعم */
    overflow: hidden; /* لضمان الحواف الدائرية */
    border: 1px solid var(--medium-gray);
}

/* 2. عنوان التقرير (اسم المخزن) */
#stock-report-results-table h3 {
    background-color: #fdfdfd;
    color: var(--secondary-color);
    padding: 20px;
    margin: 0;
    border-bottom: 1px solid #eee;
    font-size: 1.3rem;
    font-weight: 800;
    text-align: center;
    letter-spacing: -0.5px;
}

/* 3. تنسيق الجدول نفسه */
#stock-report-results-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

/* رأس الجدول (أحمر) */
#stock-report-results-table th {
    background-color: var(--primary-color); /* الخلفية حمراء */
    color: white; /* النص أبيض */
    padding: 15px;
    text-align: center;
    font-weight: 700;
    border: none; /* إزالة الحدود القديمة */
    white-space: nowrap;
}

/* خلايا الجدول */
#stock-report-results-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    text-align: center;
    color: #444;
    font-weight: 500;
    vertical-align: middle;
}

/* تلوين الصفوف (Zebra Striping) */
#stock-report-results-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

/* تأثير عند المرور (Hover) */
#stock-report-results-table tbody tr:hover {
    background-color: #fff0f3; /* أحمر فاتح جداً */
    transition: background-color 0.2s ease;
}

/* 4. تمييز عمود "الكمية المتاحة" (آخر عمود) */
#stock-report-results-table td:last-child {
    font-weight: 800;
    color: var(--primary-color); /* الرقم باللون الأحمر */
    font-size: 1.1em;
    background-color: rgba(200, 16, 46, 0.03); /* خلفية خفيفة جداً للعمود */
}

/* تحسين شكل الفلاتر في هذا القسم */
#ProjectStockReport .filter-controls {
    align-items: flex-end;
    gap: 15px;
}
#ProjectStockReport .filter-controls .form-group {
    flex: 3; /* القائمة تأخذ مساحة أكبر */
}
#ProjectStockReport .filter-controls .btn {
    flex: 1; /* الزر يأخذ مساحة أقل */
}

/* ========================================= */
/* --- (إضافة) تحسين جدول التصاريح والمتابعة --- */
/* ========================================= */

.filter-controls { 
    background-color: #fdfdfd; 
    padding: 15px 20px; 
    border: 1px solid var(--medium-gray); 
    border-radius: 6px; 
    margin-bottom: 20px; 

    /* المحاذاة العامة */
    display: flex; 
    align-items: flex-end; 
    gap: 15px; 

    /* (هام) السماح بالالتفاف لضمان عدم خروج العناصر */
    flex-wrap: wrap !important; 
}

/* ضبط العناصر لتأخذ مساحتها الطبيعية */
.filter-controls .form-group { 
    margin-bottom: 0; 
    min-width: 150px; 
    flex: 1 1 auto; /* مرونة في الحجم */
}

/* تنسيق مجموعة التاريخ (من - إلى) لتبقى متماسكة */
.filter-controls .form-row { 
    display: flex; 
    gap: 10px; 
    flex: 2 1 auto; /* مرونة أكبر */
    width: auto; 
    margin: 0; 
    /* إجبار التاريخين يبقوا جمب بعض */
    flex-wrap: nowrap !important; 
    align-items: flex-end;
}

/* ضبط مربعات الاختيار (دمج المشاريع وغيرها) */
.filter-controls .checkbox-group {
    display: flex; 
    align-items: center; 
    height: 42px; 
    background: #fff; 
    border: 1px solid var(--medium-gray); 
    border-radius: 5px; 
    padding: 0 15px; 
    margin-bottom: 0; 
    white-space: nowrap; 
    flex-shrink: 0;

    /* (إضافة) أقصى عرض لضمان عدم التمدد الزائد */
    max-width: 100%;
}

/* ضبط الزر */
.filter-controls .btn { 
    height: 42px; 
    margin-top: 0; 
    min-width: 100px; 
    flex-shrink: 0; 
}

/* 2. إصلاح كروت "إغلاق التصاريح" */
#open-permits-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 15px;
}

.permit-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--medium-gray);
    border-radius: 8px;
    padding: 15px 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
    transition: transform 0.2s ease;
}

.permit-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0,0,0,0.05);
    border-color: var(--primary-color);
}

/* 3. زر الإغلاق (البيضاوي الأنيق) */
.btn-close, 
.permit-card button, 
.results-table button.btn-danger,
.results-table button.btn-small {
    background-color: #ffebee !important;
    color: #c62828 !important;
    border: 1px solid #ffcdd2 !important;
    border-radius: 50px !important;
    padding: 5px 15px !important;
    font-size: 0.85rem !important;
    font-weight: 700 !important;
    font-family: 'Cairo', sans-serif !important;
    width: auto !important;
    height: auto !important;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: none !important;
    display: inline-block;
}

.btn-close:hover, 
.permit-card button:hover,
.results-table button:hover {
    background-color: #c62828 !important;
    color: #ffffff !important;
    border-color: #c62828 !important;
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(198, 40, 40, 0.3) !important;
}

/* 4. إصلاح عرض وصف الجدول (Wrap Text) */
.results-table td {
    white-space: normal !important;    /* السماح بنزول السطر */
    word-wrap: break-word !important;  /* كسر الكلمات الطويلة */
    vertical-align: top;
    line-height: 1.6;
    padding: 12px 10px;
    max-width: 400px;
    min-width: 150px;
}
.results-table th {
    white-space: nowrap;
    vertical-align: middle;
}

/* --- استثناء للموبايل --- */
@media (max-width: 992px) {
    .filter-controls { flex-wrap: wrap !important; }
    .filter-controls .form-group, 
    .filter-controls .form-row, 
    .filter-controls .btn, 
    .filter-controls .checkbox-group { 
        flex: 1 1 100%; 
        width: 100%; 
    }
    .filter-controls .form-row { flex-direction: row; }

    .permit-card { 
        flex-direction: column; 
        align-items: stretch; 
        text-align: right; 
    }
    .permit-card .btn-close { 
        width: 100% !important; 
        text-align: center; 
        margin-top: 10px; 
    }
}



/* قائمة البحث المنسدلة */
.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ccc;
    border-top: none;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    border-radius: 0 0 5px 5px;
}
.search-item {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    transition: background 0.2s;
}
.search-item:hover {
    background-color: #f1f1f1;
}
.search-item strong { color: var(--primary-color); }
.search-item small { color: #666; float: left; }

/* كارت الموظف */
.emp-profile-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.emp-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    flex-grow: 1;
}
.emp-info-grid div {
    font-size: 0.95rem;
    color: #333;
}
.emp-info-grid strong {
    color: var(--secondary-color);
    margin-left: 5px;
}

/* عداد KPI */
.emp-kpi-box {
    text-align: center;
    margin-right: 20px;
    border-right: 1px solid #eee;
    padding-right: 20px;
    min-width: 120px;
}
.kpi-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #f8f9fa;
    border: 5px solid #eee; /* Default */
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
    font-size: 1.4rem;
    font-weight: bold;
    color: #333;
}
.section-title {
    margin-top: 30px;
    margin-bottom: 10px;
    font-size: 1.1rem;
    color: var(--primary-color);
    border-bottom: 2px solid #eee;
    padding-bottom: 5px;
}

/* ========================================= */
/* --- Mobile Responsive Fixes (Employee Report) --- */
/* ========================================= */
@media (max-width: 768px) {

    /* 1. تعديل كارت الموظف ليظهر عمودياً */
    .emp-profile-card {
        flex-direction: column-reverse; /* يعكس الترتيب: الـ KPI فوق والبيانات تحت */
        align-items: center;
        text-align: center;
        gap: 20px;
        padding: 15px;
    }

    /* 2. تعديل شبكة البيانات لتكون عمود واحد */
    .emp-info-grid {
        grid-template-columns: 1fr; /* عمود واحد */
        width: 100%;
        text-align: right; /* الحفاظ على محاذاة النص لليمين */
        gap: 10px;
    }

    /* 3. تعديل صندوق الـ KPI */
    .emp-kpi-box {
        margin-right: 0;
        padding-right: 0;
        border-right: none; /* إزالة الخط الجانبي */
        border-bottom: 1px solid #eee; /* إضافة خط سفلي */
        padding-bottom: 20px;
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    /* 4. إجبار جداول التقرير على السكرول الأفقي */
    /* (مهم جداً عشان الجدول ميبوظش الصفحة) */
    .report-table-wrapper {
        display: block;
        width: 100%;
        overflow-x: auto; /* يسمح بالسكرول */
        -webkit-overflow-scrolling: touch; /* نعومة السكرول في الآيفون */
        margin-bottom: 15px;
        border: 1px solid #eee;
        border-radius: 4px;
    }

    /* ضمان أن الجدول داخل السكرول محتفظ بعرضه */
    .report-table-wrapper table {
        min-width: 600px; /* أقل عرض للجدول عشان الكلام ميتعصرش */
    }
}

/* ========================================= */
/* --- إصلاحات الموبايل (Mobile Fixes - Final) --- */
/* ========================================= */
@media (max-width: 768px) {

    /* 1. الحاوية الرئيسية للفلاتر: تحويلها لعمود */
    .filter-controls {
        display: flex !important;
        flex-direction: column !important; /* رص العناصر فوق بعض */
        align-items: stretch !important;   /* تمديد العناصر لعرض الشاشة */
        height: auto !important;           /* السماح بزيادة الطول */
        gap: 10px !important;
        flex-wrap: nowrap !important;
        padding: 15px 10px !important;     /* تقليل الحواف الجانبية */
    }

    /* 2. إجبار كل عنصر داخل الفلاتر أن يأخذ السطر كاملاً */
    .filter-controls > * {
        width: 100% !important;
        margin: 0 0 10px 0 !important; /* مسافة سفلية */
        flex: none !important;
        max-width: 100% !important;
    }

    /* 3. إصلاح خاص لمربعات الاختيار (Checkboxes) التي تخرج عن الإطار */
    /* نستهدف أي ديف داخلي أو كلاس checkbox-group */
    .filter-controls .checkbox-group,
    .filter-controls div[style*="display: flex"] {
        display: flex !important;
        flex-wrap: wrap !important; /* السماح بنزول الكلام لسطر جديد */
        white-space: normal !important; /* السماح بكسر السطر */
        height: auto !important;        /* ارتفاع تلقائي */
        min-height: 45px !important;
        align-items: center !important;
        justify-content: flex-start !important;
        border: 1px solid #dee2e6 !important; /* إضافة حدود لتمييزها */
        border-radius: 5px !important;
        background-color: #fff !important;
        padding: 5px 10px !important;
    }

    /* 4. إصلاح النصوص داخل التشيك بوكس */
    .filter-controls label {
        font-size: 0.9rem !important;
        margin: 0 !important;
        display: inline-block !important;
    }

    /* 5. مجموعة التاريخ (من - إلى) نجعلها في سطر واحد مقسوم */
    .filter-controls .form-row {
        display: flex !important;
        flex-direction: row !important; 
        gap: 10px !important;
        width: 100% !important;
    }
    .filter-controls .form-row .form-group {
        width: 50% !important; /* كل تاريخ ياخد نص الشاشة */
        margin: 0 !important;
    }

    /* 6. زر العرض */
    #ana-search-btn {
        width: 100% !important;
        margin-top: 5px !important;
    }

    /* 7. إصلاح خيارات PDF (التي في الأسفل) */
    .export-controls .columns-selector {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    .export-controls .columns-selector label {
        width: 48% !important; /* زرارين جمب بعض */
        font-size: 0.8rem !important;
        margin: 0 !important;
        display: flex;
        align-items: center;
        background: #fff;
        padding: 5px;
        border: 1px solid #eee;
    }
}

/* ========================================= */
/* --- Print Styles (تنسيقات الطباعة الشاملة) --- */
/* ========================================= */
@media print {
    /* 1. إعدادات الصفحة العامة: هوامش ضيقة جداً */
    /* نستخدم هوامش ضيقة عشان جدول المقاولين العريض، وهنعوضها في تقرير الموظف */
    @page {
        size: landscape; 
        margin: 5mm; 
    }

    /* 2. إخفاء كل عناصر الموقع */
    body * { 
        visibility: hidden; 
    }

    /* ---------------------------------------------------- */
    /* الحالة 1: طباعة تقرير المقاولين (الجدول العريض) */
    /* ---------------------------------------------------- */
    #ContractorAnalytics, #ContractorAnalytics * {
        visibility: visible;
    }
    #ContractorAnalytics {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;
        padding: 0;
        background: white !important;

        /* (هام) تصغير قوي للجدول لكي يدخل في الصفحة */
        zoom: 55%; 
        /* احتياطي للمتصفحات التي لا تدعم zoom */
        min-width: 100%;
    }

    /* ---------------------------------------------------- */
    /* الحالة 2: طباعة تقرير الموظفين (وثيقة رسمية) */
    /* ---------------------------------------------------- */
    #EmployeeReports, #EmployeeReports * {
        visibility: visible;
    }
    #EmployeeReports {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;

        /* (هام) إضافة حواشي داخلية لتعويض هوامش الصفحة الضيقة */
        /* هذا سيجعل الكلام بعيداً عن الحافة */
        padding: 10mm 15mm; 

        background: white !important;
        /* تصغير بسيط جداً ليناسب الشاشة */
        zoom: 85%; 
        box-sizing: border-box; 
    }

    /* ---------------------------------------------------- */
    /* تنسيقات الهيدر (اللوجو والعنوان) */
    /* ---------------------------------------------------- */
    .print-header-only {
        display: flex !important;
        /* عكس الترتيب ليظهر اللوجو يسار والعنوان يمين في اللغة العربية */
        flex-direction: row-reverse !important; 
        align-items: center;
        justify-content: space-between;
        visibility: visible !important;
        width: 100%;
        border-bottom: 2px solid #C8102E;
        padding-bottom: 10px;
        margin-bottom: 20px;
    }

    .print-header-only * {
        visibility: visible !important;
    }

    /* ضبط حجم اللوجو في الطباعة */
    .print-header-only img {
        max-height: 70px !important;
    }

    /* ---------------------------------------------------- */
    /* إخفاء العناصر غير المرغوبة */
    /* ---------------------------------------------------- */
    .no-print, .app-form, button, .filter-controls, .mobile-header, #sidebar, .export-controls, #loader-overlay, h2, .search-dropdown {
        display: none !important;
    }

    /* ---------------------------------------------------- */
    /* تنسيق الجداول (للتقريرين) */
    /* ---------------------------------------------------- */
    .results-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 10pt; 
        direction: rtl; 
        margin-bottom: 20px;
        background-color: #fff !important;
    }

    .results-table th, .results-table td {
        border: 1px solid #444;
        padding: 4px 6px;
        text-align: center;
        vertical-align: middle;
        white-space: normal; /* السماح بنزول السطر */
    }

    .results-table th {
        background-color: #eee !important;
        color: #000 !important;
        -webkit-print-color-adjust: exact; 
        font-weight: bold;
    }

    /* تصغير النصوص الطويلة جداً داخل الخلايا */
    .results-table td span {
        font-size: 9pt !important;
    }

    /* إخفاء عمود الملفات أو الإجراءات في الطباعة */
    .col-11 {
        display: none !important;
    }

    /* ---------------------------------------------------- */
    /* تنسيق كارت الموظف (البيانات الشخصية) */
    /* ---------------------------------------------------- */
    .emp-profile-card {
        border: 1px solid #000;
        box-shadow: none;
        margin-bottom: 20px;
        padding: 15px;
        background-color: #fff !important;
    }

    .kpi-circle {
        border: 4px solid #eee !important;
        -webkit-print-color-adjust: exact;
    }
}

/* ========================================= */
/* تنسيق قسم الأشخاص (الحوادث) - New Style  */
/* ========================================= */

.persons-grid-container {
    display: grid;
    grid-template-columns: 1fr 1fr; /* عمودين متساويين */
    gap: 20px;
    margin-top: 10px;
}

/* تنسيق الصندوق الواحد */
.person-box {
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
}

/* رأس الصندوق (العنوان والزر) */
.person-box-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 8px;
}

.person-box-header h4 {
    margin: 0;
    color: var(--secondary-color);
    font-size: 1rem;
}

/* تنسيق القائمة */
.list-wrapper {
    flex-grow: 1; /* يملأ المساحة المتبقية */
    background: #fff;
    border: 1px solid #eee;
    border-radius: 4px;
    min-height: 100px; /* ارتفاع أدنى */
    padding: 5px;
    max-height: 200px;
    overflow-y: auto; /* سكرول لو الأسماء كترت */
}

.styled-person-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.styled-person-list li {
    background-color: #fff;
    border-bottom: 1px solid #f1f1f1;
    padding: 8px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.styled-person-list li:hover {
    background-color: #fcfcfc;
}

.styled-person-list li span {
    color: #333;
    font-weight: 600;
}

.styled-person-list li small {
    color: #777;
    margin-right: 5px;
    font-weight: normal;
}

/* رسالة القائمة الفارغة */
.empty-msg {
    text-align: center;
    color: #aaa;
    font-size: 0.85rem;
    margin-top: 30px;
}

/* في الموبايل نخلي الصناديق تحت بعض */
@media (max-width: 768px) {
    .persons-grid-container {
        grid-template-columns: 1fr;
    }
}

/* ========================================= */
/* --- MODAL STYLES (تنسيق النافذة المنبثقة) --- */
/* ========================================= */

.modal {
    display: none; /* مخفي افتراضياً */
    position: fixed; /* ثابت فوق الشاشة */
    z-index: 2000; /* يظهر فوق كل العناصر */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto; /* سكرول لو الشاشة صغيرة */
    background-color: rgba(0,0,0,0.6); /* خلفية سوداء شفافة */
    backdrop-filter: blur(3px); /* تغبيش الخلفية */
    align-items: center; /* توسيط عمودي */
    justify-content: center; /* توسيط أفقي */

}

.modal-content {
    background-color: #fff;
    margin: 5% auto; /* مسافة من الأعلى */
    padding: 25px;
    border: 1px solid #888;
    width: 90%; 
    max-width: 800px; /* زيادة العرض لاستيعاب الجدول */
    max-height: 90vh; /* أقصى ارتفاع 90% من الشاشة */
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    position: relative;
    animation: slideDown 0.3s ease-out;
}

.close-modal {
    position: absolute;
    top: 15px;
    left: 15px; /* لأنه موقع عربي */
    font-size: 24px;
    font-weight: bold;
    color: #888;
    cursor: pointer;
    line-height: 1;
    z-index: 10;
}

/* حركة ظهور ناعمة */
@keyframes slideDown {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* زر الإغلاق (X) */
.close {
    color: #aaa;
    float: left; /* يظهر على اليسار لأن الموقع عربي */
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}

.close:hover,
.close:focus {
    color: var(--primary-color);
    text-decoration: none;
}

/* تنسيق عناصر الفورم داخل المودال */
.modal-content h3 {
    margin-top: 0;
    color: var(--primary-color);
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 20px;
    font-size: 1.2rem;
}

.modal-content .form-group {
    margin-bottom: 15px;
}

.modal-content input, 
.modal-content select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
}

/* إخفاء مجموعات الإدخال افتراضياً داخل المودال */
.vic-input-group {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #eee;
    margin-top: 10px;
}

/* ================================================= */
/* --- تحديث تنسيق أزرار صناديق الأشخاص (V2) --- */
/* ================================================= */

/* 1. ضبط رأس الصندوق ليكون مرناً ومحاذياً */
.person-box-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 10px;
    background: transparent; /* خلفية شفافة */
}

/* 2. تنسيق العنوان */
.person-box-header h4 {
    margin: 0;
    color: var(--secondary-color); /* اللون الأسود/الرمادي الغامق */
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.person-box-header h4 i {
    color: var(--primary-color); /* أيقونة العنوان باللون الأحمر */
}

/* 3. تنسيق زر الإضافة ليطابق زر البوب آب (Modal Button) */
.btn-box-add {
    background-color: var(--primary-color) !important; /* الأحمر الأساسي */
    color: #ffffff !important;
    border: none !important;
    border-radius: 6px !important; /* حواف دائرية مثل الأزرار الكبيرة */
    padding: 6px 20px !important; /* مساحة داخلية مريحة */
    font-size: 0.9rem !important;
    font-weight: 600 !important;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(200, 16, 46, 0.2); /* ظل خفيف أحمر */
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px; /* مسافة بين الأيقونة والكلمة */
    height: 35px; /* ارتفاع ثابت متناسق */
    text-decoration: none;
}

/* تأثير عند المرور بالماوس */
.btn-box-add:hover {
    background-color: #a00d23 !important; /* أحمر أغمق */
    transform: translateY(-2px); /* رفعة بسيطة */
    box-shadow: 0 4px 8px rgba(200, 16, 46, 0.3);
}

.btn-box-add i {
    font-size: 0.9em; /* حجم الأيقونة */
}

/* ========================================= */
/* --- تحسينات جدول خطة العمل (Action Plan) --- */
/* ========================================= */

/* 1. ضبط الحاوية لتسمح بالسكرول الأفقي */
.results-table-container {
    width: 100%;
    overflow-x: auto; /* يسمح بالسكرول يمين ويسار */
    -webkit-overflow-scrolling: touch; /* نعومة الحركة في الموبايل */
    border: 1px solid var(--medium-gray);
    border-radius: 6px;
    margin-top: 10px;
    background: #fff;
}

/* 2. إجبار الجدول على أخذ مساحة كافية (عشان ميتعصرش) */
#AccidentReport table.results-table {
    min-width: 600px; /* أقل عرض للجدول 600 بكسل */
    width: 100%;
}

/* 3. تنسيق خلايا الإدخال داخل الجدول */
#AccidentReport table.results-table input {
    min-width: 120px; /* أقل عرض لخانة الكتابة */
}

/* 4. تنسيق خاص لزر الإضافة (+) وزر الحذف (x) داخل الجدول */
#AccidentReport table.results-table button {
    width: 35px !important;
    height: 35px !important;
    padding: 0 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50% !important; /* شكل دائري */
    font-weight: bold;
    font-size: 1.2rem;
}

/* لون زر الإضافة (+) */
#AccidentReport table.results-table button.btn-secondary {
    background-color: var(--primary-color) !important;
    color: white !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* لون زر الحذف (x) */
#AccidentReport table.results-table button.btn-danger {
    background-color: #ffebee !important;
    color: #c62828 !important;
    border: 1px solid #ffcdd2 !important;
}

/* ========================================= */
/* --- تحسين شكل أزرار "إضافة" في باقي الفورم --- */
/* ========================================= */

/* توحيد شكل أزرار الإضافة الصغيرة بجانب حقول الإدخال */
.input-with-button button {
    height: 42px !important; /* نفس ارتفاع الـ Input */
    background-color: var(--primary-color) !important;
    color: white !important;
    border-radius: 5px !important; /* مربع بحواف ناعمة */
    padding: 0 20px !important;
    font-size: 0.9rem !important;
    white-space: nowrap;
}

.input-with-button {
    display: flex;
    gap: 8px;
}

/* ========================================= */
/* --- إصلاح سكرول جدول خطة العمل (Mobile) --- */
/* ========================================= */

/* 1. إجبار الحاوية على السكرول */
.results-table-container {
    width: 100%;
    overflow-x: auto !important; /* إجبار السكرول */
    -webkit-overflow-scrolling: touch;
    margin-top: 10px;
    border: 1px solid #eee;
}

/* 2. إجبار الجدول على التمدد */
.results-table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap; /* يمنع التفاف النص للحفاظ على العرض */
}

/* 3. (مهم جداً) إعطاء عرض أدنى لحقول الكتابة */
/* هذا ما سيمنع الحقول من أن تصبح صغيرة جداً */
#AccidentReport .results-table input {
    min-width: 150px !important; /* عرض مريح للكتابة */
    width: 100%;
}

/* تصغير زر الإضافة والحذف */
#AccidentReport .results-table button {
    width: 35px !important;
    height: 35px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ========================================= */
/* --- تنسيقات طباعة سجل الحوادث --- */
/* ========================================= */

@media print {
    /* 1. إظهار هيدر الطباعة المخفي */
    #MonitorAccidents .print-header-only {
        display: flex !important;
        flex-direction: row-reverse !important; /* اللوجو يسار والعنوان يمين */
    }

    /* 2. إخفاء عمود التشيك بوكس في الطباعة (عشان الجدول يكون شكله نضيف) */
    .print-select-col {
        display: none !important;
    }

    /* 3. (مهم) إخفاء الصفوف غير المحددة */
    tr.hide-on-print {
        display: none !important;
    }

    /* 4. تنسيق الجدول للطباعة */
    #MonitorAccidents table {
        width: 100%;
        border: 1px solid #000;
        font-size: 10pt;
    }
    #MonitorAccidents th {
        background-color: #eee !important;
        color: #000 !important;
        border: 1px solid #000;
    }
    #MonitorAccidents td {
        border: 1px solid #000;
    }
}


/* ========================================= */
/* --- إصلاح طباعة سجل الحوادث (MonitorAccidents) --- */
/* ========================================= */
@media print {
    /* 1. إظهار القسم ومحتوياته */
    /* (مهم: لو غيرت اسم السكشن لـ MYAccidents عدل الاسم هنا كمان) */
    #MYAccidents, #MYAccidents * {
        visibility: visible !important;
    }

    /* 2. ضبط مكان القسم ليحتل الصفحة بالكامل */
    #MYAccidents{
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;
        padding: 20px; /* حواف بسيطة */
        background: white !important;
        min-height: 100%;
        z-index: 9999;
    }

    /* 3. إخفاء فورم البحث والأزرار داخل هذا القسم */
    #MYAccidents .app-form, 
    #MYAccidents .no-print,
    #MYAccidents button {
        display: none !important;
    }

    /* 4. ضبط الجدول للطباعة */
    #MYAccidents .results-table-container {
        overflow: visible !important; /* إلغاء السكرول */
        display: block !important;
        border: none !important;
    }

    #MYAccidents table {
        width: 100% !important;
        border-collapse: collapse;
        font-size: 11pt; /* حجم خط مناسب للقراءة */
    }

    #MYAccidents th, #MYAccidents td {
        border: 1px solid #000 !important; /* حدود سوداء واضحة */
        padding: 8px;
        color: #000 !important;
    }

    #MYAccidents th {
        background-color: #f0f0f0 !important;
        -webkit-print-color-adjust: exact;
    }

    /* 5. إخفاء عمود الاختيار (Checkbox) في الطباعة */
    .print-select-col {
        display: none !important;
    }

    /* 6. إخفاء الصفوف غير المختارة (التي أخذت كلاس hide-on-print بالـ JS) */
    tr.hide-on-print {
        display: none !important;
    }
}

/* ========================================= */
/* --- تنسيق معرض الصور في الداش بورد --- */
/* ========================================= */

.events-grid {
    display: flex;
    gap: 20px; /* مسافة بين الصور */
    justify-content: space-between;
}

.event-card {
    flex: 1; 
    position: relative;
    border-radius: 10px;
    overflow: hidden; 
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);

    /* (*** التعديل هنا ***) */
    /* حذفنا height: 200px; واستبدلناها بالنسب التالية */
    width: 100%;             /* العرض يملأ المساحة المتاحة */
    aspect-ratio: 16 / 9;    /* يضبط الارتفاع تلقائياً بالنسبة للعرض (مثل شاشة اليوتيوب) */

    transition: transform 0.3s ease;
    cursor: pointer;
}

.event-card:hover {
    transform: translateY(-5px); /* حركة بسيطة لأعلى عند الماوس */
    box-shadow: 0 8px 15px rgba(0,0,0,0.2);
}

.event-card img {
    width: 100%;
    height: 100%;

    /* (*** التعديل هنا ***) */
    /* cover: بتقص الصورة عشان تملأ المكان */
    /* contain: بتصغر الصورة عشان تظهر بالكامل جوه المكان */
    object-fit: contain; 

    background-color: #fff; /* لون خلفية أبيض عشان يملأ الفراغات لو أبعاد الصورة مختلفة */
    transition: transform 0.5s ease;
}

.event-card:hover img {
    transform: scale(1.1); /* زووم خفيف للصورة */
}

/* شريط العنوان فوق الصورة (اختياري) */
.event-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    color: #fff;
    padding: 10px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
}

/* --- Responsive (للموبايل) --- */
@media (max-width: 768px) {
    .events-grid {
        flex-direction: column; /* الصور تحت بعض في الموبايل */
    }
    .event-card {
        height: 180px; /* تقليل الارتفاع قليلاً في الموبايل */
        width: 100%;
    }
}
/* تنسيق احتياطي للجدول لضمان الشكل */
.styled-table {
    width: 100%;
    border-collapse: collapse;
    margin: 25px 0;
    font-size: 0.9em;
    font-family: 'Cairo', sans-serif;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);
}
.styled-table thead tr {
    background-color: #C8102E; /* أحمر تيرنكي */
    color: #ffffff;
    text-align: right;
}
.styled-table th, .styled-table td {
    padding: 12px 15px;
}
.styled-table tbody tr {
    border-bottom: 1px solid #dddddd;
}
.styled-table tbody tr:nth-of-type(even) {
    background-color: #f3f3f3;
}
.styled-table tbody tr:last-of-type {
    border-bottom: 2px solid #C8102E;
}
#attendees-modal {
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.7);
}

#attendees-modal .modal-content {
    width: 95%;
    max-width: 800px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* يمنع الطفح الخارجي */
}

#attendees-modal .modal-body {
    overflow-x: auto; /* سكرول عرضي للجدول */
    overflow-y: auto; /* سكرول طولي للأسماء */
    flex-grow: 1;
}

/* ================================================= */
/* --- SPECIFIC MODAL STYLE FOR TRAINING LOG ONLY --- */
/* (التنسيقات دي مش هتأثر على أي بوب أب تانية في الموقع) */
/* ================================================= */

/* نستخدم ID المودال لضمان العزل */
#attendees-modal {
    display: none; 
    position: fixed; 
    z-index: 10000;
    left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.7); 
    backdrop-filter: blur(5px);
    align-items: center; 
    justify-content: center;
}

#attendees-modal .modal-content {
    background-color: #fff;
    padding: 25px;
    border-radius: 12px;
    width: 95%; 
    max-width: 850px; /* العرض مخصص لجدول الحضور */
    max-height: 85vh;
    position: relative;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    animation: modalFadeDown 0.3s ease-out;
}

/* زر الإغلاق X المخصص لمودال التدريب */
#attendees-modal .close-modal {
    position: absolute;
    top: 15px;
    left: 20px; /* مكان الـ X على الشمال */
    font-size: 28px;
    font-weight: bold;
    color: var(--primary-color);
    cursor: pointer;
    line-height: 1;
    z-index: 1001;
    transition: color 0.2s;
}

#attendees-modal .close-modal:hover {
    color: #000;
}

/* السكرول المخصص لمودال التدريب */
#attendees-modal .modal-body-scroll {
    overflow-x: auto;
    overflow-y: auto;
    margin-top: 10px;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 5px;
}

/* عنوان مودال التدريب فقط */
#attendees-modal .modal-content h3 {
    text-align: center;
    color: var(--secondary-color);
    margin-bottom: 15px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
    font-weight: 800;
}

/* تخصيص قائمة العمال داخل البوب أب */
#worker-list-container .ppe-cart-item:hover {
    background-color: #fff5f6;
    border-color: var(--primary-color);
}

#worker-search-box {
    font-size: 1.1rem;
    padding: 10px 15px;
    border-radius: 25px !important; /* شكل بيضاوي للبحث */
}

/* ========================================= */
/* --- تنسيقات نافذة اختيار العمال الجديدة --- */
/* ========================================= */

/* 1. تحسين حاوية القائمة (لضمان عدم خروج العناصر) */
#worker-list-container {
    max-height: 350px; /* تحديد ارتفاع أقصى للقائمة */
    overflow-y: auto;  /* تفعيل السكرول العمودي */
    overflow-x: hidden; /* منع السكرول الأفقي تماماً */
    padding: 5px;
    margin: 10px 0;
    /* تنسيق جمالي للحاوية نفسها */
    border: 1px solid #f0f0f0;
    border-radius: 8px;
    background-color: #fafafa;
}

/* 2. تنسيق "البوكسات" الخاصة بكل عامل */
#worker-list-container .ppe-cart-item {
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px; /* حواف دائرية أكثر */
    padding: 12px 15px;
    margin-bottom: 10px; /* مسافة واضحة بين كل اسم والآخر */
    box-shadow: 0 2px 4px rgba(0,0,0,0.03); /* ظل خفيف جداً */
    transition: all 0.2s ease;
    /* ضمان بقاء المحتوى داخل البوكس */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* تأثير عند الوقوف على اسم العامل */
#worker-list-container .ppe-cart-item:hover {
    border-color: var(--primary-color);
    background-color: #fff5f6; /* لون خلفية وردي فاتح */
    transform: translateY(-2px); /* حركة بسيطة للأعلى */
    box-shadow: 0 4px 8px rgba(167, 21, 45, 0.1);
}

/* --- تنسيقات مخصصة لنافذة اختيار العمال --- */

.worker-selection-modal {
    max-width: 550px !important;
    display: flex;
    flex-direction: column;
    padding-top: 40px !important; /* مساحة لزر الإغلاق */
}

/* وضع علامة X على اليسار */
.worker-selection-modal .close-modal {
    position: absolute;
    top: 10px;
    left: 15px; /* اتجاه اليسار */
    right: auto !important;
    font-size: 32px;
    color: var(--primary-color);
}

/* تحسين شكل مدخل البحث */
.search-input-fancy {
    border: 2px solid #eee !important;
    border-radius: 25px !important;
    padding: 10px 20px !important;
    height: 45px !important;
    transition: all 0.3s ease;
}

.search-input-fancy:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 8px rgba(200, 16, 46, 0.1);
}

/* منطقة سكرول الأسماء */
.modal-scroll-area {
    max-height: 350px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 5px;
    background: #fcfcfc;
    border-radius: 8px;
    border: 1px solid #f0f0f0;
}

/* تنسيق كارت العامل (البوكسات) */
#worker-list-container .ppe-cart-item {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 12px 15px;
    margin-bottom: 8px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

#worker-list-container .ppe-cart-item:hover {
    border-color: var(--primary-color);
    background-color: #fff5f6;
    transform: scale(1.01);
}

/* تنسيق زر عامل جديد الأسفل */
.worker-modal-footer {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.btn-new-worker-full {
    width: 100%;
    padding: 12px;
    background-color: var(--secondary-color); /* الأسود/الرمادي الغامق */
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s;
}

.btn-new-worker-full:hover {
    background-color: #000;
}

/* تنسيقات اختيار الموظفين داخل المودال */
#emp-list-container .ppe-cart-item {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 12px 15px;
    transition: all 0.2s ease;
}

#emp-list-container .ppe-cart-item:hover {
    border-color: var(--primary-color);
    background-color: #fff5f6;
    transform: scale(1.01);
}

/* تنسيقات خاصة بمودال موظفي المخزن */
#ppe-emp-modal .worker-selection-modal {
    max-width: 600px !important;
}

#ppe-emp-list-container .ppe-cart-item:hover {
    border-color: var(--primary-color);
    background-color: #f8f9fa;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.popup-input-style {
    cursor: pointer; 
    background-color: #fff !important; 
    border: 2px solid #C8102E !important;
    font-weight: 600;
}

/* تمييز الموظف الذي تم تقييمه بلون أخضر هادئ */
.evaluated-row {
    background-color: #f0fff4 !important; /* خلفية خضراء فاتحة جداً */
    border-right: 5px solid #28a745 !important; /* حافة خضراء سميكة */
    transition: 0.3s;
}
.evaluated-row:hover {
    background-color: #dcffe4 !important;
}

.evaluated-row {
    background-color: #f0fff4 !important; /* أخضر فاتح للمكتمل */
    border-right: 5px solid #28a745 !important;
}

.guidelines-box {
    background-color: #f8f9fa;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}
.guidelines-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85em;
    text-align: right;
}
.guidelines-table th, .guidelines-table td {
    border: 1px solid #ddd;
    padding: 8px;
}
.guidelines-table th {
    background-color: #333;
    color: white;
}
.guidelines-box h3 {
    color: #C8102E;
    font-size: 1.1em;
    margin-top: 0;
}
.note {
    color: #dc3545;
    font-weight: bold;
    font-size: 0.8em;
    margin-top: 10px;
}

/* كارت الفلتر */
.kpi-filter-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    margin-bottom: 25px;
    border: 1px solid #eee;
    overflow: hidden;
}

/* هيدر الفلتر */
.filter-header {
    background: #fdfdfd;
    padding: 12px 20px;
    border-bottom: 1px solid #f0f0f0;
    font-weight: bold;
    color: #C8102E; /* لون السويدي */
}

/* جسم الفلتر */
.filter-body {
    display: flex;
    gap: 20px;
    padding: 20px;
    flex-wrap: wrap;
}

.filter-group {
    flex: 1;
    min-width: 250px;
}

.filter-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #444;
    font-size: 0.9em;
}

/* مداخل البيانات الحديثة */
.modern-input, .custom-select-trigger input {
    width: 100%;
    padding: 12px 15px;
    border: 1.5px solid #e1e1e1;
    border-radius: 8px;
    outline: none;
    transition: 0.3s;
    background: #fafafa;
}

.modern-input:focus, .custom-select-trigger:hover input {
    border-color: #C8102E;
    background: #fff;
}

/* مشغل البوب أب المخصص */
.custom-select-trigger {
    position: relative;
    cursor: pointer;
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #C8102E;
}

/* شريط معلومات الموظف المختار */
.employee-meta-info {
    background: #f8f9fa;
    padding: 10px 20px;
    font-size: 0.85em;
    color: #666;
    border-top: 1px dashed #ddd;
    text-align: right;
}
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    direction: ltr; /* لجعل العناوين الإنجليزية تظهر بشكل صحيح */
}

.stat-card {
    background: #fff;
    padding: 15px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border-right: 5px solid #ccc; /* لتمييز البطاقة */
}

/* ألوان الأقسام */
.sewedy-trn { border-right-color: #c8102e; } /* أحمر */
.sewedy-ind { border-right-color: #0056b3; } /* أزرق */
.sub-trn { border-right-color: #ff9800; }    /* برتقالي */
.sub-ind { border-right-color: #28a745; }    /* أخضر */

.stat-card i {
    font-size: 2rem;
    color: #555;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.85rem;
    color: #666;
    font-weight: 600;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #333;
}

.sewedy-open-obs { border-right-color: #c8102e !important; }   /* أحمر */
.sewedy-closed-obs { border-right-color: #28a745 !important; } /* أخضر */
.contractor-open-obs { border-right-color: #ff9800 !important; } /* برتقالي */
.contractor-closed-obs { border-right-color: #0056b3 !important; } /* أزرق */

/* تنسيق الأزرار في وضع الموبايل لقسم المخازن */
@media (max-width: 768px) {
    /* استهداف حاوية الأزرار داخل قسم تقرير المخازن */
    #ProjectStockReport .filter-controls div[style*="display: flex"] {
        flex-direction: column !important; /* تحويل الأزرار لتحت بعض */
        gap: 10px !important;
    }

    /* جعل الأزرار تأخذ عرض الشاشة بالكامل */
    #ProjectStockReport .filter-controls .btn {
        width: 100% !important;
        flex: none !important; /* إلغاء تقسيم المساحة القديم (3 إلى 1) */
        margin-left: 0 !important;
    }
}


/* تنسيقات التقرير اليومي V2 */
.card-step {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}

.step-title {
    color: var(--primary-color);
    font-size: 1.1rem;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.step-num {
    background: var(--primary-color);
    color: #fff;
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}

.compact-input-row {
    display: flex;
    flex-wrap: wrap; /* للسماح بالالتفاف في الشاشات الصغيرة */
    gap: 12px;
    padding: 12px;
    background: #fdfdfd;
    border: 1px solid #eee;
    border-radius: 8px;
    justify-content: flex-start;
}

.input-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 65px; /* توسيع المساحة لمنع التآكل */
}

.input-unit small {
    font-size: 11px;
    font-weight: 700;
    color: #444;
    margin-bottom: 5px;
    white-space: nowrap;
}

.input-unit input {
    width: 55px !important;
    height: 35px !important;
    text-align: center;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* تنسيق خاص للكمبيوتر */
@media (min-width: 1024px) {
    .input-unit { min-width: 80px; }
    .input-unit input { width: 65px !important; }
    .compact-input-row { gap: 15px; }
}

.highlight-security {
    background: #fff3f3;
    border: 1px solid #ffcccc;
    padding: 8px;
    border-radius: 8px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}

.label-red {
    display: block;
    color: #c8102e;
    font-weight: 800;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.alert-box-red {
    border-right: 6px solid #dc3545;
    background-color: #fff5f5;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}
.empty-state {
    text-align: center;
    padding: 40px;
    color: #28a745;
}

.report-viewer {
    max-height: 70vh;
    overflow-y: auto;
    padding: 10px;
}

.report-viewer .results-table {
    min-width: 1000px; /* لضمان عدم عصر الأعمدة */
}

.report-header-info p {
    margin: 5px 0;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}


/* ========================================= */
/* --- إصلاح جدول المقاولين في التقرير اليومي (للموبايل) --- */
/* ========================================= */

#added-entities-container {
    width: 100%;
    overflow-x: auto !important; /* تفعيل السكرول الأفقي */
    -webkit-overflow-scrolling: touch; /* نعومة السكرول في الآيفون */
    border: 1px solid var(--medium-gray);
    border-radius: 8px;
    background: #fff;
    margin-top: 15px;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.02); /* ظل داخلي خفيف يوضح إن فيه سكرول */
}

#added-entities-container table {
    min-width: 550px !important; /* إجبار الجدول على عرض معين عشان ميتعصرش */
    width: 100%;
    white-space: nowrap; /* منع نزول الكلام لسطر جديد */
}

/* تنسيق زرار الحذف جوه الجدول عشان ميكبرش */
#added-entities-container .btn-danger {
    padding: 5px 10px !important;
    font-size: 0.8rem !important;
    width: auto !important;
    height: auto !important;
}

/* ========================================= */
/* تصميم كروت الفحص (Mobile Friendly) */
/* ========================================= */
.inspection-cards-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.insp-item-card {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.insp-item-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: #2C2A29;
    margin-bottom: 12px;
    line-height: 1.5;
    border-bottom: 1px dashed #ccc;
    padding-bottom: 10px;
}

.insp-item-title span.badge-num {
    background: #C8102E;
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    margin-left: 8px;
}

/* تنسيق خيارات الـ Radio كزراير */
.insp-options-group {
    display: flex;
    gap: 10px;
}

.insp-opt-label {
    flex: 1;
    cursor: pointer;
    margin: 0;
}

.insp-opt-label input[type="radio"] {
    display: none; /* إخفاء النقطة الدائرية الافتراضية */
}

.insp-opt-btn {
    display: block;
    text-align: center;
    padding: 10px 5px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-weight: bold;
    font-size: 0.9rem;
    color: #555;
    background: #fff;
    transition: all 0.2s ease-in-out;
}

/* لما المستخدم يختار الـ Radio Button، نغير لون الـ Div اللي بعده */
/* (S) Satisfactory -> أخضر */
.insp-opt-label input[value="S"]:checked + .insp-opt-btn {
    background-color: #28a745;
    border-color: #28a745;
    color: #fff;
}

/* (U) Unsatisfactory -> أحمر */
.insp-opt-label input[value="U"]:checked + .insp-opt-btn {
    background-color: #dc3545;
    border-color: #dc3545;
    color: #fff;
}

/* (NA) Not Applicable -> رصاصي */
.insp-opt-label input[value="NA"]:checked + .insp-opt-btn {
    background-color: #6c757d;
    border-color: #6c757d;
    color: #fff;
}

/* تأثير عند المرور بالماوس */
.insp-opt-label:hover .insp-opt-btn {
    background-color: #f1f1f1;
}
.insp-opt-label input:checked + .insp-opt-btn:hover {
    filter: brightness(0.9);
}
