/* ==========================================================================
   نظام التصميم والبصريات لورشة لكس (Design System & Variables)
   ========================================================================== */

:root {
    --font-primary: 'Tajawal', sans-serif;
    
    /* لوحة الألوان الأساسية الداكنة الفاخرة المستوحاة من الشعار والموك اب */
    --bg-main: #090f1d;
    --bg-card: rgba(14, 22, 41, 0.7);
    --bg-sidebar: #060a14;
    --bg-header: rgba(9, 15, 29, 0.65);
    --border-color: rgba(233, 216, 138, 0.12); /* حدود ذهبية خفيفة شفافة */
    --border-highlight: rgba(233, 216, 138, 0.3); /* حدود ذهبية متوهجة */
    
    /* الذهبي الفاخر الملكي كشريك أساسي للتصميم */
    --color-primary: #d4af37;
    --color-primary-glow: rgba(212, 175, 55, 0.35);
    --color-primary-alpha: rgba(212, 175, 55, 0.12);
    --color-accent: var(--color-primary); /* إصلاح المتغير المفقود */
    
    --color-success: #10b981;
    --color-success-glow: rgba(16, 185, 129, 0.4);
    --color-success-alpha: rgba(16, 185, 129, 0.15);
    
    --color-warning: #f59e0b;
    --color-warning-glow: rgba(245, 158, 11, 0.4);
    --color-warning-alpha: rgba(245, 158, 11, 0.15);
    
    --color-danger: #ef4444;
    --color-danger-glow: rgba(239, 68, 68, 0.4);
    --color-danger-alpha: rgba(239, 68, 68, 0.15);
    
    /* لون أزرق ملكي داكن للمؤشرات والتوزيعات المماثلة لـ 3.webp */
    --color-info: #0252a7;
    --color-info-glow: rgba(2, 82, 167, 0.4);
    --color-info-alpha: rgba(2, 82, 167, 0.15);

    /* ألوان النصوص */
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dark: #1f2937;
    --text-gold: #e9d88a; /* نص ذهبي ملكي فاتح */
    
    /* الانتقالات الحركية والمؤثرات */
    --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --blur-value: 20px;
    --border-radius: 16px;
}

body.light-theme {
    --bg-main: #f3f4f6;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-sidebar: #ffffff;
    --bg-header: rgba(243, 244, 246, 0.8);
    --border-color: rgba(0, 0, 0, 0.08);
    --border-highlight: rgba(212, 175, 55, 0.5);
    
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --text-gold: #c5a028;
    
    --color-primary-alpha: rgba(212, 175, 55, 0.2);
    --color-success-alpha: rgba(16, 185, 129, 0.2);
    --color-warning-alpha: rgba(245, 158, 11, 0.2);
    --color-danger-alpha: rgba(239, 68, 68, 0.2);
    --color-info-alpha: rgba(2, 82, 167, 0.2);
}

/* ==========================================================================
   تخصيص الوضع المضيء (Light Theme Overrides)
   ========================================================================== */

/* 1. الخلفية الرئيسية للمحتوى */
body.light-theme .main-content {
    background: var(--bg-main) !important;
}

/* 2. بطاقات الجداول والصفوف على الهواتف */
@media (max-width: 768px) {
    body.light-theme .data-table tr, 
    body.light-theme .table tr {
        background: #ffffff !important;
        border-color: rgba(0, 0, 0, 0.08) !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05) !important;
    }
    
    body.light-theme .data-table tr::before, 
    body.light-theme .table tr::before {
        border-radius: 16px !important;
    }
}

/* 3. حقول الإدخال والتحكم */
body.light-theme .form-control {
    background: #ffffff !important;
    border-color: rgba(0, 0, 0, 0.15) !important;
    color: var(--text-main) !important;
}
body.light-theme .form-control:focus {
    border-color: var(--color-primary) !important;
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.25) !important;
}
body.light-theme ::placeholder {
    color: rgba(0, 0, 0, 0.4) !important;
}

/* 4. القوائم المنسدلة وأشرطة التمرير والبحث التلقائي */
body.light-theme ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15) !important;
}
body.light-theme ::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary) !important;
}
body.light-theme .search-select-options {
    background: #ffffff !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08) !important;
}
body.light-theme .search-select-options > div {
    background: #ffffff !important;
    color: var(--text-main) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}
body.light-theme .search-select-options > div:hover {
    background: rgba(0, 0, 0, 0.04) !important;
    color: var(--text-gold) !important;
}
body.light-theme .notification-dropdown {
    background: #ffffff !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08) !important;
    color: var(--text-main) !important;
}
body.light-theme .dropdown-header h3 {
    color: var(--text-main) !important;
}
body.light-theme .btn-clear-notif {
    color: var(--text-muted) !important;
}
body.light-theme .btn-clear-notif:hover {
    color: var(--text-main) !important;
}
body.light-theme .notif-item {
    background: rgba(0, 0, 0, 0.02) !important;
    border-color: rgba(0, 0, 0, 0.06) !important;
    color: var(--text-main) !important;
}
body.light-theme .no-notif-message {
    color: var(--text-muted) !important;
}

/* 5. شاشة الدردشة والتنبيهات */
body.light-theme .chat-header {
    background: #ffffff !important;
    border-bottom-color: rgba(0, 0, 0, 0.08) !important;
}
body.light-theme .chat-messages-body {
    background: #f9fafb !important;
}
body.light-theme .chat-footer-input {
    background: #ffffff !important;
    border-top-color: rgba(0, 0, 0, 0.08) !important;
}
body.light-theme .chat-bubble.received .chat-bubble-content {
    background-color: #f3f4f6 !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
    color: var(--text-main) !important;
}
body.light-theme .chat-context-menu {
    background: #ffffff !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08) !important;
}
body.light-theme .chat-context-menu button {
    color: var(--text-main) !important;
}
body.light-theme .chat-context-menu button:hover {
    background: rgba(0, 0, 0, 0.04) !important;
}
body.light-theme .voice-recording-overlay {
    background: rgba(255, 255, 255, 0.95) !important;
    color: var(--text-main) !important;
}
body.light-theme .toast {
    background: #ffffff !important;
    border-color: rgba(0, 0, 0, 0.06) !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08) !important;
}

/* 6. بطاقات الملاحة الرئيسية واللوحة الخلفية */
body.light-theme .section-nav-card:hover {
    background: #ffffff !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05), 0 0 15px rgba(212, 175, 55, 0.2) !important;
}
body.light-theme .login-wrapper {
    background: radial-gradient(circle at center, #ffffff 0%, #f3f4f6 100%) !important;
}
body.light-theme .login-card {
    background: #ffffff !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.06) !important;
}

/* ==========================================================================
   التنسيق العام وعناصر البنية التحتية (Reset & Base Styles)
   ========================================================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-primary);
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* تخصيص أشرطة التمرير */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary);
}

/* لوحات الزجاج (Glassmorphism Panels) */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(var(--blur-value)) saturate(180%);
    -webkit-backdrop-filter: blur(var(--blur-value)) saturate(180%);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.45);
    transition: var(--transition-normal);
}

.glass-panel:hover {
    border-color: var(--border-highlight);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.55), 0 0 15px 0 var(--color-primary-alpha);
}

a {
    color: inherit;
    text-decoration: none;
}

/* ==========================================================================
   شاشة تسجيل الدخول (Login Wrapper)
   ========================================================================== */

.login-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #0e1a35 0%, #050a14 100%);
    padding: 20px;
    z-index: 9999;
}

.login-card {
    width: 100%;
    max-width: 460px;
    padding: 40px;
    border: 1px solid var(--border-color);
}

.login-logo {
    max-width: 130px;
    height: auto;
    border-radius: 10px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
    box-shadow: 0 0 20px 0 var(--color-primary-glow);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.logo-glow {
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: 2px;
    background: linear-gradient(to left, var(--color-primary), var(--text-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px var(--color-primary-glow);
    margin-bottom: 10px;
}

.login-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-main);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper i {
    position: absolute;
    right: 14px;
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.input-wrapper input {
    width: 100%;
    padding: 12px 42px 12px 14px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 0.95rem;
    transition: var(--transition-fast);
}

.input-wrapper input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-glow);
    outline: none;
}

.login-footer {
    text-align: center;
    margin-top: 25px;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.login-footer strong {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

/* ==========================================================================
   الهيكل العام للمنصة (Layout & Shell)
   ========================================================================== */

.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100vw;
}

/* شريط القائمة الجانبية (Sidebar) */
.sidebar {
    width: 280px;
    flex-shrink: 0;
    border-radius: 0;
    border-top: 0;
    border-bottom: 0;
    border-right: 0;
    border-left: 1px solid var(--border-color);
    background-color: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: var(--transition-normal);
}

.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo {
    height: 38px;
    width: auto;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    box-shadow: 0 0 10px 0 var(--color-primary-glow);
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-menu {
    flex: 1;
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition-fast);
    cursor: pointer;
}

.menu-item i {
    width: 18px;
    height: 18px;
}

.menu-item:hover {
    background: rgba(233, 216, 138, 0.06);
    color: var(--text-gold);
}

.menu-item.active {
    background: rgba(212, 175, 55, 0.12);
    color: var(--color-primary);
    border-right: 4px solid var(--color-primary);
    box-shadow: inset 5px 0 15px rgba(212, 175, 55, 0.05);
    font-weight: 700;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.active-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    margin-bottom: 12px;
}

.active-user-info i {
    width: 24px;
    height: 24px;
}

.user-fullname {
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.user-role-badge {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* المحتوى الرئيسي (Main Container) */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    background: radial-gradient(circle at top left, #0e1a35 0%, #060b14 100%);
    padding: 24px;
}

.main-header {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    border-radius: var(--border-radius);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-right h1 {
    font-size: 1.3rem;
    font-weight: 700;
}

.menu-toggle-btn {
    background: rgba(212, 175, 55, 0.1);
    border: 1px solid var(--border-color);
    color: var(--color-primary);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.menu-toggle-btn:hover {
    background: rgba(212, 175, 55, 0.2);
    box-shadow: 0 0 10px var(--color-primary-glow);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* ==========================================================================
   أزرار وتنسيقات النماذج (Buttons & Forms)
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
    color: #fff;
    outline: none;
}

.btn i {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background-color: var(--color-primary);
    box-shadow: 0 4px 12px 0 var(--color-primary-glow);
}
.btn-primary:hover {
    background-color: #4338ca;
    transform: translateY(-1px);
}

.btn-success {
    background-color: var(--color-success);
    box-shadow: 0 4px 12px 0 var(--color-success-glow);
}
.btn-success:hover {
    background-color: #059669;
    transform: translateY(-1px);
}

.btn-danger {
    background-color: var(--color-danger);
    box-shadow: 0 4px 12px 0 var(--color-danger-glow);
}
.btn-danger:hover {
    background-color: #dc2626;
    transform: translateY(-1px);
}

.btn-warning {
    background-color: var(--color-primary) !important;
    box-shadow: 0 4px 12px 0 var(--color-primary-glow);
    color: #fff !important;
}
.btn-warning:hover {
    background-color: #4338ca !important;
    transform: translateY(-1px);
    color: #fff !important;
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-xs {
    padding: 4px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
}

.btn-block {
    width: 100%;
}

.form-control {
    width: 100%;
    padding: 11px 15px;
    background: rgba(4, 8, 16, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-main);
    font-size: 0.92rem;
    outline: none;
    transition: var(--transition-fast);
}

.form-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-glow), 0 0 10px 0 var(--color-primary-glow);
    background: rgba(4, 8, 16, 0.6);
}

textarea.form-control {
    resize: vertical;
}

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.form-row .col {
    flex: 1;
}

.helper-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* تبديل الحسابات */
.user-switcher-container {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.switcher-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.user-select-switcher {
    padding: 4px 8px;
    font-size: 0.8rem;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    width: auto;
}

/* ==========================================================================
   إشعارات الجرس في الشريط العلوي (Notifications Bell)
   ========================================================================== */

.notification-bell-wrapper {
    position: relative;
}

.bell-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: var(--transition-fast);
}

.bell-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.bell-badge {
    position: absolute;
    top: -4px;
    left: -4px;
    background: var(--color-danger);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    box-shadow: 0 0 10px 0 var(--color-danger-glow);
}

.notification-dropdown {
    position: absolute;
    left: 0;
    top: 50px;
    width: 320px;
    z-index: 99999;
    padding: 16px;
    background: #1a1a2e;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.6);
    max-height: 400px;
    overflow-y: auto;
}

.dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.dropdown-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
}

.btn-clear-notif {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
}

.btn-clear-notif:hover {
    color: var(--text-main);
}

.dropdown-body {
    max-height: 250px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.notif-item {
    display: flex;
    gap: 10px;
    padding: 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    font-size: 0.8rem;
    line-height: 1.4;
}

.notif-item.danger-notif {
    border-right: 4px solid var(--color-danger);
}
.notif-item.warning-notif {
    border-right: 4px solid var(--color-warning);
}

.no-notif-message {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ==========================================================================
   بطاقات الإحصائيات ولوحة التحكم (Stats Cards & Dashboard View)
   ========================================================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px;
    transition: var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px -5px rgba(0,0,0,0.5);
}

.border-glow-primary { border-color: rgba(212, 175, 55, 0.35); }
.border-glow-success { border-color: rgba(16, 185, 129, 0.35); }
.border-glow-warning { border-color: rgba(245, 158, 11, 0.35); }
.border-glow-info { border-color: rgba(2, 82, 167, 0.35); }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bg-primary-alpha { background: var(--color-primary-alpha); }
.bg-success-alpha { background: var(--color-success-alpha); }
.bg-warning-alpha { background: var(--color-warning-alpha); }
.bg-danger-alpha { background: var(--color-danger-alpha); }
.bg-info-alpha { background: var(--color-info-alpha); }

.stat-icon i {
    width: 24px;
    height: 24px;
}

.stat-details h3 {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.stat-value {
    font-size: 1.45rem;
    font-weight: 800;
}

.stat-details p {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* هيكل الأعمدة والصفوف */
.dashboard-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.flex-1 { flex: 1; min-width: 300px; }
.flex-2 { flex: 2; min-width: 300px; }
.flex-3 { flex: 3; min-width: 300px; }

.card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.card-header {
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body {
    padding: 24px;
}

.border-bottom { border-bottom: 1px solid var(--border-color); }
.border-top { border-top: 1px solid var(--border-color); }
.padding-0 { padding: 0 !important; }
.padding-top-2 { padding-top: 16px; }
.margin-top-2 { margin-top: 20px; }
.margin-top-3 { margin-top: 30px; }
.margin-bottom-2 { margin-bottom: 20px; }
.font-bold { font-weight: 700; }
.font-code { font-family: monospace; letter-spacing: 1px; }

/* شارات الحالة */
.badge {
    display: inline-flex;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-primary { background: var(--color-primary-alpha); color: var(--text-gold); }
.badge-success { background: var(--color-success-alpha); color: #34d399; }
.badge-warning { background: var(--color-warning-alpha); color: #fbbf24; }
.badge-danger { background: var(--color-danger-alpha); color: #f87171; }
.badge-info { background: var(--color-info-alpha); color: #60a5fa; }

/* ==========================================================================
   حاسبة توزيع الأرباح (Profit Sharing Calculator UX)
   ========================================================================== */

.profit-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.sum-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 120px;
}

.sum-box span {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.sum-box strong {
    font-size: 1.25rem;
    font-weight: 800;
}

.sum-box.highlight {
    background: var(--color-primary-alpha);
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid rgba(79, 70, 229, 0.3);
}

.math-operator {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.partners-grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.partner-share-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    transition: var(--transition-fast);
}

.partner-share-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--color-primary);
}

.partner-share-card .avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
}

.partner-share-card h4 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.share-percent {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.share-val {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--color-success);
}

/* ==========================================================================
   الجداول وقائمة البيانات (Data Tables & Lists)
   ========================================================================== */

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.data-table, .table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
}

.data-table th, .data-table td,
.table th, .table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.data-table th, .table th {
    background: linear-gradient(135deg, rgba(0,0,0,0.25) 0%, rgba(0,0,0,0.15) 100%);
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
}

.data-table tbody tr, .table tbody tr {
    transition: var(--transition-fast);
}

.data-table tbody tr:hover, .table tbody tr:hover {
    background: rgba(var(--primary-rgb), 0.05);
}

.data-table tbody tr td:first-child, .table tbody tr td:first-child {
    font-weight: 600;
    color: var(--text-muted);
}

.text-center { text-align: center !important; }
.text-muted { color: var(--text-muted) !important; }
.text-success { color: var(--color-success) !important; }
.text-danger { color: var(--color-danger) !important; }
.text-warning { color: var(--color-warning) !important; }
.text-info { color: var(--color-info) !important; }

/* أجهزة الإنذار وتنبيهات المخزون */
.alert-box-warning {
    background: var(--color-danger-alpha);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}

.alert-title-icon {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: #f87171;
    font-size: 0.85rem;
}

.low-stock-ul {
    margin-top: 10px;
    margin-right: 25px;
    font-size: 0.8rem;
    color: #fca5a5;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.low-stock-ul li {
    background: rgba(0,0,0,0.2);
    padding: 4px 10px;
    border-radius: 4px;
    list-style-type: square;
}

/* ==========================================================================
   المستندات والأقسام والتبويبات (Tabs & Section control)
   ========================================================================== */

.app-section {
    display: none;
    animation: fadeIn 0.4s ease;
}

.app-section.active {
    display: block;
}

.section-actions-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}

.section-main-title {
    font-size: 1.25rem;
    font-weight: 800;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* تبويبات الزبائن والموردين */
.tabs-header {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--transition-fast);
}

.tab-btn:hover {
    color: var(--text-main);
}

.tab-btn.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ==========================================================================
   التجهيزات وآلات الورشة (Equipment Panels)
   ========================================================================== */

.equipment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

.equipment-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.equip-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
}

.equip-title h3 {
    font-size: 1.05rem;
    font-weight: 700;
}

.equip-title span {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
}

.equip-details {
    margin-bottom: 20px;
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-line {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    padding-bottom: 4px;
}

.detail-line span:first-child {
    color: var(--text-muted);
}

.detail-line span:last-child {
    font-weight: 600;
}

.maint-history-list {
    margin-top: 12px;
    background: rgba(0,0,0,0.15);
    border-radius: 6px;
    padding: 10px;
    max-height: 100px;
    overflow-y: auto;
}

.maint-history-list h4 {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 4px;
}

.maint-log-item {
    font-size: 0.7rem;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
}

.maint-log-item:last-child { margin-bottom: 0; }

/* ==========================================================================
   سجلات النظام وأمن التدقيق (System Audit Logs)
   ========================================================================== */

.recent-actions-list, .full-audit-logs-list, .audit-log-full-list {
    display: flex;
    flex-direction: column;
    max-height: 400px;
    overflow-y: auto;
}

.recent-action-item, .audit-log-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8rem;
    transition: var(--transition-fast);
}

.recent-action-item:hover, .audit-log-item:hover {
    background: rgba(255,255,255,0.02);
}

.audit-user {
    font-weight: 700;
    color: var(--color-info);
    min-width: 140px;
}

.audit-desc {
    flex: 1;
    margin-right: 12px;
}

.audit-time {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.audit-ip {
    background: rgba(255,255,255,0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-family: monospace;
    margin-right: 12px;
}

.loading-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ==========================================================================
   الـ API وتكامل الهاتف الذكي (API integration Docs & queue)
   ========================================================================== */

.api-token-box {
    background: rgba(0,0,0,0.25);
    border: 1px solid var(--border-color);
    padding: 18px;
    border-radius: 8px;
}

.input-action-group {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.api-endpoints-docs {
    background: rgba(0,0,0,0.3);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.endpoint-doc {
    background: rgba(255,255,255,0.02);
    border-radius: 6px;
    padding: 12px;
    border-right: 3px solid var(--color-primary);
}

.method {
    font-size: 0.7rem;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 4px;
    color: #fff;
    margin-left: 8px;
}

.method.get { background: var(--color-success); }
.method.post { background: var(--color-primary); }

.endpoint-path {
    font-family: monospace;
    font-size: 0.8rem;
    color: #a5b4fc;
}

.endpoint-doc p {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* طابور الإشعارات */
.queue-list-wrapper {
    display: flex;
    flex-direction: column;
    max-height: 450px;
    overflow-y: auto;
}

.queue-item {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.8rem;
}

.queue-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.queue-cust-name {
    font-weight: 700;
    color: var(--text-main);
}

.queue-cust-phone {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.queue-item-message {
    background: rgba(0,0,0,0.15);
    border-radius: 6px;
    padding: 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
    border: 1px solid var(--border-color);
}

/* ==========================================================================
   المحادثة الجماعية العائمة (Floating Chat Widget UX)
   ========================================================================== */

.floating-chat-widget {
    position: fixed;
    bottom: 30px;
    left: 30px; /* يسار الصفحة لتناسب التخطيط العربي (Sidebar باليمين) */
    z-index: 1000;
}

.chat-badge-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--color-primary);
    border: none;
    box-shadow: 0 8px 24px var(--color-primary-glow), 0 0 0 0 rgba(79, 70, 229, 0.7);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: var(--transition-fast);
    animation: pulse-ring 2s infinite;
}

.chat-badge-btn:hover {
    transform: scale(1.05);
}

.chat-badge-btn i {
    width: 28px;
    height: 28px;
}

.chat-count-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--color-danger);
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    border: 2px solid var(--bg-primary);
    box-shadow: 0 0 12px var(--color-danger-glow);
    animation: pulse-dot 1.5s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    padding: 0 4px;
    line-height: 1;
}

@keyframes pulse-dot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
}

/* نافذة الشات الكلية */
.chat-window-panel {
    position: absolute;
    bottom: 80px;
    left: 0;
    width: 380px;
    height: 520px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-header {
    padding: 16px;
    background: rgba(15, 23, 42, 0.9);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-title-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.online-indicator {
    width: 10px;
    height: 10px;
    background: var(--color-success);
    border-radius: 50%;
    box-shadow: 0 0 8px 0 var(--color-success-glow);
}

.chat-title-info h4 {
    font-size: 0.9rem;
    font-weight: 700;
}

.chat-title-info p {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.chat-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}
.chat-close-btn:hover { color: var(--text-main); }

.chat-messages-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: rgba(5, 7, 12, 0.85);
}

/* فقاعات الرسائل (Chat Bubbles) */
.chat-bubble {
    max-width: 75%;
    display: flex;
    flex-direction: column;
}

.chat-bubble-sender {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    margin-right: 6px;
}

.chat-bubble-content {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.82rem;
    line-height: 1.4;
    word-break: break-word;
}

/* رسالة الشريك نفسه (صادرة) */
.chat-bubble.sent {
    align-self: flex-end;
}
.chat-bubble.sent .chat-bubble-sender {
    align-self: flex-end;
    margin-right: 0;
    margin-left: 6px;
}
.chat-bubble.sent .chat-bubble-content {
    background-color: var(--color-primary);
    color: #fff;
    border-top-left-radius: 0;
}

/* رسائل الشركاء الآخرين (واردة) */
.chat-bubble.received {
    align-self: flex-start;
}
.chat-bubble.received .chat-bubble-content {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border-top-right-radius: 0;
    border: 1px solid var(--border-color);
}

/* توقيت الرسالة */
.chat-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 4px;
    align-self: flex-end;
}

.chat-bubble.sent .chat-time {
    align-self: flex-start;
}

/* أزرار ومرفقات الرسالة */
.file-attachment-card {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0,0,0,0.2);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    margin-top: 4px;
    color: #818cf8;
    text-decoration: underline;
    font-size: 0.75rem;
}

.file-attachment-card i {
    width: 16px;
    height: 16px;
}

/* مشغل الصوت الفاخر (Audio Message Player UX) */
.audio-player-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.25);
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-top: 4px;
    min-width: 200px;
}

.btn-play-pause {
    background: var(--color-primary);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
}

.audio-wave-simulate {
    flex: 1;
    height: 12px;
    display: flex;
    align-items: center;
    gap: 2px;
}

.audio-bar-node {
    width: 3px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.audio-player-card.playing .audio-bar-node {
    background: var(--color-success);
    animation: audio-jump 0.8s ease infinite alternate;
}

/* إعطاء تفاوت زمني لحركة الأعمدة الصوتية */
.audio-bar-node:nth-child(1) { height: 60%; animation-delay: 0.1s; }
.audio-bar-node:nth-child(2) { height: 40%; animation-delay: 0.3s; }
.audio-bar-node:nth-child(3) { height: 80%; animation-delay: 0.2s; }
.audio-bar-node:nth-child(4) { height: 50%; animation-delay: 0.4s; }
.audio-bar-node:nth-child(5) { height: 90%; animation-delay: 0.1s; }
.audio-bar-node:nth-child(6) { height: 30%; animation-delay: 0.5s; }

.audio-timer-lbl {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: monospace;
}

/* شريط الإدخال في الشات */
.chat-footer-input {
    padding: 12px;
    background: rgba(15, 23, 42, 0.9);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.chat-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition-fast);
}

.chat-action-btn:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-main);
}

.chat-footer-input input {
    flex: 1;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 8px 16px;
    color: var(--text-main);
    font-size: 0.8rem;
    outline: none;
}

.chat-footer-input input:focus {
    border-color: var(--color-primary);
}

.btn-send-chat {
    background: var(--color-primary);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
    flex-shrink: 0;
}
.btn-send-chat:hover { background-color: #4338ca; }
.btn-send-chat i { width: 16px; height: 16px; }

/* شاشة تسجيل الصوت العائمة */
.audio-recording-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

.pulse-mic-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--color-danger);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.5rem;
    box-shadow: 0 0 20px var(--color-danger-glow);
    animation: mic-pulse 1.5s infinite;
}

.recording-timer {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 20px 0;
    font-family: monospace;
}

.recording-buttons {
    display: flex;
    gap: 16px;
}

/* شريط المعاينة */
.chat-preview-bar {
    background: rgba(79, 70, 229, 0.1);
    border-top: 1px solid var(--border-color);
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-content {
    font-size: 0.75rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-remove-preview {
    background: none;
    border: none;
    color: var(--color-danger);
    cursor: pointer;
}

/* حركات الأنيميشن */
@keyframes pulse-ring {
    0% { box-shadow: 0 8px 24px var(--color-primary-glow), 0 0 0 0 rgba(79, 70, 229, 0.7); }
    70% { box-shadow: 0 8px 24px var(--color-primary-glow), 0 0 0 15px rgba(79, 70, 229, 0); }
    100% { box-shadow: 0 8px 24px var(--color-primary-glow), 0 0 0 0 rgba(79, 70, 229, 0); }
}

@keyframes mic-pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1.08); box-shadow: 0 0 0 15px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

@keyframes audio-jump {
    from { transform: scaleY(0.4); }
    to { transform: scaleY(1.2); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   النوافذ المنبثقة الشاملة (Modals Overlay & Cards)
   ========================================================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(12px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.25s ease;
}

.modal-card {
    width: 100%;
    max-width: 750px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-card > div:not(.modal-header):not(.modal-footer),
.modal-card > form:not(.modal-header):not(.modal-footer) {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.modal-header {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition-fast);
}

.modal-close:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-main);
}

.modal-form {
    padding: 24px;
}

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

.modal-footer {
    padding: 16px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* الراديو كارد للتحديثات */
.radio-group {
    display: flex;
    flex-direction: column;
}
.radio-group.inline {
    flex-direction: row;
    gap: 16px;
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.radio-label input {
    display: none;
}

.custom-radio {
    display: block;
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.85rem;
    transition: var(--transition-fast);
}

.radio-label input:checked + .custom-radio {
    border-color: var(--color-primary);
}

.bg-success-radio { background: rgba(16, 185, 129, 0.05); }
.radio-label input:checked + .custom-radio.bg-success-radio {
    border-color: var(--color-success);
    background: var(--color-success-alpha);
}

.bg-danger-radio { background: rgba(239, 68, 68, 0.05); }
.radio-label input:checked + .custom-radio.bg-danger-radio {
    border-color: var(--color-danger);
    background: var(--color-danger-alpha);
}

.info-card-stat {
    background: rgba(255, 255, 255, 0.03);
    padding: 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
    line-height: 1.6;
}

/* ==========================================================================
   قائمة سياق الرسائل (Chat Context Menu)
   ========================================================================== */

.chat-context-menu {
    position: fixed;
    z-index: 10000;
    background: rgba(17, 25, 40, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 0;
    min-width: 160px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.chat-context-menu button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
}
.chat-context-menu button:hover {
    background: rgba(255,255,255,0.08);
}
.chat-context-menu button.danger { color: var(--color-danger); }

/* ==========================================================================
   وسائط الرسائل: صور، فيديو، صوت، ملفات (Chat Media)
   ========================================================================== */

.chat-media-img {
    max-width: 220px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
    margin-top: 4px;
}
.chat-media-img:hover { transform: scale(1.03); }

.chat-media-video {
    max-width: 260px;
    border-radius: 8px;
    margin-top: 4px;
}

.chat-audio-player {
    width: 100%;
    max-width: 240px;
    height: 36px;
    margin-top: 4px;
}

.chat-forwarded-label {
    font-size: 0.72rem;
    color: var(--color-primary);
    padding: 2px 0 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ==========================================================================
   عرض الصورة المكبّرة (Chat Lightbox Overlay)
   ========================================================================== */

.chat-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    animation: fadeIn 0.2s ease;
}
.chat-lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 8px;
}

/* سجل تصحيحات المخزون */
.correction-log-list {
    max-height: 250px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.correction-log-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8rem;
    transition: var(--transition-fast);
}

.correction-log-item:hover {
    background: rgba(255,255,255,0.02);
}

.correction-log-item:last-child {
    border-bottom: none;
}

.correction-log-user {
    font-weight: 700;
    color: var(--color-warning);
    min-width: 100px;
}

.correction-log-diff {
    display: flex;
    align-items: center;
    gap: 6px;
}

.correction-old-val {
    text-decoration: line-through;
    color: var(--text-muted);
}

.correction-new-val {
    font-weight: 700;
    color: var(--text-main);
}

.correction-log-reason {
    flex: 1;
    margin: 0 12px;
    color: var(--text-muted);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* فاتورة الشراء */
.invoice-summary-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 16px;
    font-size: 0.85rem;
}

.invoice-summary-bar strong {
    font-size: 1rem;
    font-weight: 800;
}

.invoice-row-total {
    font-weight: 700;
    color: var(--color-success);
}

#invoiceTable .form-control {
    padding: 6px 10px;
    font-size: 0.8rem;
}

/* رسم بياني للمخزون */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* جدول الخدمات الخارجية */
.services-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 24px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-info);
    border-bottom: 1px solid rgba(6,182,212,0.2);
    background: rgba(6,182,212,0.05);
}

#servicesTableBody tr:hover {
    background: rgba(6,182,212,0.05);
}

.btn-info {
    background-color: var(--color-info);
    box-shadow: 0 4px 12px 0 var(--color-info-glow);
    color: #fff;
}
.btn-info:hover {
    background-color: #0891b2;
    transform: translateY(-1px);
    color: #fff;
}

.stat-card-info {
    background: rgba(6,182,212,0.05);
    border: 1px solid rgba(6,182,212,0.2);
    border-radius: 8px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

/* ==========================================================================
   التجاوب البرمجي للشاشات الصغير (Responsive Styling)
   ========================================================================== */

.md-only {
    display: none !important;
}

@media (max-width: 992px) {
    .md-only {
        display: inline-flex !important;
    }
    
    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        right: -280px; /* تخرج خارج الشاشة باليمين في وضع الموبايل */
        left: auto;
        box-shadow: 5px 0 30px rgba(0,0,0,0.8);
        z-index: 1500 !important; /* لضمان الظهور فوق الهيدر المثبت */
    }
    
    .sidebar.open {
        right: 0;
    }
    
    .main-content {
        padding: 16px;
    }
    
    .user-switcher-container {
        display: none; /* إخفاء أداة التبديل للشريك لتوفير المساحة */
    }

    .chat-window-panel {
        width: calc(100vw - 60px);
        left: 0;
    }
}

/* ==========================================================================
   التنبيهات الاحترافية العائمة (Professional Toast Notifications)
   ========================================================================== */

#toast-container {
    position: fixed;
    top: 20px;
    left: 20px; /* الجانب الأيسر لتلافي تداخلها مع القائمة الجانبية باليمين */
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    width: 320px;
    padding: 16px;
    border-radius: var(--border-radius);
    background: rgba(17, 25, 40, 0.85);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transition: var(--transition-normal);
}

.toast.toast-error {
    border-right: 4px solid var(--color-danger);
    box-shadow: 0 8px 24px -5px rgba(239, 68, 68, 0.2);
}

.toast.toast-success {
    border-right: 4px solid var(--color-success);
    box-shadow: 0 8px 24px -5px rgba(16, 185, 129, 0.2);
}

.toast.toast-warning {
    border-right: 4px solid var(--color-warning);
    box-shadow: 0 8px 24px -5px rgba(245, 158, 11, 0.2);
}

.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.toast-message {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--text-main);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
}

.toast-close:hover {
    color: var(--text-main);
}

.error-msg {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 16px;
    text-align: center;
    animation: fadeIn 0.3s ease;
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(-40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastFadeOut {
    to { opacity: 0; transform: translateY(-10px); }
}

/* ==========================================
   تفاصيل المادة - Item Detail Modal
   ========================================== */

.detail-stats-row .stat-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
    padding: 14px 10px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.detail-stats-row .stat-card .stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.detail-stats-row .stat-card .stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.3;
}

.stat-card-success { border-right: 3px solid var(--color-success); }
.stat-card-success .stat-value { color: var(--color-success); }
.stat-card-danger { border-right: 3px solid var(--color-danger); }
.stat-card-danger .stat-value { color: var(--color-danger); }
.stat-card-info { border-right: 3px solid var(--color-info); }
.stat-card-info .stat-value { color: var(--color-info); }
.stat-card-warning { border-right: 3px solid var(--color-warning); }
.stat-card-warning .stat-value { color: var(--color-warning); }

.detail-section {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-panel);
}

.detail-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 600;
}

.detail-section-success {
    background: rgba(16, 185, 129, 0.08);
    color: var(--color-success);
    border-bottom: 1px solid rgba(16, 185, 129, 0.15);
}

.detail-section-danger {
    background: rgba(239, 68, 68, 0.08);
    color: var(--color-danger);
    border-bottom: 1px solid rgba(239, 68, 68, 0.15);
}

.detail-section-count {
    margin-right: auto;
    font-size: 0.75rem;
    font-weight: 400;
    background: rgba(255,255,255,0.1);
    padding: 2px 8px;
    border-radius: 10px;
}

.detail-table-wrap {
    max-height: 280px;
    overflow-y: auto;
}

.detail-table-wrap .table {
    margin-bottom: 0;
}

.detail-table-wrap .table thead th {
    position: sticky;
    top: 0;
    background: var(--bg-panel);
    z-index: 1;
    font-size: 0.75rem;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
}

.detail-table-wrap .table tbody td {
    padding: 7px 10px;
    font-size: 0.8rem;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.detail-table-wrap .table tfoot td {
    padding: 8px 10px;
    font-size: 0.8rem;
    background: rgba(255,255,255,0.03);
    border-top: 2px solid var(--border-color);
}

/* عرض القيم السالبة باللون الأحمر */
.text-negative,
td.text-negative,
span.text-negative {
    color: var(--color-danger) !important;
    font-weight: 700;
}

.neg-value {
    color: var(--color-danger) !important;
    font-weight: 700;
}

/* تنبيه بطاقة الشراء المستعجل */
#urgentPurchaseCard {
    animation: urgentPulse 2s infinite;
}

@keyframes urgentPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
    50% { box-shadow: 0 0 12px 2px rgba(239,68,68,0.3); }
}

/* ==========================================
   قائمة اختيار قابلة للبحث
   ========================================== */

.searchable-select-wrap {
    position: relative;
}

.search-select-input {
    cursor: text;
}

.search-select-options {
    box-shadow: 0 8px 24px -4px rgba(0,0,0,0.5);
    background: #1a1a2e !important;
    border-color: var(--border-color) !important;
}

.search-select-options > div {
    background: #1a1a2e !important;
    color: var(--text-primary);
}

.search-select-options > div:first-child {
    border-radius: 6px 6px 0 0;
}

.search-select-options > div:last-child {
    border-radius: 0 0 6px 6px;
    border-bottom: none;
}

/* صف الطلبيات القابل للنقر */
.order-row-clickable:hover {
    background: rgba(79, 70, 229, 0.08);
    transition: background 0.15s;
}

.price-clickable {
    cursor: pointer;
    position: relative;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
    transition: color 0.2s, text-shadow 0.2s;
}

.price-clickable:hover {
    color: var(--color-accent) !important;
    text-shadow: 0 0 6px rgba(234, 179, 8, 0.3);
}

.payment-overdue-glow {
    border-color: rgba(239, 68, 68, 0.4) !important;
    animation: payment-pulse 2s infinite;
}

.maint-overdue-glow {
    border-color: rgba(245, 158, 11, 0.5) !important;
    animation: maint-pulse 2.5s infinite;
}

@keyframes payment-pulse {
    0%, 100% { box-shadow: 0 0 5px rgba(239, 68, 68, 0.2); }
    50% { box-shadow: 0 0 15px rgba(239, 68, 68, 0.4); }
}

@keyframes maint-pulse {
    0%, 100% { box-shadow: 0 0 5px rgba(245, 158, 11, 0.2); }
    50% { box-shadow: 0 0 15px rgba(245, 158, 11, 0.35); }
}

/* ═══ Suggestion System ═══ */
.suggestion-trigger {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    transition: all 0.2s;
}
.suggestion-trigger:hover {
    color: var(--accent-green) !important;
    text-decoration: underline;
}
.suggestion-popup {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    margin-top: 4px;
}
.suggestion-chip {
    display: block;
    width: 100%;
    text-align: right;
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: var(--text);
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s;
    line-height: 1.5;
}
.suggestion-chip:hover {
    background: rgba(16,185,129,0.12);
    color: var(--accent-green);
}
.suggestion-chip .sug-delete {
    float: left;
    color: var(--danger);
    font-size: 0.75rem;
    opacity: 0;
    transition: opacity 0.15s;
}
.suggestion-chip:hover .sug-delete {
    opacity: 1;
}

/* ═══ Shipping Mode Radio ═══ */
.shipping-mode-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.2s;
}
.shipping-mode-label:has(input:checked) {
    border-color: var(--accent-green);
    background: rgba(16,185,129,0.08);
    color: var(--accent-green);
}

/* ═══ Photo Editor ═══ */
.photo-filter-btn, .photo-anim-btn {
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-color);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}
.photo-filter-btn:hover, .photo-anim-btn:hover {
    border-color: var(--primary);
}
.photo-filter-btn.active, .photo-anim-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
#photoEditPreview {
    filter: transition 0.3s;
}
#photoEditOverlay {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    pointer-events: none;
}

/* ═══ Manufacture Modal - Materials Preview ═══ */
#mfgMaterialsPreview {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(16, 185, 129, 0.03) 100%);
    border: 1px solid rgba(16, 185, 129, 0.15);
    border-radius: 10px;
    padding: 16px;
}
#mfgMaterialsPreview h4 {
    margin: 0 0 12px;
    font-size: 0.9rem;
    color: var(--accent-green);
    display: flex;
    align-items: center;
    gap: 8px;
}
#mfgMaterialsPreview h4::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--accent-green);
    border-radius: 50%;
}
.mfg-material-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(255,255,255,0.03);
    margin-bottom: 6px;
    transition: background 0.2s;
}
.mfg-material-row:hover {
    background: rgba(255,255,255,0.06);
}
.mfg-material-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.mfg-material-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(16, 185, 129, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}
.mfg-material-name {
    font-weight: 600;
    font-size: 0.85rem;
}
.mfg-material-unit {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.mfg-material-qty {
    display: flex;
    align-items: center;
    gap: 8px;
}
.mfg-qty-badge {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.8rem;
}
.mfg-cost-badge {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.8rem;
}
.mfg-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
    font-size: 0.85rem;
}

/* ═══ Professional Products Table ═══ */
.table .product-name-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.table .product-name-main {
    font-weight: 600;
    font-size: 0.9rem;
}
.table .product-name-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.table .stock-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.8rem;
}
.table .stock-badge.ok { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.table .stock-badge.low { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.table .stock-badge.out { background: rgba(239, 68, 68, 0.15); color: var(--color-danger); }
.table .status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.table .status-badge.manufactured { background: rgba(99, 102, 241, 0.15); color: #6366f1; }
.table .status-badge.resale { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.table .btn-action {
    width: auto;
    min-width: 34px;
    height: auto;
    padding: 4px 6px;
    border-radius: 8px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: none;
    transition: all 0.2s;
}
.table .btn-action:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.table .btn-action i { width: 16px; height: 16px; }
.table .btn-action .btn-label { font-size: 0.55rem; line-height: 1; white-space: nowrap; opacity: 0.9; }
.table .btn-action.view { background: linear-gradient(135deg, #8b5cf6, #7c3aed); color: #fff; }
.table .btn-action.edit { background: linear-gradient(135deg, #3b82f6, #2563eb); color: #fff; }
.table .btn-action.mfg { background: linear-gradient(135deg, #ec4899, #db2777); color: #fff; }
.table .btn-action.delete { background: linear-gradient(135deg, #ef4444, #dc2626); color: #fff; }
.table .btn-action.sell { background: linear-gradient(135deg, #10b981, #059669); color: #fff; }
.table .btn-action.restock { background: linear-gradient(135deg, #10b981, #059669); color: #fff; }

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}


/* ═══════════════════════════════════════════
   تخصيص كامل الموقع للهاتف ليبدو كتطبيق هاتف ذكي (Mobile App UI/UX)
   ═══════════════════════════════════════════ */

/* 1. تنسيق صف استهلاك المواد في الهاتف والكمبيوتر */
.consume-item-row {
    display: grid;
    grid-template-columns: 1fr 120px 100px auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 12px;
    padding: 16px;
    background: rgba(14, 22, 41, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.35);
    transition: var(--transition-fast);
}

@media (max-width: 768px) {
    /* تجديد شكل كامل الموقع على الهواتف */
    
    /* 2. تحسين حقل استهلاك المواد */
    .consume-item-row {
        grid-template-columns: 1fr 1fr auto;
        gap: 10px;
        padding: 14px;
    }
    .consume-item-row > div:first-child {
        grid-column: span 2;
    }
    .consume-item-row select,
    .consume-item-row input {
        min-height: 46px;
    }
    
    /* 3. نافذة منبثقة على شكل Bottom Sheet كالتطبيقات الذكية */
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
        backdrop-filter: blur(8px);
    }
    .modal-card {
        max-height: 85vh;
        border-radius: 24px 24px 0 0 !important;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.6);
        animation: slideUpBottom 0.35s cubic-bezier(0.32, 0.94, 0.6, 1);
    }
    .modal-card > div:not(.modal-header):not(.modal-footer),
    .modal-card > form:not(.modal-header):not(.modal-footer) {
        padding: 16px 20px 32px;
    }
    
    /* 4. تكبير عناصر الإدخال لتفادي التقريب التلقائي (Auto Zoom) وللمس المريح */
    .form-control, 
    select.form-control,
    input[type="text"],
    input[type="number"],
    input[type="password"],
    textarea {
        font-size: 16px !important; /* يمنع متصفح iOS وسفاري من تكبير الشاشة عند التركيز */
        padding: 13px 18px;
        min-height: 48px;
        border-radius: 12px;
    }
    
    /* 5. تحسين الأزرار في وضع الهاتف */
    .btn {
        min-height: 48px;
        padding: 12px 20px;
        font-size: 0.95rem;
        border-radius: 12px;
        width: 100%; /* تمدد الأزرار للمس المريح */
        justify-content: center;
    }
    
    .btn-xs {
        min-height: 38px;
        padding: 6px 12px;
        font-size: 0.85rem;
        width: auto;
    }
    
    .modal-footer {
        flex-direction: column-reverse; /* ترتيب الأزرار ليكون الإلغاء بالأسفل والتأكيد بالأعلى */
        gap: 10px;
        padding: 16px;
    }
    
    .modal-footer .btn {
        width: 100% !important;
    }
    
    /* 6. تحسين المظهر العام للصفحات والبطاقات */
    .dashboard-stats {
        grid-template-columns: 1fr; /* جعل كروت الإحصائيات كرت واحد في كل صف عمودي */
        gap: 12px;
        padding: 12px;
    }
    
    .stat-card {
        padding: 18px;
        border-radius: 16px;
    }
    
    /* 7. تحسين شريط الهيدر العلوي */
    .main-header {
        padding: 12px 16px;
        height: 65px;
        position: sticky;
        top: 0;
        z-index: 1000;
    }
    
    .main-header h1 {
        font-size: 1.25rem;
    }
    
    /* 8. تحسين شريط التنقل الجانبي ليكون كدرج التطبيق الناعم */
    .sidebar {
        width: 280px;
        border-radius: 0 20px 20px 0 !important;
        box-shadow: 10px 0 30px rgba(0,0,0,0.5);
    }
    
    /* 9. تحسين جداول البيانات وسلاسة التمرير للمس */
    .table-responsive {
        border-radius: 12px;
        border: 1px solid var(--border-color);
        background: var(--bg-card);
        -webkit-overflow-scrolling: touch; /* تمرير ناعم وممتد في أجهزة الآيفون */
        margin-bottom: 16px;
    }
    
    .data-table th, .data-table td {
        padding: 12px 14px;
        font-size: 0.85rem;
    }
}

@keyframes slideUpBottom {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* ═══════════════════════════════════════════
   تحسين تباعد الأزرار واستجابة الجداول على الهاتف (RTL Responsive Cards)
   ═══════════════════════════════════════════ */

@media (max-width: 768px) {
    /* 1. تباعد الأزرار لمنع تلاصقها */
    .btn, button, .btn-action {
        margin: 4px 3px !important;
    }
    
    .modal-footer {
        gap: 12px !important;
    }
    
    /* 2. تحويل جميع جداول الموقع إلى بطاقات عصرية (Responsive Cards) */
    .data-table, .table,
    .data-table thead, .table thead,
    .data-table tbody, .table tbody,
    .data-table th, .table th,
    .data-table td, .table td,
    .data-table tr, .table tr {
        display: block !important;
        width: 100% !important;
    }
    
    .data-table thead, .table thead {
        display: none !important; /* إخفاء الهيدر التقليدي */
    }
    
    .data-table tr, .table tr {
        margin-bottom: 16px !important;
        background: rgba(14, 22, 41, 0.6) !important;
        border: 1px solid var(--border-color) !important;
        border-radius: 16px !important;
        padding: 16px !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3) !important;
    }
    
    .data-table td, .table td {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 10px 0 !important;
        border-bottom: 1px solid rgba(233, 216, 138, 0.06) !important;
        font-size: 0.9rem !important;
        text-align: left !important;
    }
    
    .data-table td:last-child, .table td:last-child {
        border-bottom: none !important;
        padding-top: 12px !important;
        justify-content: flex-end !important;
        gap: 8px !important;
        flex-wrap: wrap !important;
    }
    
    /* عرض اسم العمود على اليمين باللغة العربية */
    .data-table td::before, .table td::before {
        content: attr(data-label);
        font-weight: 700 !important;
        color: var(--text-gold) !important;
        font-size: 0.85rem !important;
        margin-left: auto !important;
        margin-right: 0 !important;
        text-align: right !important;
    }
    
    /* إخفاء تسمية العمود لسطر العمليات لإعطاء الأزرار مساحة كاملة */
    .data-table td:last-child::before,
    .data-table td[data-label="العمليات"]::before,
    .table td:last-child::before,
    .table td[data-label="العمليات"]::before {
        display: none !important;
    }
    
    /* تحسين شكل وحجم الأزرار داخل الجداول لتكون مناسبة للمس والترتيب */
    .data-table td:last-child .btn,
    .data-table td:last-child button,
    .data-table td:last-child .btn-action,
    .table td:last-child .btn,
    .table td:last-child button,
    .table td:last-child .btn-action {
        margin: 0 !important;
        min-height: 40px !important;
        flex: 1 1 auto !important;
        font-size: 0.85rem !important;
        border-radius: 8px !important;
        padding: 8px 12px !important;
        justify-content: center !important;
    }
}

/* ═══════════════════════════════════════════
   تنسيق العناصر القابلة للضغط داخل الجداول بشكل احترافي
   ═══════════════════════════════════════════ */
.item-detail-trigger,
.clickable-table-link {
    cursor: pointer !important;
    color: var(--text-gold) !important;
    background: rgba(212, 175, 55, 0.09) !important;
    border: 1px solid rgba(212, 175, 55, 0.22) !important;
    border-radius: 8px !important;
    padding: 4px 10px !important;
    display: inline-block !important;
    font-size: 0.88rem !important;
    font-weight: 700 !important;
    text-decoration: none !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2) !important;
    transition: var(--transition-fast) !important;
}

.item-detail-trigger:hover,
.clickable-table-link:hover {
    background: rgba(212, 175, 55, 0.2) !important;
    border-color: var(--color-primary) !important;
    box-shadow: 0 0 10px var(--color-primary-glow) !important;
    color: #fff !important;
    transform: translateY(-1px) !important;
}

/* شبكة التنقل السريع للأقسام في لوحة التحكم */
.sections-nav-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr) !important; /* فرض 3 أعمدة دائمًا */
    gap: 16px;
    margin-bottom: 24px;
}

.section-nav-card {
    display: flex !important;
    flex-direction: column !important; /* محاذاة رأسية (الأيقونة فوق النص) */
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    gap: 12px !important;
    padding: 24px 16px !important;
    border-radius: var(--border-radius) !important;
    text-decoration: none !important;
    color: var(--text-main) !important;
    transition: var(--transition-normal) !important;
    cursor: pointer !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2) !important;
}

.section-nav-card:hover {
    transform: translateY(-4px) !important;
    border-color: var(--border-highlight) !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4), 0 0 15px var(--color-primary-alpha) !important;
    background: rgba(14, 22, 41, 0.85) !important;
}

.section-nav-card .card-icon {
    width: 64px !important; /* تكبير حجم حاوية الأيقونة */
    height: 64px !important;
    border-radius: 16px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    transition: transform 0.2s ease !important;
}

.section-nav-card .card-icon i {
    width: 30px !important; /* تكبير حجم الأيقونة */
    height: 30px !important;
}

.section-nav-card:hover .card-icon {
    transform: scale(1.1) rotate(5deg) !important;
}

.section-nav-card span {
    font-size: 0.95rem !important;
    font-weight: 700 !important;
}

@media (max-width: 768px) {
    .sections-nav-grid {
        gap: 10px !important;
    }
    .section-nav-card {
        padding: 16px 8px !important;
        gap: 8px !important;
        border-radius: 12px !important;
    }
    .section-nav-card .card-icon {
        width: 48px !important;
        height: 48px !important;
        border-radius: 12px !important;
    }
    .section-nav-card .card-icon i {
        width: 22px !important;
        height: 22px !important;
    }
    .section-nav-card span {
        font-size: 0.82rem !important;
        word-break: keep-all !important;
    }
}

/* إخفاء عمود المعرف الرقمي أو رقم الطلب غير الهام لتحسين مظهر وجاذبية الجداول */
.data-table:not(#invoiceTable):not(.keep-first-col) th:first-child,
.data-table:not(#invoiceTable):not(.keep-first-col) td:first-child,
.table:not(#invoiceTable):not(.keep-first-col) th:first-child,
.table:not(#invoiceTable):not(.keep-first-col) td:first-child {
    display: none !important;
}

/* تنسيق أزرار الفلترة الاحترافي لطلبات صفحات الهبوط (Pills Filter Group) */
.filter-pills-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: rgba(4, 8, 16, 0.55);
    padding: 6px;
    border-radius: 30px;
    border: 1px solid var(--border-color);
    align-items: center;
}

.filter-pills-group .lp-status-filter {
    background: transparent !important;
    border: none !important;
    color: var(--text-muted) !important;
    padding: 8px 18px !important;
    font-size: 0.88rem !important;
    font-weight: 700 !important;
    border-radius: 20px !important;
    min-height: 36px !important;
    width: auto !important;
    box-shadow: none !important;
    cursor: pointer !important;
    transition: var(--transition-fast) !important;
}

.filter-pills-group .lp-status-filter:hover {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.05) !important;
    transform: none !important;
}

.filter-pills-group .lp-status-filter.active {
    color: #fff !important;
    background: var(--color-primary) !important;
    box-shadow: 0 4px 12px var(--color-primary-glow) !important;
}

/* responsive styling for filter group */
@media (max-width: 768px) {
    .filter-pills-group {
        border-radius: 16px;
        width: 100%;
        justify-content: center;
        margin-top: 12px;
    }
    .filter-pills-group .lp-status-filter {
        flex: 1 1 auto;
        padding: 6px 12px !important;
        font-size: 0.8rem !important;
        text-align: center;
        min-height: 32px !important;
    }
}

/* أزرار الترقيم الفاخرة للجدول */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 15px;
    border-top: 1px solid var(--border-color);
}

.pagination-container button {
    border-radius: 6px !important;
    font-weight: 700 !important;
    min-width: 32px !important;
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 6px !important;
    font-size: 0.85rem !important;
    transition: var(--transition-fast) !important;
    border: 1px solid var(--border-color) !important;
    background: rgba(255, 255, 255, 0.03) !important;
    color: var(--text-muted) !important;
    cursor: pointer !important;
}

.pagination-container button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #fff !important;
    border-color: var(--border-highlight) !important;
}

.pagination-container button:disabled {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
}

.pagination-container button.btn-primary {
    background: var(--color-primary) !important;
    color: #fff !important;
    border-color: var(--color-primary) !important;
    box-shadow: 0 0 10px var(--color-primary-alpha) !important;
}

/* حل مشكلة تداخل قائمة البحث عن المواد والزبائن مع أزرار الفوتر واللمس المريح */
#orderMaterialsModal .modal-card,
#addOrderModal .modal-card,
#sellProductModal .modal-card {
    overflow: visible !important;
}
#orderMaterialsModal .modal-card > div:not(.modal-header):not(.modal-footer),
#addOrderModal .modal-card > form,
#sellProductModal .modal-card > div:not(.modal-header):not(.modal-footer) {
    overflow: visible !important;
    position: relative;
    z-index: 10;
}
#orderMaterialsModal .modal-footer,
#addOrderModal .modal-footer,
#sellProductModal .modal-footer {
    position: relative;
    z-index: 1;
}

/* ==========================================================================
   تنسيق نظام إدارة المهام وتوزيعها (Task Assignment Styles)
   ========================================================================== */

/* كارت المهمة المعلقة في الهوم بيج */
.pending-task-card {
    background: rgba(30, 41, 59, 0.7);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: transform var(--transition-fast), border-color var(--transition-fast);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.pending-task-card:hover {
    transform: translateY(-2px);
    border-color: var(--color-primary);
}

.pending-task-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 8px;
}

.pending-task-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
}

.pending-task-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.pending-task-body {
    font-size: 0.85rem;
    color: var(--text-main);
    line-height: 1.5;
}

.pending-task-img {
    max-width: 100%;
    max-height: 150px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid var(--border-color);
}

.pending-task-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* شارات حالات المهام */
.badge-task-pending {
    background-color: rgba(245, 158, 11, 0.15) !important;
    color: #f59e0b !important;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-task-completed {
    background-color: rgba(16, 185, 129, 0.15) !important;
    color: #10b981 !important;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-task-cancelled {
    background-color: rgba(239, 68, 68, 0.15) !important;
    color: #ef4444 !important;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* تنسيق المظهر الفاتح للمهام */
body.light-theme .pending-task-card {
    background: #ffffff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}
body.light-theme .pending-task-img {
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* تنسيق وتلوين الطلبيات المكتملة والمغلقة */
.order-closed {
    background: rgba(16, 185, 129, 0.07) !important;
    border-color: rgba(16, 185, 129, 0.25) !important;
}
body.light-theme .order-closed {
    background: rgba(16, 185, 129, 0.05) !important;
}

/* شاشات الهواتف المحمولة: خلفية البطاقة بصورة الطلب مضللة ومدمجة */
@media (max-width: 768px) {
    .data-table tr.has-bg-img, .table tr.has-bg-img {
        position: relative !important;
        background: var(--card-bg-img) center/cover no-repeat !important;
        z-index: 1 !important;
    }
    .data-table tr.has-bg-img::before, .table tr.has-bg-img::before {
        content: "" !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        background: rgba(9, 15, 29, 0.85) !important; /* Obscuring glass layer */
        border-radius: 16px !important;
        z-index: -1 !important;
    }
    body.light-theme .data-table tr.has-bg-img::before, body.light-theme .table tr.has-bg-img::before {
        background: rgba(255, 255, 255, 0.88) !important;
    }
    /* جعل كل النصوص ومحتويات البطاقة فوق التضليل */
    .data-table tr.has-bg-img *, .table tr.has-bg-img * {
        position: relative !important;
        z-index: 2 !important;
    }
}

/* ==========================================================================
   تنسيق العرض الشجري للمخزون (Inventory Tree View)
   ========================================================================== */
.tree-node {
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-card);
    backdrop-filter: blur(var(--blur-value)) saturate(180%);
    overflow: hidden;
    transition: var(--transition-normal);
}
.tree-node-header {
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
    user-select: none;
    transition: var(--transition-fast);
}
.tree-node-header:hover {
    background: rgba(255, 255, 255, 0.05);
}
body.light-theme .tree-node-header:hover {
    background: rgba(0, 0, 0, 0.03);
}
.tree-node-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    color: var(--text-main);
    font-size: 1.05rem;
}
.tree-node-icon {
    transition: transform 0.3s ease;
    width: 20px;
    height: 20px;
    color: var(--color-primary);
}
.tree-node.expanded > .tree-node-header .tree-node-icon {
    transform: rotate(-90deg); /* يتجه للأسفل في الوضع العربي لتعبر عن الفتح */
}
.tree-node-content {
    display: none;
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.08);
}
body.light-theme .tree-node-content {
    background: rgba(0, 0, 0, 0.01);
}
.tree-node.expanded > .tree-node-content {
    display: block;
}

/* التفرعات الفرعية للمخزون (Units) */
.tree-sub-node {
    margin-bottom: 12px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.01);
    overflow: hidden;
}
body.light-theme .tree-sub-node {
    border-color: rgba(0, 0, 0, 0.06);
}
.tree-sub-node-header {
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.01);
    user-select: none;
}
.tree-sub-node-header:hover {
    background: rgba(255, 255, 255, 0.03);
}
body.light-theme .tree-sub-node-header:hover {
    background: rgba(0, 0, 0, 0.02);
}
.tree-sub-node-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text-muted);
}
.tree-sub-node.expanded > .tree-sub-node-header .tree-node-icon {
    transform: rotate(-90deg);
}
.tree-sub-node-content {
    display: none;
    padding: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    background: rgba(0, 0, 0, 0.1);
}
body.light-theme .tree-sub-node-content {
    border-top-color: rgba(0, 0, 0, 0.06);
    background: rgba(0, 0, 0, 0.015);
}
.tree-sub-node.expanded > .tree-sub-node-content {
    display: block;
}

@media (max-width: 768px) {
    #section-inventory .card-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }
    #section-inventory .card-header select {
        width: 100% !important;
        max-width: none !important;
    }
}

/* إخفاء العناصر المخصصة للمدير فقط */
.admin-only.hidden-action {
    display: none !important;
}

/* تنسيق سجل أحدث العمليات على الهواتف لمنع التداخل */
@media (max-width: 768px) {
    .recent-action-item, .audit-log-item {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 6px !important;
        padding: 12px 16px !important;
    }
    .recent-action-item .audit-user, .audit-log-item .audit-user {
        min-width: auto !important;
        font-size: 0.85rem !important;
    }
    .recent-action-item .audit-desc, .audit-log-item .audit-desc {
        margin-right: 0 !important;
        margin-left: 0 !important;
        font-size: 0.8rem !important;
        color: var(--text-main) !important;
    }
    .recent-action-item .audit-time, .audit-log-item .audit-time {
        align-self: flex-end !important;
        font-size: 0.72rem !important;
        color: var(--text-muted) !important;
    }
}


