/* ========================================
   نظام إدارة شركة التوصيل — CSS مشترك
   ======================================== */

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

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

:root {
  /* Brand colors — أزرق لوجستي */
  --brand-50:  #eef4ff;
  --brand-100: #dbe6fe;
  --brand-200: #bfd2fe;
  --brand-300: #93b3fd;
  --brand-400: #6088f9;
  --brand-500: #3d63f3;
  --brand-600: #2746e0;
  --brand-700: #1f37c2;
  --brand-800: #1d3199;
  --brand-900: #1d2f7a;

  --accent-500: #ff6a1a; /* برتقالي شركات الشحن */
  --accent-600: #ed5408;
  --accent-100: #fff0e6;

  /* Neutrals */
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Status */
  --success-50:  #ecfdf5;
  --success-500: #10b981;
  --success-600: #059669;
  --warn-50:  #fffbeb;
  --warn-500: #f59e0b;
  --warn-600: #d97706;
  --danger-50: #fef2f2;
  --danger-500: #ef4444;
  --danger-600: #dc2626;
  --info-50: #eff6ff;
  --info-500: #3b82f6;

  /* Layout */
  --sidebar-w: 260px;
  --header-h: 64px;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow:    0 2px 6px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 28px rgba(15, 23, 42, 0.12), 0 4px 8px rgba(15, 23, 42, 0.06);

  font-family: 'Cairo', 'Tajawal', system-ui, sans-serif;
}

html, body {
  background: var(--gray-100);
  color: var(--gray-800);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ============ App shell ============ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  grid-template-areas: "sidebar header" "sidebar main";
  min-height: 100vh;
}

.sidebar {
  grid-area: sidebar;
  background: linear-gradient(180deg, #18256e 0%, #0f1747 100%);
  color: #cdd5f7;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 14px;
}
.brand-logo {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--accent-500), #ff8d4d);
  border-radius: 10px;
  display: grid; place-items: center;
  color: white;
  box-shadow: 0 4px 12px rgba(255,106,26,0.35);
  flex-shrink: 0;
}
.brand-name {
  color: white;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
}
.brand-sub {
  color: #8a98d4;
  font-size: 11px;
  margin-top: 2px;
}

.nav-section {
  font-size: 11px;
  color: #6b78b3;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 14px 12px 6px;
  font-weight: 700;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 9px;
  color: #cdd5f7;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: white;
}
.nav-item.active {
  background: linear-gradient(90deg, rgba(61,99,243,0.25), rgba(61,99,243,0.05));
  color: white;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  inset-inline-end: -16px;
  top: 8px; bottom: 8px;
  width: 3px;
  background: var(--accent-500);
  border-radius: 3px;
}
.nav-item .icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  opacity: 0.85;
}
.nav-item .badge {
  margin-inline-start: auto;
  background: var(--accent-500);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  display: grid; place-items: center;
  color: white; font-weight: 700; font-size: 13px;
}
.user-info { flex: 1; min-width: 0; }
.user-name { color: white; font-size: 13px; font-weight: 600; }
.user-role { color: #8a98d4; font-size: 11px; }

/* ============ Header ============ */
.header {
  grid-area: header;
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.page-title { font-size: 18px; font-weight: 700; color: var(--gray-900); }
.page-subtitle { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

.header-search {
  flex: 1;
  max-width: 420px;
  margin-inline-start: 20px;
  position: relative;
}
.header-search input {
  width: 100%;
  padding-block: 9px;
  padding-inline-start: 38px;
  padding-inline-end: 14px;
  border: 1px solid var(--gray-200);
  background: var(--gray-50);
  border-radius: 9px;
  outline: none;
  transition: all 0.15s;
}
.header-search input:focus {
  background: white;
  border-color: var(--brand-400);
  box-shadow: 0 0 0 3px rgba(61,99,243,0.1);
}
.header-search .search-icon {
  position: absolute;
  inset-inline-start: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  pointer-events: none;
}

.header-actions {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 9px;
  display: grid; place-items: center;
  color: var(--gray-600);
  position: relative;
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--gray-100); }
.icon-btn .dot {
  position: absolute;
  top: 8px; inset-inline-end: 8px;
  width: 8px; height: 8px;
  background: var(--danger-500);
  border-radius: 50%;
  border: 2px solid white;
}

/* ============ Main ============ */
.main {
  grid-area: main;
  padding: 24px 28px 40px;
  overflow-x: hidden;
}

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 13.5px;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--brand-600);
  color: white;
  box-shadow: 0 1px 2px rgba(31,55,194,0.3);
}
.btn-primary:hover { background: var(--brand-700); transform: translateY(-1px); box-shadow: 0 4px 10px rgba(31,55,194,0.35); }
.btn-accent {
  background: var(--accent-500);
  color: white;
  box-shadow: 0 1px 2px rgba(255,106,26,0.3);
}
.btn-accent:hover { background: var(--accent-600); }
.btn-ghost {
  background: transparent;
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}
.btn-ghost:hover { background: var(--gray-50); border-color: var(--gray-300); }
.btn-danger { background: var(--danger-500); color: white; }
.btn-danger:hover { background: var(--danger-600); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-lg { padding: 12px 20px; font-size: 15px; }

/* ============ Cards ============ */
.card {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 12px;
}
.card-title { font-size: 15px; font-weight: 700; color: var(--gray-900); }
.card-sub { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.card-body { padding: 22px; }
.card-actions { margin-inline-start: auto; display: flex; gap: 8px; }

/* ============ Stat cards ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  position: relative;
  overflow: hidden;
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 11px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.stat-icon.blue   { background: var(--brand-50); color: var(--brand-600); }
.stat-icon.orange { background: var(--accent-100); color: var(--accent-600); }
.stat-icon.green  { background: var(--success-50); color: var(--success-600); }
.stat-icon.amber  { background: var(--warn-50); color: var(--warn-600); }
.stat-icon.red    { background: var(--danger-50); color: var(--danger-600); }
.stat-icon.purple { background: #f3e8ff; color: #7c3aed; }
.stat-label { font-size: 12.5px; color: var(--gray-500); font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--gray-900); margin-top: 4px; line-height: 1.1; }
.stat-trend { font-size: 11.5px; margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.stat-trend.up   { color: var(--success-600); }
.stat-trend.down { color: var(--danger-600); }

/* ============ Tables ============ */
.table-wrap { overflow-x: auto; }
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.tbl thead th {
  background: var(--gray-50);
  padding: 12px 16px;
  text-align: right;
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
table.tbl tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  vertical-align: middle;
}
table.tbl tbody tr:hover { background: var(--gray-50); }
table.tbl tbody tr:last-child td { border-bottom: none; }

/* ============ Status pills ============ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.pill::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.pill.created       { background: #f1f5f9; color: var(--gray-600); }
.pill.in-warehouse  { background: var(--brand-50); color: var(--brand-700); }
.pill.in-transit    { background: #fef3c7; color: #92400e; }
.pill.received      { background: #e0f2fe; color: #075985; }
.pill.assigned      { background: #ede9fe; color: #6d28d9; }
.pill.out           { background: var(--accent-100); color: var(--accent-600); }
.pill.delivered     { background: var(--success-50); color: var(--success-600); }
.pill.failed        { background: var(--danger-50); color: var(--danger-600); }
.pill.returning     { background: #fef3c7; color: #92400e; }
.pill.returned      { background: #f3e8ff; color: #7c3aed; }

/* Tags */
.tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--gray-100);
  color: var(--gray-700);
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
}

/* ============ Forms ============ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--gray-700);
  display: flex;
  align-items: center;
  gap: 6px;
}
.field label .req { color: var(--danger-500); }
.field input,
.field select,
.field textarea {
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 9px;
  background: white;
  outline: none;
  transition: all 0.15s;
  color: var(--gray-800);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand-400);
  box-shadow: 0 0 0 3px rgba(61,99,243,0.1);
}
.field .hint { font-size: 11.5px; color: var(--gray-500); }
.field textarea { resize: vertical; min-height: 80px; }

/* ============ Modal ============ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.2s;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: white;
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s;
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--gray-900); }
.modal-close {
  margin-inline-start: auto;
  width: 32px; height: 32px;
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--gray-500);
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-800); }
.modal-body { padding: 22px 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-start;
  gap: 10px;
}

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

/* ============ Toast ============ */
.toast-host {
  position: fixed;
  top: 20px;
  inset-inline-end: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: var(--gray-900);
  color: white;
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  min-width: 240px;
  animation: slideIn 0.25s;
}
.toast.success { background: var(--success-600); }
.toast.error   { background: var(--danger-600); }
.toast .toast-icon { flex-shrink: 0; }
@keyframes slideIn { from { transform: translateX(-30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ============ Tabs ============ */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 20px;
}
.tab {
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--gray-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: all 0.15s;
}
.tab:hover { color: var(--gray-800); }
.tab.active { color: var(--brand-600); border-bottom-color: var(--brand-600); }

/* ============ Misc ============ */
.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.section-title h2 { font-size: 16px; font-weight: 700; color: var(--gray-900); }

.divider { height: 1px; background: var(--gray-200); margin: 18px 0; }

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 12.5px; }
.text-xs { font-size: 11.5px; }
.text-muted { color: var(--gray-500); }
.font-bold { font-weight: 700; }
.text-success { color: var(--success-600); }
.text-danger  { color: var(--danger-600); }
.text-warn    { color: var(--warn-600); }
.text-brand   { color: var(--brand-600); }
.text-accent  { color: var(--accent-600); }

.no-scrollbar::-webkit-scrollbar { display: none; }

/* responsive collapse for narrow screens */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============ Dropdown menu ============ */
.dd-wrap { position: relative; }
.dd-panel {
  position: absolute;
  top: calc(100% + 10px);
  inset-inline-end: 0;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(15,23,42,0.18);
  min-width: 280px;
  z-index: 90;
  display: none;
  overflow: hidden;
  animation: ddIn 0.16s ease-out;
}
.dd-panel.open { display: block; }
@keyframes ddIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.dd-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
}
.dd-head h4 { font-size: 13px; font-weight: 700; color: var(--gray-900); }
.dd-head a { font-size: 12px; color: var(--brand-600); font-weight: 600; }
.dd-list { max-height: 360px; overflow-y: auto; }
.dd-item {
  display: flex; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer; transition: background 0.12s;
  align-items: flex-start;
}
.dd-item:hover { background: var(--gray-50); }
.dd-item:last-child { border-bottom: none; }
.dd-item.unread { background: var(--brand-50); }
.dd-item.unread:hover { background: #dbeafe; }
.dd-icon {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--brand-100); color: var(--brand-600);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.dd-icon.green { background: #d1fae5; color: var(--success-600); }
.dd-icon.amber { background: #fef3c7; color: #d97706; }
.dd-icon.red   { background: #fee2e2; color: var(--danger-500); }
.dd-icon.purple { background: #ede9fe; color: #7c3aed; }
.dd-text { flex: 1; min-width: 0; }
.dd-text .t { font-size: 13px; font-weight: 600; color: var(--gray-900); margin-bottom: 2px; }
.dd-text .s { font-size: 12px; color: var(--gray-500); line-height: 1.45; }
.dd-text .ts { font-size: 11px; color: var(--gray-400); margin-top: 4px; }
.dd-foot { padding: 10px 16px; border-top: 1px solid var(--gray-100); text-align: center; }
.dd-foot a { font-size: 12.5px; color: var(--brand-600); font-weight: 600; }

/* Settings menu items */
.dd-menu-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px;
  cursor: pointer; transition: background 0.12s;
  font-size: 13.5px; color: var(--gray-800);
  border: none; background: none; width: 100%;
  font-family: inherit;
  text-align: start;
}
.dd-menu-item:hover { background: var(--gray-50); }
.dd-menu-item .mi-icon { width: 18px; color: var(--gray-500); display: grid; place-items: center; }
.dd-menu-item.danger { color: var(--danger-500); }
.dd-menu-item.danger .mi-icon { color: var(--danger-500); }
.dd-divider { height: 1px; background: var(--gray-100); margin: 4px 0; }

/* User profile button in header */
.user-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 10px 5px 5px;
  border-radius: 999px;
  border: 1px solid var(--gray-200);
  background: white;
  cursor: pointer;
  transition: background 0.12s;
}
.user-btn:hover { background: var(--gray-50); }
.user-btn .ub-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: white;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
}
.user-btn .ub-name { font-size: 13px; font-weight: 600; color: var(--gray-900); }
.user-btn .ub-role { font-size: 11px; color: var(--gray-500); margin-top: 1px; }
.user-btn .ub-chev { color: var(--gray-400); }

.dd-profile-head {
  padding: 16px;
  background: linear-gradient(135deg, var(--brand-50), white);
  display: flex; gap: 12px; align-items: center;
  border-bottom: 1px solid var(--gray-100);
}
.dd-profile-head .ph-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: white;
  display: grid; place-items: center;
  font-size: 16px; font-weight: 700;
}
.dd-profile-head .ph-name { font-size: 14px; font-weight: 700; color: var(--gray-900); }
.dd-profile-head .ph-email { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
