/**
 * نظام إدارة الورشة - التصميم
 * شركة الدقل لنقل النفايات
 */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #1e3a5f;
    --primary-light: #2d5a8a;
    --primary-dark: #0f2440;
    --secondary: #ff6b35;
    --accent: #00b4d8;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0284c7;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --sidebar-width: 280px;
    --sidebar-collapsed: 80px;
    --header-height: 70px;
    --transition: all 0.3s ease;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.15);
    --radius: 10px;
    --radius-lg: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Cairo', sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    min-height: 100vh;
    direction: rtl;
}

/* ========================================
   Sidebar
   ======================================== */
.sidebar {
    position: fixed;
    right: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
    z-index: 1000;
    transition: var(--transition);
    box-shadow: -5px 0 30px rgba(0,0,0,0.2);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .menu-label,
.sidebar.collapsed .menu-item span,
.sidebar.collapsed .menu-badge,
.sidebar.collapsed .sidebar-footer {
    display: none;
}

.sidebar.collapsed .menu-item {
    justify-content: center;
    padding: 14px;
}

.sidebar.collapsed .menu-item i {
    margin: 0;
    font-size: 20px;
}

.sidebar-toggle {
    position: absolute;
    left: -15px;
    top: 30px;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: var(--secondary);
    color: white;
    cursor: pointer;
    z-index: 10;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.sidebar-toggle:hover {
    transform: scale(1.1);
}

.sidebar.collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

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

.sidebar-logo {
    width: 50px;
    height: 50px;
    background: var(--secondary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.sidebar-brand-text h4 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

.sidebar-brand-text small {
    font-size: 12px;
    opacity: 0.7;
}

.sidebar-menu {
    padding: 15px 0;
    height: calc(100vh - 160px);
    overflow-y: auto;
}

.menu-section {
    margin-bottom: 15px;
}

.menu-label {
    padding: 10px 20px;
    font-size: 11px;
    font-weight: 600;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    transition: var(--transition);
    gap: 12px;
    position: relative;
    font-size: 14px;
}

.menu-item:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.menu-item.active {
    background: rgba(255,255,255,0.15);
    color: white;
}

.menu-item.active::before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 70%;
    background: var(--secondary);
    border-radius: 0 4px 4px 0;
}

.menu-item i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.menu-badge {
    margin-right: auto;
    background: var(--secondary);
    color: white;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.sidebar-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.5);
    font-size: 12px;
    text-align: center;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

/* ========================================
   Main Content
   ======================================== */
.main-content {
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    transition: var(--transition);
}

.sidebar.collapsed ~ .main-content {
    margin-right: var(--sidebar-collapsed);
}

.page-content {
    padding: 25px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.page-header h4 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-800);
    margin: 0;
}

/* ========================================
   Cards
   ======================================== */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: none;
    overflow: hidden;
}

.card-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--gray-200);
    background: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-800);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title i {
    color: var(--primary);
}

.card-body {
    padding: 22px;
}

/* ========================================
   Stats Cards
   ======================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-card .stat-icon {
    width: 55px;
    height: 55px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 15px;
    color: white;
}

.stat-card.primary .stat-icon { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.stat-card.success .stat-icon { background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%); }
.stat-card.warning .stat-icon { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
.stat-card.danger .stat-icon { background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%); }
.stat-card.info .stat-icon { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }

.stat-value {
    font-size: 32px;
    font-weight: 800;
    color: var(--gray-800);
    line-height: 1;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 10px;
}

.stat-change {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--danger); }

/* ========================================
   Tables
   ======================================== */
.table {
    margin-bottom: 0;
}

.table th {
    background: var(--gray-50);
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--gray-200);
    padding: 14px 16px;
    white-space: nowrap;
}

.table td {
    padding: 14px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--gray-100);
}

.table tbody tr:hover {
    background: var(--gray-50);
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-light);
    border-color: var(--primary-light);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 14px;
}

.btn-icon.edit { background: rgba(59, 130, 246, 0.1); color: #3b82f6; border: none; }
.btn-icon.delete { background: rgba(239, 68, 68, 0.1); color: #ef4444; border: none; }
.btn-icon.view { background: rgba(16, 185, 129, 0.1); color: #10b981; border: none; }

.btn-icon:hover { transform: scale(1.1); }

/* ========================================
   Forms
   ======================================== */
.form-control, .form-select {
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.form-label {
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
    font-size: 13px;
}

/* ========================================
   Badges
   ======================================== */
.badge {
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 20px;
}

/* ========================================
   Alerts Panel
   ======================================== */
.alerts-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.alert-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 15px 0;
    border-bottom: 1px solid var(--gray-100);
}

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

.alert-icon {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.alert-icon.critical { background: rgba(220, 38, 38, 0.1); color: var(--danger); }
.alert-icon.warning { background: rgba(217, 119, 6, 0.1); color: var(--warning); }
.alert-icon.info { background: rgba(2, 132, 199, 0.1); color: var(--info); }

.alert-content { flex: 1; }
.alert-title { font-size: 14px; font-weight: 600; color: var(--gray-800); margin-bottom: 3px; }
.alert-desc { font-size: 12px; color: var(--gray-500); margin-bottom: 5px; }
.alert-time { font-size: 11px; color: var(--gray-400); }

/* ========================================
   Loading Overlay
   ======================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.loading-overlay.show {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 1200px) {
    .sidebar {
        transform: translateX(100%);
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .sidebar.mobile-open ~ .sidebar-overlay {
        display: block;
    }
    
    .main-content {
        margin-right: 0;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .page-content {
        padding: 15px;
    }
    
    .table-responsive {
        font-size: 13px;
    }
}

/* ========================================
   Scrollbar
   ======================================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-400); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }
