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

/* الألوان والظلال بقت كلها في tokens.css — كانت متعرّفة هنا كمان
   فكانت بتلغيه (بيتحمّل قبله). الباقي هنا مقاسات مش ألوان. */
:root {
  --nav-height: 60px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--surface-2);
  color: var(--text-primary);
  direction: rtl;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ===== NAVBAR ===== */
/* ===== NAVBAR ===== */
.nav-bar {
  background: var(--primary);
  height: var(--nav-height);
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  overflow: visible;
}

.nav-logo {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  overflow-y: clip;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  padding: 0 8px;
}

.nav-links::-webkit-scrollbar { display: none; }

.nav-links a {
  color: #94a3b8;
  text-decoration: none;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.nav-links a:hover { color: #fff; background: rgba(255,255,255,0.08); }
.nav-links a.active { color: var(--primary); background: var(--accent); font-weight: 700; }
.nav-links a i { font-size: 0.9rem; }

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.user-info span {
  color: #94a3b8;
  font-size: 0.75rem;
  font-weight: 600;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  background: rgba(239,68,68,0.15);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,0.3);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.75rem;
  font-family: var(--font);
  font-weight: 600;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-logout:hover { background: rgba(239,68,68,0.3); }

/* ===== CONTAINER ===== */
.container {
  max-width: 100%;   /* قاعدة ثابتة: الصفحة تاخد كامل عرض الشاشة بدون فراغ جانبي */
  width: 100%;
  margin: 0;
  padding: 16px 14px;
}

/* ===== CARD ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-title i { color: var(--accent); }
.page-title .highlight { color: var(--accent-dark); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); color: #fff; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #16a34a; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-icon { padding: 8px; }

/* ===== FILTER BAR ===== */
.filter-bar {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

.form-select, .form-input {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: var(--font);
  font-size: 0.85rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.form-select:focus, .form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13,148,136,0.15);
}

/* ===== TABLE ===== */
.table-wrap { overflow: auto; max-height: calc(100vh - 150px); -webkit-overflow-scrolling: touch; border-radius: var(--radius-md); }

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 500px;
}

th {
  background: var(--accent);
  padding: 11px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  text-align: center;
  border-bottom: 2px solid var(--accent);
  white-space: nowrap;
  /* قاعدة عامة: رأس أي جدول ثابت عند التمرير لأسفل */
  position: sticky;
  top: 0;
  z-index: 5;
}

td {
  padding: 11px 12px;
  text-align: center;
  border-bottom: 1px solid var(--surface-3);
  font-size: 0.85rem;
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--row-hover); }

/* ===== الوضع الداكن (body.dark) ===== */
/* قيم الوضع الداكن في tokens.css */
body.dark tr:hover td { background: #16324a; }
body.dark input, body.dark select, body.dark textarea,
body.dark .table-input, body.dark .table-select { background: #0e1626; color: #e6ecf5; border-color: #26314a; }
.row-done td { opacity: 0.6; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
}

.badge-blue { background: #e0f2fe; color: #0369a1; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-yellow { background: #fef9c3; color: #a16207; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-orange { background: #ffedd5; color: #c2410c; }

/* ===== INLINE INPUTS ===== */
.table-input {
  padding: 6px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.8rem;
  width: 100%;
  min-width: 90px;
  outline: none;
  transition: border-color 0.2s;
  background: var(--surface);
}

.table-input:focus { border-color: var(--accent); }

.table-select {
  padding: 6px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.78rem;
  background: var(--surface);
  cursor: pointer;
  outline: none;
  width: 100%;
}

.table-select:focus { border-color: var(--accent); }

/* ===== NOTIF CARD ===== */
.notif-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-right: 4px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: box-shadow 0.2s;
}

.notif-card:hover { box-shadow: var(--shadow-md); }
.notif-card.done { border-right-color: var(--border); opacity: 0.65; }

/* ===== STATS ROW ===== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
}

.stat-num { font-size: 1.6rem; font-weight: 900; color: var(--accent-dark); line-height: 1; }
.stat-lbl { font-size: 0.75rem; color: var(--text-secondary); margin-top: 4px; font-weight: 500; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}

.empty-state i { font-size: 2.5rem; margin-bottom: 12px; display: block; opacity: 0.3; }

/* ===== LOADING ===== */
.loading-row td { padding: 40px; color: var(--text-muted); text-align: center; }

/* ===== CHECKBOX LABEL ===== */
.check-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  user-select: none;
}

.check-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ===== BRANCH TAG ===== */
.branch-tag {
  display: inline-block;
  background: #e0f2fe;
  color: #0369a1;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ===== DIVIDER ===== */
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 640px) {
  .container { padding: 10px 8px; }
  .card { padding: 14px; border-radius: var(--radius-md); }
  .page-header { gap: 8px; }
  .page-title { font-size: 1rem; }

  .nav-links a { padding: 6px 10px; font-size: 0.75rem; }
  .nav-links a i { font-size: 0.85rem; }

  th { padding: 9px 8px; font-size: 0.72rem; }
  td { padding: 9px 8px; font-size: 0.8rem; }

  .btn { padding: 8px 14px; font-size: 0.8rem; }
  .stat-num { font-size: 1.3rem; }

  .filter-bar { padding: 10px 12px; gap: 8px; }
}
