/* ITRS - Professional Design System v2 */

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

:root {
  /* الألوان الأساسية */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-dark: #1e40af;
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;

  /* ألوان الحالة */
  --success: #16a34a;
  --success-50: #f0fdf4;
  --success-100: #dcfce7;
  --warning: #f59e0b;
  --warning-50: #fffbeb;
  --warning-100: #fef3c7;
  --danger: #dc2626;
  --danger-50: #fef2f2;
  --danger-100: #fee2e2;
  --info: #0ea5e9;
  --info-50: #f0f9ff;
  --info-100: #e0f2fe;
  --purple: #8b5cf6;
  --purple-50: #faf5ff;
  --purple-100: #f3e8ff;

  /* رمادي */
  --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;

  /* الأسطح */
  --bg: #f5f7fb;
  --surface: #ffffff;
  --border: #e5e7eb;
  --border-light: #f3f4f6;

  /* الظلال */
  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
  --shadow: 0 1px 3px 0 rgba(0,0,0,0.07), 0 1px 2px -1px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.05);

  /* القياسات */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
}

body {
  font-family: 'Cairo', 'Segoe UI', 'Tahoma', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--gray-800);
  line-height: 1.5;
  min-height: 100vh;
  font-size: 14px;
}

/* ═══════════════════════════════════════════
   الشريط العلوي - Top Navigation
   ═══════════════════════════════════════════ */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

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

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.brand-logo {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
  font-weight: 700;
}

.brand-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
}

.brand-subtitle {
  font-size: 12px;
  color: var(--gray-500);
}

.search-box {
  position: relative;
  width: 320px;
}

.search-box input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--gray-50);
  outline: none;
  transition: all 0.15s;
  font-family: inherit;
}

html[dir="rtl"] .search-box input {
  padding: 9px 38px 9px 14px;
}

.search-box input:focus {
  background: white;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-100);
}

.search-box::before {
  content: "🔍";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 12px;
  font-size: 13px;
  opacity: 0.5;
}

html[dir="rtl"] .search-box::before {
  left: auto;
  right: 12px;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 4px 4px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}

html[dir="rtl"] .user-menu {
  padding: 4px 4px 4px 12px;
}

.user-menu:hover {
  background: var(--gray-100);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--purple) 100%);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}

.avatar-sm {
  width: 26px;
  height: 26px;
  font-size: 11px;
}

.avatar-lg {
  width: 40px;
  height: 40px;
  font-size: 14px;
}

.user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
}

.user-role {
  font-size: 11px;
  color: var(--gray-500);
}

.date-label {
  font-size: 12px;
  color: var(--gray-500);
  padding: 0 8px;
}

/* ═══════════════════════════════════════════
   الأزرار - Buttons
   ═══════════════════════════════════════════ */
.btn {
  padding: 9px 16px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  line-height: 1;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover { background: #15803d; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

.btn-outline {
  background: white;
  color: var(--primary);
  border: 1px solid var(--primary-200);
}

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

.btn-icon-sm {
  padding: 7px;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 12px 24px;
  font-size: 14px;
}

.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ═══════════════════════════════════════════
   الحاوية الرئيسية
   ═══════════════════════════════════════════ */
.app-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px 24px;
}

.app-layout-wide {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px 24px;
}

.container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px 24px;
}

/* ═══════════════════════════════════════════
   البطاقات - Cards
   ═══════════════════════════════════════════ */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}

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

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 20px;
}

.card-section {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.card-section:last-child {
  border-bottom: none;
}

/* ═══════════════════════════════════════════
   بطاقات الإحصائيات - Stat Cards
   ═══════════════════════════════════════════ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  border-top: 3px solid var(--primary);
}

.stat-card.success { border-top-color: var(--success); }
.stat-card.warning { border-top-color: var(--warning); }
.stat-card.danger { border-top-color: var(--danger); }
.stat-card.info { border-top-color: var(--info); }
.stat-card.purple { border-top-color: var(--purple); }

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

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

.stat-trend {
  font-size: 12px;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ═══════════════════════════════════════════
   التبويبات - Tabs
   ═══════════════════════════════════════════ */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--gray-100);
  border-radius: var(--radius);
  width: fit-content;
  margin-bottom: 16px;
}

.tab {
  padding: 8px 18px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab.active {
  background: white;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.tab:not(.active):hover {
  color: var(--gray-800);
}

.tab-count {
  background: var(--gray-200);
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}

.tab.active .tab-count {
  background: var(--primary-100);
  color: var(--primary);
}

/* ═══════════════════════════════════════════
   الجدول - Table
   ═══════════════════════════════════════════ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  background: var(--gray-50);
  padding: 12px 16px;
  text-align: start;
  font-weight: 600;
  font-size: 12px;
  color: var(--gray-600);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.data-table tbody tr {
  transition: background 0.15s;
}

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

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.ticket-id {
  font-family: 'Courier New', monospace;
  font-weight: 700;
  color: var(--gray-700);
  font-size: 12px;
}

.ticket-title {
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 2px;
}

.ticket-subtitle {
  font-size: 11px;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ═══════════════════════════════════════════
   الشارات - Badges
   ═══════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-open { background: var(--info-50); color: var(--info); }
.badge-in_progress { background: var(--warning-50); color: #b45309; }
.badge-pending { background: var(--purple-50); color: var(--purple); }
.badge-resolved { background: var(--success-50); color: var(--success); }
.badge-closed { background: var(--gray-100); color: var(--gray-600); }

.badge-urgent { background: var(--danger-50); color: var(--danger); }
.badge-high { background: var(--warning-50); color: #b45309; }
.badge-medium { background: var(--info-50); color: var(--info); }
.badge-low { background: var(--gray-100); color: var(--gray-600); }

/* ═══════════════════════════════════════════
   معالج الخطوات - Wizard
   ═══════════════════════════════════════════ */
.wizard-steps {
  display: flex;
  align-items: center;
  margin-bottom: 28px;
  padding: 0 8px;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--gray-500);
  font-weight: 500;
}

.wizard-step-number {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--gray-200);
  color: var(--gray-600);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  transition: all 0.2s;
}

.wizard-step.active .wizard-step-number {
  background: var(--primary);
  color: white;
  box-shadow: 0 0 0 4px var(--primary-100);
}

.wizard-step.completed .wizard-step-number {
  background: var(--success);
  color: white;
}

.wizard-step.completed .wizard-step-number::before {
  content: "✓";
}

.wizard-step.completed .wizard-step-number-text {
  display: none;
}

.wizard-step.active {
  color: var(--primary);
  font-weight: 700;
}

.wizard-step.completed {
  color: var(--success);
}

.wizard-connector {
  flex: 1;
  height: 2px;
  background: var(--gray-200);
  margin: 0 12px;
  border-radius: 2px;
}

.wizard-connector.active {
  background: var(--primary);
}

/* ═══════════════════════════════════════════
   اختيار الفئة بالأيقونات
   ═══════════════════════════════════════════ */
.category-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.category-card {
  background: white;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.category-card:hover {
  border-color: var(--primary-200);
  background: var(--primary-50);
  transform: translateY(-2px);
}

.category-card.selected {
  border-color: var(--primary);
  background: var(--primary-50);
  box-shadow: 0 0 0 3px var(--primary-100);
}

.category-card.selected::after {
  content: "✓";
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  width: 22px;
  height: 22px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

.category-icon {
  font-size: 32px;
  margin-bottom: 10px;
  display: block;
}

.category-icon-3d {
  display: inline-block;
  width: 56px;
  height: 56px;
  margin-bottom: 10px;
}
.category-icon-3d svg {
  width: 100%;
  height: 100%;
}

/* ─── رفع الصور (Image Upload) ─── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  background: var(--gray-50, #f8fafc);
  transition: all 0.2s;
}
.upload-zone:hover,
.upload-zone.drag-active {
  border-color: var(--primary);
  background: var(--primary-50);
}
.upload-prompt {
  pointer-events: none;
}
.upload-icon {
  font-size: 36px;
  margin-bottom: 8px;
}
.upload-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 4px;
}
.upload-hint {
  font-size: 12px;
  color: var(--gray-500);
}

.upload-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.upload-preview:empty {
  margin-top: 0;
}
.preview-item {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--gray-100);
}
.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.preview-remove {
  position: absolute;
  top: 4px;
  inset-inline-end: 4px;
  width: 24px;
  height: 24px;
  background: rgba(15, 23, 42, 0.85);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}
.preview-remove:hover {
  background: #dc2626;
}

/* ─── معرض صور التذكرة في صفحة IT ─── */
.attachment-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.attachment-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--gray-100);
}
.attachment-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.attachment-item:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Lightbox */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  cursor: pointer;
  padding: 40px;
}
.lightbox-overlay img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
}
.lightbox-close {
  position: absolute;
  top: 20px;
  inset-inline-end: 20px;
  width: 44px;
  height: 44px;
  background: rgba(255,255,255,0.15);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 24px;
  font-weight: 700;
}

.category-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
}

/* ═══════════════════════════════════════════
   اختيار الأولوية
   ═══════════════════════════════════════════ */
.priority-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.priority-card {
  background: white;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.priority-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.priority-card.selected {
  background: var(--primary-50);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-100);
}

.priority-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  margin: 0 auto 8px;
}

.priority-dot.low { background: var(--success); }
.priority-dot.medium { background: var(--warning); }
.priority-dot.high { background: #f97316; }
.priority-dot.urgent { background: var(--danger); }

.priority-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 4px;
}

.priority-desc {
  font-size: 11px;
  color: var(--gray-500);
}

/* ═══════════════════════════════════════════
   النماذج - Forms
   ═══════════════════════════════════════════ */
.form-section {
  margin-bottom: 24px;
}

.form-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-section-title::before {
  content: "";
  width: 4px;
  height: 16px;
  background: var(--primary);
  border-radius: 2px;
}

.form-group {
  margin-bottom: 14px;
}

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

.form-label .required {
  color: var(--danger);
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: white;
  outline: none;
  transition: all 0.15s;
  font-family: inherit;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-100);
}

textarea.form-control {
  min-height: 100px;
  resize: vertical;
  line-height: 1.6;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-help {
  font-size: 11px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* ═══════════════════════════════════════════
   قائمة التذاكر الجانبية
   ═══════════════════════════════════════════ */
.mini-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.mini-stat {
  background: var(--gray-50);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}

.mini-stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1;
}

.mini-stat-label {
  font-size: 11px;
  color: var(--gray-500);
  margin-top: 4px;
}

.mini-tickets {
  max-height: 600px;
  overflow-y: auto;
}

.mini-ticket {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  border-inline-start: 3px solid transparent;
  cursor: pointer;
  transition: background 0.15s;
}

.mini-ticket:hover {
  background: var(--gray-50);
}

.mini-ticket.priority-urgent { border-inline-start-color: var(--danger); }
.mini-ticket.priority-high { border-inline-start-color: var(--warning); }
.mini-ticket.priority-medium { border-inline-start-color: var(--info); }
.mini-ticket.priority-low { border-inline-start-color: var(--success); }

.mini-ticket-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.mini-ticket-title {
  font-weight: 600;
  color: var(--gray-900);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mini-ticket-meta {
  font-size: 11px;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

/* ═══════════════════════════════════════════
   اللوحة الجانبية - Sidebar Widgets
   ═══════════════════════════════════════════ */
.sidebar-widget {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
}

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

.sidebar-widget-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-800);
}

.sidebar-widget-link {
  font-size: 12px;
  color: var(--primary);
  cursor: pointer;
  text-decoration: none;
}

.sidebar-widget-link:hover {
  text-decoration: underline;
}

.sidebar-widget-body {
  padding: 12px 16px;
}

.branch-bar {
  margin-bottom: 12px;
}

.branch-bar:last-child { margin-bottom: 0; }

.branch-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 5px;
}

.branch-bar-name {
  color: var(--gray-700);
  font-weight: 500;
}

.branch-bar-value {
  color: var(--gray-900);
  font-weight: 700;
}

.branch-bar-track {
  height: 6px;
  background: var(--gray-100);
  border-radius: 4px;
  overflow: hidden;
}

.branch-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border-radius: 4px;
  transition: width 0.6s;
}

.team-member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}

.team-member:last-child { border-bottom: none; }

.avatar-with-status {
  position: relative;
}

.avatar-status {
  position: absolute;
  bottom: -1px;
  inset-inline-end: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid white;
}

.avatar-status.online { background: var(--success); }
.avatar-status.busy { background: var(--warning); }
.avatar-status.offline { background: var(--gray-400); }

.team-member-info {
  flex: 1;
  line-height: 1.3;
}

.team-member-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
}

.team-member-status {
  font-size: 11px;
  color: var(--gray-500);
}

/* ═══════════════════════════════════════════
   صفحة تسجيل الدخول
   ═══════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #3b82f6 100%);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: "";
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
  top: -200px;
  inset-inline-end: -200px;
  border-radius: 50%;
}

.login-page::after {
  content: "";
  position: absolute;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
  bottom: -150px;
  inset-inline-start: -150px;
  border-radius: 50%;
}

.login-container {
  background: white;
  padding: 40px;
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.3);
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
}

.login-logo-box {
  width: 70px;
  height: 70px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  font-size: 34px;
  box-shadow: 0 10px 25px rgba(37, 99, 235, 0.3);
}

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

.login-header h1 {
  font-size: 24px;
  color: var(--gray-900);
  margin-bottom: 6px;
  font-weight: 800;
}

.login-header p {
  color: var(--gray-500);
  font-size: 13px;
}

.role-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 24px;
  padding: 4px;
  background: var(--gray-100);
  border-radius: var(--radius);
}

.role-tab {
  padding: 11px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  transition: all 0.2s;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.role-tab.active {
  background: white;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ═══════════════════════════════════════════
   الرسائل والإشعارات
   ═══════════════════════════════════════════ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-error {
  background: var(--danger-50);
  color: var(--danger);
  border: 1px solid var(--danger-100);
}

.alert-success {
  background: var(--success-50);
  color: #166534;
  border: 1px solid var(--success-100);
}

.alert-info {
  background: var(--info-50);
  color: #0369a1;
  border: 1px solid var(--info-100);
}

.alert-warning {
  background: var(--warning-50);
  color: #92400e;
  border: 1px solid var(--warning-100);
}

/* ═══════════════════════════════════════════
   المودال - Modal
   ═══════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.2s;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: white;
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 850px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 30px 80px rgba(0,0,0,0.3);
  animation: slideUp 0.25s;
}

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

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: white;
  z-index: 10;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--gray-100);
  color: var(--gray-600);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.modal-close:hover {
  background: var(--gray-200);
  color: var(--gray-900);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ═══════════════════════════════════════════
   التعليقات
   ═══════════════════════════════════════════ */
.comment-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.comment {
  background: var(--gray-50);
  padding: 14px;
  border-radius: var(--radius-md);
  border-inline-start: 3px solid var(--primary);
}

.comment.internal {
  background: var(--warning-50);
  border-color: var(--warning);
}

.comment-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  margin-bottom: 6px;
}

.comment-author {
  font-weight: 700;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: 6px;
}

.comment-date {
  color: var(--gray-500);
}

.comment-body {
  font-size: 13px;
  color: var(--gray-700);
  white-space: pre-wrap;
  line-height: 1.6;
}

/* ═══════════════════════════════════════════
   السجل التاريخي
   ═══════════════════════════════════════════ */
.history-list {
  list-style: none;
  border-inline-start: 2px solid var(--border);
  padding-inline-start: 18px;
}

.history-item {
  padding: 10px 0;
  font-size: 12px;
  color: var(--gray-600);
  position: relative;
}

.history-item::before {
  content: "";
  position: absolute;
  width: 9px;
  height: 9px;
  background: var(--primary);
  border-radius: 50%;
  inset-inline-start: -23px;
  top: 14px;
  border: 2px solid white;
  box-shadow: 0 0 0 2px var(--primary-100);
}

/* ═══════════════════════════════════════════
   حالة فارغة
   ═══════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}

.empty-state-icon {
  font-size: 56px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state-text {
  font-size: 14px;
  color: var(--gray-500);
}

/* ═══════════════════════════════════════════
   التحميل
   ═══════════════════════════════════════════ */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 40px auto;
}

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

/* ═══════════════════════════════════════════
   Toast
   ═══════════════════════════════════════════ */
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

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

/* ═══════════════════════════════════════════
   Toggle button
   ═══════════════════════════════════════════ */
.lang-toggle {
  padding: 7px 14px;
  border: 1px solid var(--border);
  background: white;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  transition: all 0.15s;
  font-family: inherit;
}

.lang-toggle:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

/* ═══════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════ */
@media (max-width: 1100px) {
  .app-layout,
  .app-layout-wide {
    grid-template-columns: 1fr;
  }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .container,
  .app-layout,
  .app-layout-wide {
    padding: 12px;
  }
  .topbar { padding: 10px 14px; flex-wrap: wrap; gap: 10px; }
  .search-box { width: 100%; order: 3; }
  .stats-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 24px; }
  .category-grid { grid-template-columns: repeat(2, 1fr); }
  .priority-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .wizard-step span:not(.wizard-step-number) { display: none; }
  .brand-info { display: none; }
}

/* RTL fine-tune */
html[dir="rtl"] {
  font-family: 'Cairo', 'Tahoma', system-ui, sans-serif;
}

/* ═══════════════════════════════════════════
   شريط التنقل الجانبي للإدارة
   ═══════════════════════════════════════════ */
.admin-sidebar {
  position: fixed;
  top: 0;
  inset-inline-end: 0;
  width: 64px;
  height: 100vh;
  background: white;
  border-inline-start: 1px solid var(--border);
  padding: 14px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 60;
  box-shadow: var(--shadow-sm);
}

.admin-sidebar-logo {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  width: 100%;
  display: flex;
  justify-content: center;
}

.admin-sidebar-logo .brand-logo {
  width: 40px;
  height: 40px;
  font-size: 18px;
}

.admin-nav-item {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  text-decoration: none;
}

.admin-nav-item:hover {
  background: var(--primary-50);
  color: var(--primary);
}

.admin-nav-item.active {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-md);
}

.admin-nav-item.active .admin-nav-icon {
  filter: brightness(2);
}

.admin-nav-tooltip {
  position: absolute;
  inset-inline-end: 56px;
  background: var(--gray-900);
  color: white;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.admin-nav-item:hover .admin-nav-tooltip {
  opacity: 1;
}

.has-admin-sidebar .topbar {
  padding-inline-end: 84px;
}

.has-admin-sidebar .container,
.has-admin-sidebar .app-layout,
.has-admin-sidebar .app-layout-wide {
  padding-inline-end: 84px;
}

/* ═══════════════════════════════════════════
   صفحة الفروع
   ═══════════════════════════════════════════ */
.branches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.branch-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  transition: all 0.2s;
}

.branch-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-200);
}

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

.branch-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
}

.branch-card-code {
  font-size: 12px;
  color: var(--gray-500);
  font-family: monospace;
  margin-top: 4px;
}

.branch-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--success);
  font-weight: 600;
}

.branch-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

.branch-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.branch-stat {
  text-align: center;
  padding: 8px 4px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
}

.branch-stat-value {
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}

.branch-stat-value.urgent { color: var(--danger); }
.branch-stat-value.in_progress { color: var(--warning); }
.branch-stat-value.resolved { color: var(--success); }
.branch-stat-value.open { color: var(--primary); }

.branch-stat-label {
  font-size: 10px;
  color: var(--gray-500);
  font-weight: 600;
}

.branch-card-info {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
  color: var(--gray-500);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.branch-card-actions {
  position: absolute;
  top: 16px;
  inset-inline-start: 16px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}

.branch-card:hover .branch-card-actions {
  opacity: 1;
}

/* ═══════════════════════════════════════════
   جدول المستخدمين
   ═══════════════════════════════════════════ */
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.role-admin { background: #ede9fe; color: #6d28d9; }
.role-it { background: var(--info-100); color: var(--info); }
.role-restaurant { background: var(--warning-100); color: #b45309; }

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
}

.status-indicator::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status-active { color: var(--success); }
.status-inactive { color: var(--gray-400); }

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--gray-300);
  border-radius: 22px;
  transition: 0.3s;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}

html[dir="rtl"] .toggle-slider:before {
  left: auto;
  right: 3px;
}

.toggle input:checked + .toggle-slider {
  background: var(--success);
}

.toggle input:checked + .toggle-slider:before {
  transform: translateX(16px);
}

html[dir="rtl"] .toggle input:checked + .toggle-slider:before {
  transform: translateX(-16px);
}

/* ═══════════════════════════════════════════
   صفحة التقارير
   ═══════════════════════════════════════════ */
.reports-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.report-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.report-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--gray-50);
}

.report-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-800);
}

.report-card-body {
  padding: 20px;
  min-height: 280px;
  position: relative;
}

.chart-canvas-wrap {
  position: relative;
  height: 280px;
}

.insight-card {
  background: linear-gradient(135deg, var(--primary-50), white);
  border: 1px solid var(--primary-100);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.insight-icon {
  width: 46px;
  height: 46px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.insight-content {
  flex: 1;
}

.insight-title {
  font-size: 12px;
  color: var(--gray-600);
  font-weight: 600;
}

.insight-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--gray-900);
}

.insight-description {
  font-size: 11px;
  color: var(--gray-500);
  margin-top: 2px;
}

.insights-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

@media (max-width: 1100px) {
  .reports-grid { grid-template-columns: 1fr; }
  .insights-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .admin-sidebar { width: 52px; }
  .has-admin-sidebar .topbar,
  .has-admin-sidebar .container,
  .has-admin-sidebar .app-layout,
  .has-admin-sidebar .app-layout-wide { padding-inline-end: 64px; }
  .insights-grid { grid-template-columns: 1fr 1fr; }
  .branches-grid { grid-template-columns: 1fr; }
}


/* ════════════════════════════════════════════
   Trial Banner (شريط تنبيه التجربة)
   ════════════════════════════════════════════ */
.trial-banner {
  background: linear-gradient(90deg, #2563eb, #6d28d9);
  color: white;
  padding: 10px 24px;
  position: sticky;
  top: 0;
  z-index: 999;
}
.trial-banner-warning {
  background: linear-gradient(90deg, #dc2626, #ea580c);
}
.trial-banner-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}
.trial-banner-icon { font-size: 20px; }
.trial-banner-text { font-size: 14.5px; font-weight: 500; }
.trial-banner-btn {
  background: white;
  color: var(--primary-dark);
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.15s;
}
.trial-banner-btn:hover { transform: translateY(-1px); }
.trial-banner-warning .trial-banner-btn { color: #b91c1c; }
.has-trial-banner .admin-sidebar { top: 44px; }
