/* General Body Styles */
body {
    font-family: 'Cairo', sans-serif;
    background-color: #f4f7f6;
    margin: 0;
    direction: rtl;
}
.status-assembled_pending_delivery { background-color: #17a2b8; } /* لون سماوي أغمق */

/* Login Page Styles */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: #ffffff;
}
.login-box {
    padding: 40px;
    background: #fff;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    border-radius: 10px;
    text-align: center;
    width: 350px;
}
.login-box img {
    max-width: 200px;
    margin-bottom: 20px;
}
.login-box h2 {
    margin-bottom: 20px;
    color: #333;
}

/* Form Styles */
.form-group {
    margin-bottom: 15px;
    text-align: right;
}
.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}
.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
    transition: border-color 0.3s;
}
.form-control:focus {
    border-color: #00aaff; /* Sky Blue */
    outline: none;
}

/* Button Styles */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background-color 0.3s, transform 0.2s;
}
.btn-primary {
    background-color: #00aaff; /* Sky Blue */
    color: white;
    width: 100%;
}
.btn-primary:hover {
    background-color: #0088cc;
    transform: translateY(-2px);
}
.btn-secondary {
    background-color: #343a40; /* Dark Gray/Black */
    color: white;
}
.btn-secondary:hover {
    background-color: #23272b;
}
.btn-success {
    background-color: #28a745;
    color: white;
}
.btn-warning {
    background-color: #ffc107;
    color: black;
}

/* Main Layout (Admin & Assembler) */
.main-container {
    display: flex;
}
.sidebar {
    width: 200px;
    background-color: #111; /* Black */
    color: white;
    height: 100vh;
    padding: 20px;
    position: fixed;
}
.sidebar .logo {
    text-align: center;
    margin-bottom: 30px;
}
.sidebar .logo img {
    max-width: 150px;
}
.sidebar-menu {
    list-style: none;
    padding: 0;
}
.sidebar-menu li a {
    color: white;
    text-decoration: none;
    display: block;
    padding: 15px 10px 15px 20px; /* Top, Right, Bottom, Left */
    border-radius: 5px;
    transition: background-color 0.3s;
}
.sidebar-menu li a:hover, .sidebar-menu li a.active {
    background-color: #00aaff; /* Sky Blue */
}
.content {
    margin-right: 260px; /* Same as sidebar width */
    padding: 30px;
    width: calc(100% - 250px);
    transition: margin-right 0.3s ease-in-out;
}

/* Card Styles */
.card {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}
.card-header {
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 15px;
    font-size: 20px;
    font-weight: bold;
    color: #333;
}

/* Table Styles */
.table {
    width: 100%;
    border-collapse: collapse;
}
.table th, .table td {
    padding: 12px;
    text-align: right;
    border-bottom: 1px solid #ddd;
}
.table th {
    background-color: #f2f2f2;
}
.status {
    padding: 5px 10px;
    border-radius: 15px;
    color: white;
    font-size: 12px;
    font-weight: bold;
}
.status-pending { background-color: #ffc107; color: black; }
.status-in_progress { background-color: #00aaff; }
.status-assembled { background-color: #28a745; }
.status-delivered_customer { background-color: #6f42c1; }
.status-archived { background-color: #c4171e; } /* لون رمادي داكن */

/* Assembler Mobile View */
.assembler-container {
    padding: 15px;
}
.tabs {
    display: flex;
    margin-bottom: 20px;
}
.tab-link {
    flex: 1;
    padding: 15px;
    text-align: center;
    background-color: #e9ecef;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background-color 0.3s;
}
.tab-link.active {
    background-color: #00aaff;
    color: white;
}
.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
}
.assembly-card {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    margin-bottom: 15px;
}
.assembly-card h3 {
    margin-top: 0;
}
.assembly-card p {
    color: #555;
    margin: 5px 0;
}
/* * إصلاح مشكلة ظهور القائمة المنسدلة جهة اليمين
 * وتحديد عرضها ليكون بحجم المحتوى
*/
select.form-control {
    width: auto; /* يجعل العرض يتناسب مع حجم النص */
    min-width: 250px; /* يضع عرضًا أدنى مناسبًا حتى لا تكون القائمة صغيرة جدًا */
    
    /* السطر التالي هو الحل السحري لمشكلة الاتجاه */
    direction: ltr;
    
    /* السطر التالي يبقي النص داخل القائمة نفسها محاذيًا لليمين */
    text-align: right;
    padding-left: 15px; /* إضافة مساحة إضافية للسهم */
}
/*
 * إضافة ألوان للحالات المتبقية
*/

/* لون أحمر لحالة "لم يتم التجميع" للدلالة على وجود مشكلة */
.status-not_assembled {
    background-color: #dc3545;
    color: white;
}

/* لون رمادي لحالة "تم التسليم للشحن" كحالة إجرائية */
.status-delivered_shipping {
    background-color: #6c757d;
    color: white;
}
/*
 * CSS for Collapsible Sidebar
*/

/* --- Transition for smooth animation --- */
.sidebar, .content {
    transition: all 0.3s ease-in-out;
}

/* --- The Toggle Button --- */
.sidebar-toggle-btn {
    position: absolute;
    top: 20px;
    left: 20px; /* Aligned to the left for RTL */
    background-color: #00aaff;
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    line-height: 30px;
    text-align: center;
    padding: 0;
    z-index: 1100;
    transition: transform 0.3s ease;
}

/* --- Styles for Collapsed State --- */
body.sidebar-toggled .sidebar {
    width: 80px; /* The new smaller width */
}

body.sidebar-toggled .content {
    margin-right: 80px; /* Match the new sidebar width */
}

body.sidebar-toggled .sidebar .logo {
    display: none; /* Hide the logo when collapsed */
}

body.sidebar-toggled .sidebar .sidebar-menu a span {
    display: none; /* Hide the text inside links */
}

body.sidebar-toggled .sidebar-toggle-btn {
    transform: rotate(180deg); /* Flip the arrow button */
}

/*
 * تصميم جديد وواضح لقائمة القطع (التفاصيل)
*/
/*
 * التصميم النهائي لقائمة القطع (التفاصيل)
*/
/*
 * التصميم النهائي والمصحح لقائمة القطع (التفاصيل)
*/
/*
 * [الحل النهائي] تصميم قائمة القطع لمنع السكرول الأفقي وتوسيع الارتفاع
*/
/* --- 1. تكبير عرض النافذة المنبثقة --- */
.modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 25px;
    border-radius: 8px;
    width: 90%;
    max-width: 800px; /* زيادة العرض الأقصى */
    position: relative;
    animation: fadeIn 0.3s;
}

/* --- 2. إصلاح محاذاة مربع التفاصيل --- */
pre.details-box, 
div.specs, 
pre.specs {
    margin: 0; /* إزالة أي هوامش خارجية قد تسبب الإزاحة */
    /* بقية الخصائص تبقى كما هي */
    font-family: 'Cairo', sans-serif;
    font-size: 12px;
    font-weight: bold;
    line-height: 1.6;
    color: #2c3e50;
    column-count: 1;
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    overflow-x: hidden !important;
    direction: ltr;
    text-align: left !important;
    background: #fdfdfd;
    padding: 15px;
    border-radius: 5px;
    border: 1px solid #e0e0e0;
}
/*
 * Delivery Interface Styles
*/

/* --- Top Bar and Main Container --- */
.top-bar {
    background: #111;
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}
.top-bar h3 { margin: 0; font-size: 1.1em; }
.top-bar a { color: #00aaff; text-decoration: none; font-weight: bold; }
.delivery-container { 
    padding: 10px;
}

/* --- Tabs Styling --- */
.tabs {
    display: flex;
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 15px;
}
.tab-link {
    flex: 1;
    padding: 15px 10px;
    text-align: center;
    text-decoration: none;
    color: #555;
    font-weight: bold;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}
.tab-link.active {
    color: #00aaff;
    border-bottom-color: #00aaff;
    background-color: #f8f9fa;
}
.tab-link:hover {
    background-color: #f8f9fa;
}


/* --- Filter Form --- */
.filter-form {
    padding: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.filter-form .form-control {
    flex: 1 1 200px; /* Allow wrapping on small screens */
}
.filter-form .btn {
    flex: 1 1 100px;
}


/* --- Delivery Card --- */
.delivery-card {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    margin-bottom: 15px;
}
.delivery-card h3 { 
    margin-top: 0;
    font-size: 1.2em;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 10px;
}
.delivery-card p {
    margin: 0 0 8px 0;
    color: #333;
}
.delivery-card .actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

/* --- Modal Styles --- */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.6); justify-content: center; align-items: center; }
.modal-content { background-color: #fefefe; margin: auto; padding: 25px; border-radius: 8px; width: 100%; max-width: 900px; position: relative; animation: fadeIn 0.3s; }
.close-btn { color: #aaa; position: absolute; left: 15px; top: 10px; font-size: 28px; font-weight: bold; cursor: pointer; }
@keyframes fadeIn { from {opacity: 0; transform: scale(0.9);} to {opacity: 1; transform: scale(1);} }

/*
 * تصميم أزرار نوع الطلب
*/
.order-type-tag {
    padding: 5px 10px;
    font-size: 12px;
    font-weight: bold;
    border-radius: 5px;
    color: white;
    text-align: center;
}

.order-type-cash { background-color: #28a745; } /* أخضر */
.order-type-credit { background-color: #fd7e14; } /* برتقالي */
.order-type-provinces { background-color: #6f42c1; } /* بنفسجي */
.order-type-baghdad { background-color: #007bff; } /* أزرق */

/*
 * تصميم جديد ومحسّن لترقيم الصفحات
*/
.pagination {
    display: flex;
    justify-content: center; /* هذا السطر هو المسؤول عن التوسيط */
    align-items: center;
    gap: 8px; /* المسافة بين الأزرار */
    flex-wrap: wrap; /* للسماح بانتقال الأزرار لسطر جديد على الشاشات الصغيرة */
    padding: 15px;
    background-color: #f8f9fa; /* خلفية رمادية فاتحة */
    border-top: 1px solid #dee2e6;
    margin-top: 20px;
    border-bottom-left-radius: 8px; /* ليتناسب مع زوايا الكرت */
    border-bottom-right-radius: 8px;
}

/* --- تصغير حجم الأزرار داخل شريط الترقيم --- */
.pagination .btn {
    padding: 6px 12px; /* تقليل الهامش الداخلي */
    font-size: 14px;   /* تصغير حجم الخط */
}

/* --- تصميم أزرار أرقام الصفحات --- */
.pagination .page-num {
    background-color: #fff;
    color: #495057;
    border: 1px solid #dee2e6;
}

/* --- تصميم زر الصفحة الحالية النشطة --- */
.pagination .page-num.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
    z-index: 2;
}
/* =================================================== */
/* ======== New Floating Toggle Sidebar Styles ======= */
/* =================================================== */

/* --- Sidebar Base Styles --- */
.sidebar {
    position: fixed;
    height: 100%;
    top: 0;
    right: 0;
    width: 250px;
    background: #11101d;
    z-index: 100;
    transition: all 0.4s ease;
    display: flex;
    flex-direction: column;
}
.sidebar.collapsed {
    width: 0;
    overflow: hidden;
}

/* --- Logo Area --- */
.sidebar .logo-area {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    height: 60px;
    flex-shrink: 0;
    border-bottom: 1px solid #2c2c2c;
    white-space: nowrap;
}
.sidebar .logo-area .logo-icon {
    width: 100%;
    min-width: 40px;
}
.sidebar .logo-area .logo-name {
    font-size: 22px;
    color: #fff;
    font-weight: 600;
    margin-right: 10px;
}

/* --- Sidebar Menu Links --- */
.sidebar .sidebar-menu {
    padding: 20px 0;
    margin: 0;
    list-style: none;
    overflow-y: auto;
    flex-grow: 1;
}
.sidebar .sidebar-menu li a {
    color: #e0e0e0;
    text-decoration: none;
    display: block;
    padding: 15px 20px;
    white-space: nowrap;
    transition: background-color 0.3s, color 0.3s;
}
.sidebar .sidebar-menu li a:hover {
    background: #00aaff;
    color: #fff;
}
.sidebar .sidebar-menu li a span {
    font-size: 18px;
}

/* --- Content Area --- */
.content {
    margin-right: 250px;
    transition: margin-right 0.4s ease;
    padding: 30px;
    padding-right: 50px;
}
.content.collapsed {
margin-right: 80px;
}

/* --- Floating Toggle Button --- */
.sidebar-toggle-btn-floating {
    position: fixed;
    top: 15px;
    right: 5px;
    width: 35px;
    height: 36px;
    background-color: #343a40;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 24px;
    cursor: pointer;
    z-index: 101;
    transition: all 0.4s ease;
}
.sidebar:not(.collapsed) + .sidebar-toggle-btn-floating {
    right: 265px; /* Move button with the sidebar */
}

.sidebar .logo-details {
    height: 60px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start; /* <<< السطر الجديد هنا */
    padding-right: 15px;
    white-space: nowrap;
}
/* 1. إخفاء القائمة الفرعية بشكل افتراضي */
.sidebar-item .sidebar-dropdown {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out; /* تأثير حركة ناعم */
    list-style: none;
    padding-right: 20px; /* مسافة بادئة للتمييز */
}

/* 2. إظهار القائمة الفرعية عند مرور الماوس فوق العنصر الأب */
.sidebar-item:hover > .sidebar-dropdown {
    max-height: 500px; /* قيمة كبيرة بما يكفي لإظهار كل العناصر */
}

/* 3. ستايل بسيط لعناصر القائمة الفرعية */
.sidebar-item .sidebar-dropdown .sidebar-link {
    padding: 8px 15px;
    font-size: 0.9em; /* حجم خط أصغر قليلاً */
    color: #ccc; /* لون باهت قليلاً */
    background-color: #343a40; /* خلفية أغمق قليلاً */
}

.sidebar-item .sidebar-dropdown .sidebar-link:hover {
    color: #fff;
    background-color: #495057;
}

/* CSS الخاص بتنبيه النجاح (النسخة الفاخرة) */
.toast-notification {
    position: fixed;
    top: 20px; /* يبدأ قريبًا من الأعلى */
    left: 50%;
    transform: translateX(-50%) translateY(-150%); /* يبدأ خارج الشاشة تمامًا */
    background: linear-gradient(135deg, #2d3436, #000000); /* تدرج أسود فخم */
    color: white;
    padding: 18px 28px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 15px 35px rgba(0,0,0,0.4);
    z-index: 1050;
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 1.15rem;
    font-weight: 600;
    opacity: 0;
    /* حركة دخول وخروج ناعمة جدًا */
    transition: transform 0.6s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.6s ease;
    pointer-events: none; /* لمنعه من اعتراض النقرات وهو مخفي */
}

/* حالة الظهور */
.toast-notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0); /* ينزل بسلاسة إلى مكانه */
    pointer-events: auto;
}

/* حالة الاختفاء التدريجي */
.toast-notification.hide {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px); /* يرتفع قليلاً ويختفي */
}

/* ------- */

/* =================================================== */
/* == تصميم فاخر ومتجاوب (النسخة النهائية والمحسّنة) == */
/* =================================================== */

/* --- 1. تصميم كروت الإحصائيات الفاخرة --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    padding: 15px; /* تقليل الحشو قليلاً */
}
.stat-card-link {
    text-decoration: none;
    color: inherit;
}
.stat-card {
    background-color: #fff;
    border-radius: 12px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    border: 1px solid #e0e0e0;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.08);
}
.stat-card-icon {
    font-size: 2.2em; /* تصغير الأيقونة قليلاً */
    width: 55px;
    height: 55px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
}
.stat-card-info h4 {
    margin: 0 0 5px 0;
    font-size: 0.9rem;
    color: #333;
}
.stat-card-info span {
    font-size: 1.7em;
    font-weight: bold;
    color: #111;
}
/* ألوان كروت الإحصائيات */
.stat-card.color-all .stat-card-icon { background: #6c757d; }
.stat-card.color-pending .stat-card-icon { background: #ffc107; }
.stat-card.color-progress .stat-card-icon { background: #00aaff; }
.stat-card.color-awaiting .stat-card-icon { background: #17a2b8; }
.stat-card.color-delivered .stat-card-icon { background: #28a745; }
.stat-card.color-archived .stat-card-icon { background: #dc3545; }


/* --- 2. إعادة خلفية فورم الفلترة --- */
.filter-form-wrapper {
    padding: 15px; 
    background-color:#f8f9fa; 
    border-radius:5px; 
    margin-bottom:20px;
}
.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
}
.filter-form .form-group {
    margin-bottom: 0;
    flex: 1 1 200px;
}
.filter-form .btn {
    flex-basis: 100px;
}


/* --- 3. تصميم الجدول المتجاوب --- */
.table-responsive-wrapper {
    overflow-x: auto;
}
.responsive-table {
    width: 100%;
    border-collapse: collapse;
}
.responsive-table th, .responsive-table td {
    padding: 15px 12px;
    text-align: right;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}
.responsive-table th {
    background-color: #f8f9fa;
    font-weight: bold;
    color: #495057;
    font-size: 14px;
}
.responsive-table tr:hover {
    background-color: #f9f9f9;
}

/* أزرار الإجراءات */
.actions-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
}
.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    font-size: 13px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: white;
    transition: all 0.2s ease;
}
.btn-action:hover { opacity: 0.85; transform: translateY(-1px); }
.btn-details { background-color: #6c757d; }
.btn-timestamps { background-color: #17a2b8; }
.btn-print { background-color: #343a40; }
.btn-edit { background-color: #ffc107; color: black; }
.btn-delete { background-color: #dc3545; }
.btn-icon {
    background: none; border: none; color: #007bff;
    cursor: pointer; font-size: 1.4em; padding: 0;
}

/* ========================================================= */
/* == الكود النهائي والمُصحّح للهاتف (الإصدار الأخير) == */
/* ========================================================= */

/* إخفاء عناصر الهاتف على الشاشة الكبيرة بشكل افتراضي */
.mobile-header,
.sidebar-overlay,
.sidebar-header {
    display: none;
}

/* --- الأنماط عند عرض الموقع على شاشات الهاتف والأجهزة اللوحية --- */
@media (max-width: 992px) {
    
    /* 1. [الإصلاح الجذري] تغيير تخطيط الحاوية الرئيسية */
    .main-container {
        display: block !important; /* التحويل إلى بلوك ليتم ترتيب العناصر عمودياً */
    }

    /* 2. إظهار وتنسيق الشريط العلوي للهاتف */
    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 15px;
        height: 60px;
        background-color: #fff;
        border-bottom: 1px solid #e0e0e0;
        position: sticky; /* يجعله يثبت في الأعلى عند التمرير */
        top: 0;
        z-index: 999;
        width: 100%;
        box-sizing: border-box; /* يمنع المشاكل مع الهوامش */
    }
    .mobile-menu-toggle {
        background: none; border: none; font-size: 24px;
        cursor: pointer; color: #333;
    }
    .mobile-logo img {
        height: 35px;
    }

    /* 3. إجبار المحتوى على شغل كامل الشاشة وإلغاء الهوامش */
    .content, .content.collapsed {
        margin-right: 0 !important;
        padding: 15px !important;
        width: 100% !important;
        box-sizing: border-box;
    }

    /* 4. إخفاء العناصر الخاصة بالحاسوب */
    .sidebar .logo-area,
    .sidebar-toggle-btn-floating {
        display: none !important;
    }

    /* 5. تحويل القائمة الجانبية إلى قائمة منسدلة */
    .sidebar {
        position: fixed; top: 0; right: 0;
        width: 280px; height: 100vh; z-index: 1001;
        transform: translateX(100%);
        transition: transform 0.3s ease-in-out;
        overflow-y: auto;
    }
    .sidebar.is-open {
        transform: translateX(0);
        box-shadow: -5px 0 20px rgba(0,0,0,0.2);
    }
    
    /* 6. تنسيق زر الإغلاق (X) */
    .sidebar-header {
        display: flex;
        justify-content: flex-start;
        padding: 10px 15px;
    }
    .sidebar-close-btn {
        background: none; border: none; color: #fff;
        font-size: 30px; font-weight: bold; cursor: pointer;
    }

    /* 7. تنسيق طبقة التعتيم */
    .sidebar-overlay {
        display: block;
        position: fixed; top: 0; left: 0;
        width: 100%; height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1000;
        opacity: 0; visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }
    .sidebar-overlay.is-open {
        opacity: 1; visibility: visible;
    }
}