/* ============================================================
   جناح خفاق للخدمات اللوجستية - الهوية البصرية والتصميم العام
   ============================================================ */

:root {
  color-scheme: dark;

  /* ---- ألوان الهوية (مستخرجة من الشعار: كحلي داكن + ذهبي) ---- */
  --brand-navy-900: #0d0e13;
  --brand-navy-800: #14161d;
  --brand-navy-700: #1b1e27;
  --brand-navy-600: #242731;
  --brand-navy-500: #333743;
  --brand-gold: #d4af37;
  --brand-gold-light: #f2c260;
  --brand-gold-dark: #a97e2f;

  /* ---- أسطح وحبر (متوافقة مع سطح داكن مخصص) ---- */
  --surface-page: var(--brand-navy-900);
  --surface-card: var(--brand-navy-800);
  --surface-card-hover: var(--brand-navy-700);
  --surface-input: #1a1d26;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #8b8e9a;
  --border-hairline: rgba(255, 255, 255, 0.08);
  --border-gold: rgba(212, 175, 55, 0.35);

  /* ---- لوحة تصنيفية للرسوم البيانية (تم التحقق منها عبر أداة dataviz على السطح الداكن) ---- */
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;

  /* ---- حالة (status) - ثابتة ولا تُستخدم كتصنيف ---- */
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;

  --gridline: #2c2c2a;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface-page);
  color: var(--text-primary);
  font-family: "Segoe UI", "Tahoma", system-ui, -apple-system, sans-serif;
  font-variant-numeric: normal;
}

body { direction: rtl; }

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

/* ---------------- Layout ---------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--brand-navy-800), var(--brand-navy-900));
  border-left: 1px solid var(--border-hairline);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.sidebar-brand img { width: 44px; height: 44px; object-fit: contain; }

.sidebar-brand .name {
  font-size: 14px;
  font-weight: 700;
  color: var(--brand-gold-light);
  line-height: 1.4;
}

.sidebar-brand .name small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

.nav-group { display: flex; flex-direction: column; gap: 4px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover { background: var(--surface-card-hover); color: var(--text-primary); }

.nav-link.active {
  background: rgba(212, 175, 55, 0.12);
  color: var(--brand-gold-light);
  border: 1px solid var(--border-gold);
}

.sidebar-footer {
  margin-top: auto;
  font-size: 12px;
  color: var(--text-muted);
  padding-top: 12px;
  border-top: 1px solid var(--border-hairline);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border-hairline);
  background: var(--brand-navy-800);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; }

.platform-switch {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--surface-input);
  border: 1px solid var(--border-hairline);
  border-radius: 999px;
  padding: 4px;
}

.platform-switch form { margin: 0; }

.platform-pill {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}

.platform-pill:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }

.platform-pill.active {
  background: linear-gradient(135deg, var(--brand-gold-light), var(--brand-gold-dark));
  color: var(--brand-navy-900);
  box-shadow: 0 2px 10px rgba(212,175,55,0.35);
}

@media (max-width: 900px) {
  .platform-switch { display: none; }
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-supervisor { background: rgba(212,175,55,0.15); color: var(--brand-gold-light); border: 1px solid var(--border-gold); }
.badge-rep { background: rgba(57,135,229,0.15); color: #7fb0ee; border: 1px solid rgba(57,135,229,0.35); }

.btn-logout {
  font-size: 13px;
  color: var(--status-critical);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(208,59,59,0.35);
}
.btn-logout:hover { background: rgba(208,59,59,0.12); }

.content { padding: 24px 28px 48px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ---------------- Cards / KPI ---------------- */
.grid {
  display: grid;
  gap: 16px;
}
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 1000px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; }
}

.card {
  background: var(--surface-card);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}

.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
}
.kpi-value.gold { color: var(--brand-gold-light); }
.kpi-sub { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

.card-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 14px;
  color: var(--text-primary);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

/* ---------------- Forms ---------------- */
.form-group { margin-bottom: 14px; }
label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }

input[type=text], input[type=password], input[type=date], input[type=number],
input[type=tel], input[type=file], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-hairline);
  background: var(--surface-input);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-gold);
  box-shadow: 0 0 0 3px rgba(212,175,55,0.12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn-primary {
  background: linear-gradient(135deg, var(--brand-gold-light), var(--brand-gold-dark));
  color: #14161d;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border-hairline);
  color: var(--text-secondary);
}
.btn-outline:hover { background: var(--surface-card-hover); color: var(--text-primary); }
.btn-danger { background: rgba(208,59,59,0.15); color: #ff8a8a; border: 1px solid rgba(208,59,59,0.35); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 18px;
}
.filters-row .form-group { margin-bottom: 0; min-width: 160px; }

/* ---------------- Table ---------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: right;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-hairline);
  white-space: nowrap;
}
tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border-hairline);
  color: var(--text-secondary);
}
tbody tr:hover { background: rgba(255,255,255,0.02); }
tbody td.strong { color: var(--text-primary); font-weight: 600; }

/* ---------------- Login page ---------------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at top, rgba(212,175,55,0.08), transparent 60%),
    var(--surface-page);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface-card);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-card);
  text-align: center;
}
.login-card img { width: 84px; margin-bottom: 12px; }
.login-card h1 { font-size: 17px; margin: 0 0 4px; color: var(--brand-gold-light); }
.login-card p.sub { font-size: 12.5px; color: var(--text-muted); margin: 0 0 22px; }
.login-card form { text-align: right; }

/* ---------------- Alerts ---------------- */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-success { background: rgba(12,163,12,0.1); border-color: rgba(12,163,12,0.35); color: #6fd66f; }
.alert-error { background: rgba(208,59,59,0.1); border-color: rgba(208,59,59,0.35); color: #ff8a8a; }
.alert-info { background: rgba(57,135,229,0.1); border-color: rgba(57,135,229,0.35); color: #7fb0ee; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}
.status-pill.good { background: rgba(12,163,12,0.15); color: #6fd66f; }
.status-pill.warning { background: rgba(250,178,25,0.15); color: #f0c14b; }
.status-pill.critical { background: rgba(208,59,59,0.15); color: #ff8a8a; }
.status-pill.muted { background: rgba(255,255,255,0.06); color: var(--text-muted); }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------------- Charts ---------------- */
.chart-card .card-title { margin-bottom: 4px; }
.chart-sub { font-size: 12px; color: var(--text-muted); margin-bottom: 14px; }

.hbar-chart { display: flex; flex-direction: column; gap: 6px; }
.hbar-row {
  display: grid;
  grid-template-columns: 130px 1fr 70px;
  align-items: center;
  gap: 10px;
}
.hbar-label {
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hbar-track {
  background: var(--surface-input);
  border-radius: 6px;
  height: 14px;
  overflow: hidden;
}
.hbar-fill {
  height: 100%;
  border-radius: 6px;
  min-width: 4px;
  transition: width 0.3s;
}
.hbar-value {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 600;
  text-align: left;
}
@media (max-width: 640px) {
  .hbar-row { grid-template-columns: 90px 1fr 56px; }
}

.text-muted { color: var(--text-muted); }
.small { font-size: 12px; }
hr.hairline { border: none; border-top: 1px solid var(--border-hairline); margin: 18px 0; }
