/*
 * نظام التصميم المخصص للمشروع (RTL Stylesheet)
 * الشركة المتقدمة للشحن والخدمات اللوجستية
 */

:root {
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --bg-sidebar: #0f172a;
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #94a3b8; /* تم تعديله ليكون أفتح في الوضع الداكن لزيادة التباين */
    --bg-table-hdr: rgba(15, 23, 42, 0.8);
    --bg-table-hover: rgba(255, 255, 255, 0.02);
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --sidebar-width: 260px;
    --transition-speed: 0.3s;
}

.light-theme {
    --bg-main: #f1f5f9;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --border-color: rgba(15, 23, 42, 0.08);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --bg-table-hdr: #e2e8f0;
    --bg-table-hover: rgba(15, 23, 42, 0.02);
}

/* تحسين مقروئية الفئات الافتراضية لـ Bootstrap وتوافقها مع الثيم المضيء */
.text-muted {
    color: var(--text-muted) !important;
}
.light-theme .text-white {
    color: var(--text-primary) !important;
}
.light-theme .text-white-50 {
    color: var(--text-secondary) !important;
}
.light-theme .modal-content {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
}
.light-theme .modal-header,
.light-theme .modal-footer {
    border-color: var(--border-color) !important;
}
.light-theme .btn-close {
    filter: none !important;
}
.light-theme .btn-close-white {
    filter: none !important;
}
.light-theme .menu-divider {
    border-color: var(--border-color) !important;
    opacity: 0.8 !important;
}
.light-theme .bg-slate-900 {
    background-color: var(--bg-main) !important;
}
.light-theme .bg-slate-800 {
    background-color: var(--bg-card) !important;
}
.light-theme .form-custom-control {
    background-color: rgba(15, 23, 42, 0.05) !important;
    color: var(--text-primary) !important;
}
.light-theme .form-custom-control:focus {
    background-color: #ffffff !important;
}
.light-theme .timeline-content {
    background-color: var(--bg-card) !important;
}

body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

/* تخطيط الصفحة الرئيسي */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* القائمة الجانبية */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    right: 0;
    top: 0;
    z-index: 1000;
    transition: all var(--transition-speed) ease, background-color var(--transition-speed) ease;
}

.sidebar-brand {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand img.sidebar-logo {
    width: 110px;
    height: 110px;
    object-fit: contain;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    padding: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.sidebar-menu {
    list-style: none;
    padding: 20px 10px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
    overflow-y: auto;
    flex-grow: 1;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    gap: 12px;
    transition: all 0.2s ease;
}

.sidebar-menu li a:hover,
.sidebar-menu li.active a {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--primary);
}

.sidebar-menu li a i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

/* محتوى الصفحة الرئيسي */
.main-content {
    margin-right: var(--sidebar-width);
    flex-grow: 1;
    min-width: 0;
    padding: 25px;
    transition: all var(--transition-speed) ease;
}

/* شريط الإجراءات العلوي */
.top-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 25px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 30px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: var(--bg-card);
    padding: 8px 15px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.user-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background-color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

/* بطاقات لوحة التحكم الإحصائية */
.stat-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
    height: 100%;
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

.stat-icon {
    width: 55px;
    height: 55px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
}

.stat-icon.primary { background: rgba(59, 130, 246, 0.1); color: var(--primary); }
.stat-icon.success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.stat-icon.warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.stat-icon.danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.stat-icon.info { background: rgba(6, 182, 212, 0.1); color: var(--info); }

.stat-details h3 {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 5px 0 0 0;
}

.stat-details span {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
}

/* النوافذ والبطاقات العادية */
.card-custom {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    margin-bottom: 25px;
    transition: background-color var(--transition-speed) ease, border-color var(--transition-speed) ease;
}

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

.card-custom-body {
    padding: 25px;
}

/* الجداول المتطورة */
.table-custom-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.table-custom {
    width: 100%;
    margin-bottom: 0;
    color: var(--text-primary);
    border-collapse: collapse;
}

.table-custom th {
    background-color: var(--bg-table-hdr);
    color: var(--text-secondary);
    padding: 15px 20px;
    font-weight: 700;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border-color);
    text-align: right;
}

.table-custom td {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
    vertical-align: middle;
}

.table-custom tbody tr:hover {
    background-color: var(--bg-table-hover);
}

/* شارات الحالات (Badges) */
.badge-custom {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.badge-draft { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; }
.badge-pending { background: rgba(245, 158, 11, 0.15); color: #fde047; }
.badge-pending_approval { background: rgba(245, 158, 11, 0.15); color: #fde047; }
.badge-link_sent { background: rgba(6, 182, 212, 0.15); color: #67e8f9; }
.badge-link_opened { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
.badge-sent { background: rgba(6, 182, 212, 0.15); color: #67e8f9; }
.badge-opened { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
.badge-approved { background: rgba(16, 185, 129, 0.15); color: #86efac; }
.badge-cancelled { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }

/* شارات حالات الشحن */
.badge-new { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
.badge-preparing { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
.badge-loaded { background: rgba(16, 185, 129, 0.15); color: #86efac; }
.badge-intransit { background: rgba(6, 182, 212, 0.15); color: #67e8f9; }
.badge-arrived { background: rgba(139, 92, 246, 0.15); color: #c084fc; }
.badge-delivered { background: #064e3b; color: #34d399; }
.badge-delayed { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }

/* شارات حالات الشاحنات والسائقين */
.badge-available { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-active { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.badge-maintenance { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-unavailable { background: rgba(239, 68, 68, 0.15); color: #f87171; }

/* النماذج وعناصر الإدخال */
.form-custom-control {
    background-color: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 10px;
    padding: 10px 15px;
    transition: all 0.2s ease;
}

.form-custom-control:focus {
    background-color: rgba(15, 23, 42, 0.7);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
    color: #fff;
}

.form-label-custom {
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-size: 0.88rem;
}

/* أزرار مخصصة */
.btn-custom {
    border-radius: 10px;
    padding: 10px 20px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-custom-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
}

.btn-custom-primary:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    color: white;
}

/* جدول زمني (Timeline) */
.timeline {
    position: relative;
    padding: 20px 0;
    list-style: none;
}

.timeline::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    right: 20px;
    width: 2px;
    background-color: var(--border-color);
}

.timeline-item {
    position: relative;
    margin-bottom: 30px;
    padding-right: 45px;
}

.timeline-icon {
    position: absolute;
    right: 9px;
    top: 2px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--bg-main);
    border: 2px solid var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.timeline-icon.completed {
    background-color: var(--success);
    border-color: var(--success);
    color: white;
    font-size: 0.75rem;
}

.timeline-content {
    background-color: rgba(30, 41, 59, 0.5);
    border: 1px solid var(--border-color);
    padding: 15px 20px;
    border-radius: 12px;
}

.timeline-time {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 5px;
}

.timeline-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 5px;
}

/* شريط تتبع العميل الجمالي */
.tracking-steps {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    margin: 40px 0;
}

.tracking-steps::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 4px;
    background-color: var(--border-color);
    transform: translateY(-50%);
    z-index: 1;
}

.tracking-step {
    position: relative;
    z-index: 2;
    background-color: var(--bg-card);
    padding: 10px;
    border-radius: 50%;
    border: 3px solid var(--border-color);
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.tracking-step.active {
    border-color: var(--primary);
    background-color: var(--primary);
    color: white;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
}

.tracking-step.completed {
    border-color: var(--success);
    background-color: var(--success);
    color: white;
}

.tracking-label {
    position: absolute;
    top: 55px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.tracking-step.active + .tracking-label,
.tracking-step.completed + .tracking-label {
    color: var(--text-primary);
}

/* أشرطة التمرير المخصصة */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* تصميم متجاوب للهواتف */
@media (max-width: 991px) {
    .sidebar {
        right: calc(-1 * var(--sidebar-width));
    }
    
    .sidebar.active {
        right: 0;
        box-shadow: 5px 0 30px rgba(0, 0, 0, 0.5);
    }
    
    .main-content {
        margin-right: 0;
        padding: 15px;
    }
}

/* أزرار الخطر المخصصة */
.btn-custom-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border: none;
}

.btn-custom-danger:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.35);
    color: white;
}

/* أدوات نصية */
.text-xs { font-size: 0.78rem !important; }
.text-sm { font-size: 0.875rem !important; }
.font-weight-bold { font-weight: 700 !important; }
.lh-sm { line-height: 1.4 !important; }

/* مؤثر نبضات */
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 5px rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 20px rgba(239, 68, 68, 0.8); }
}

.animate-pulse { animation: pulse-glow 2s infinite; }

