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

:root {
  --brand-green: #829818;
  --brand-green-dark: #6b7f14;
  --brand-blue: #1480c3;
  --brand-blue-dark: #106da3;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --info-bg: #eff6ff;
  --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;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 16px rgba(20, 128, 195, 0.08);
  --sidebar-w: 280px;
}

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

html, body { max-width: 100vw; overflow-x: hidden; }

body {
  font-family: 'Tajawal', 'Inter', system-ui, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  font-size: 15px;
}

a { color: var(--brand-blue); text-decoration: none; }
a:hover { color: var(--brand-blue-dark); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ===== AUTH ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  background: var(--gray-50);
}

.auth-brand {
  display: none;
  width: 58%;
  background: linear-gradient(to bottom right, var(--brand-green), var(--brand-blue));
  color: white;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  position: relative;
  overflow: hidden;
}

.auth-brand::before,
.auth-brand::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
}

.auth-brand::before { width: 320px; height: 320px; top: -80px; inset-inline-end: -60px; }
.auth-brand::after { width: 400px; height: 400px; bottom: -120px; inset-inline-start: -80px; }

.auth-brand-inner { position: relative; z-index: 1; max-width: 420px; }

.auth-brand h1 { font-size: 2.5rem; font-weight: 700; margin-bottom: 12px; }
.auth-brand p { color: rgba(255,255,255,0.8); font-size: 1.05rem; }

.auth-form-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: white;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow-md);
}

.auth-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  background: white;
  border-radius: 18px;
  border: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.auth-logo img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }

@media (min-width: 1024px) {
  .auth-brand { display: flex; }
}

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

.sidebar {
  width: var(--sidebar-w);
  background: white;
  border-inline-end: 1px solid var(--gray-100);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  z-index: 40;
  transition: transform 0.25s;
}

.sidebar-brand {
  padding: 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-brand img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid var(--gray-100);
  padding: 4px;
  background: white;
}

.sidebar-brand h1 { font-size: 15px; font-weight: 700; color: var(--gray-800); }
.sidebar-brand p { font-size: 11px; color: var(--gray-400); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px; }

.nav-section {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-400);
  padding: 12px 12px 6px;
  letter-spacing: 0.5px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--gray-600);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background 0.15s, color 0.15s;
}

.sidebar-item:hover { background: #e8f4fc; color: var(--brand-blue); }
.sidebar-item.active {
  background: var(--brand-blue);
  color: white;
  box-shadow: 0 4px 14px rgba(20, 128, 195, 0.3);
}

.sidebar-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--gray-100);
  font-size: 12px;
  color: var(--gray-400);
}

.main-wrap {
  flex: 1;
  margin-inline-start: var(--sidebar-w);
  min-width: 0;
}

.topbar {
  background: white;
  border-bottom: 1px solid var(--gray-100);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar h2 { font-size: 18px; font-weight: 700; color: var(--gray-800); }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.menu-toggle {
  display: none;
  border: none;
  background: var(--gray-100);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  cursor: pointer;
}

.page-content { padding: 24px; }

.demo-strip {
  margin: 0 24px 0;
  padding: 10px 16px;
  background: var(--info-bg);
  border: 1px solid rgba(20, 128, 195, 0.2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--gray-600);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.demo-badge {
  background: linear-gradient(to bottom right, var(--brand-green), var(--brand-blue));
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}

@media (max-width: 1024px) {
  .sidebar { transform: translateX(100%); }
  html[dir='rtl'] .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-inline-start: 0; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
}

/* ===== COMPONENTS ===== */
.card {
  background: white;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.card + .card { margin-top: 16px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.stat-icon.blue { background: var(--info-bg); }
.stat-icon.green { background: #f4f7e8; }
.stat-icon.gold { background: var(--warning-bg); }
.stat-icon.red { background: var(--danger-bg); }

.stat-value { font-size: 24px; font-weight: 700; color: var(--brand-blue-dark); }
.stat-label { font-size: 13px; color: var(--gray-500); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}

.btn-primary {
  background: var(--brand-blue);
  color: white;
  box-shadow: 0 4px 14px rgba(20, 128, 195, 0.25);
}

.btn-primary:hover { background: var(--brand-blue-dark); }

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

.btn-success:hover { background: var(--brand-green-dark); }

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
}

.btn-secondary:hover { background: var(--gray-200); }

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.btn-danger:hover { background: #fee2e2; }

.btn-sm { padding: 6px 12px; font-size: 13px; }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-sm);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table thead { background: var(--gray-50); color: var(--gray-600); }

.data-table th {
  padding: 12px 16px;
  text-align: right;
  font-weight: 600;
  font-size: 13px;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

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

.data-table tbody tr:hover { background: rgba(20, 128, 195, 0.03); }
.data-table tbody tr:last-child td { border-bottom: none; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-primary { background: var(--info-bg); color: var(--brand-blue-dark); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

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

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

.input,
.select,
.textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(20, 128, 195, 0.15);
}

.textarea { min-height: 100px; resize: vertical; }

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-100);
}

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

.page-header h3 { font-size: 16px; font-weight: 700; color: var(--gray-800); }

.search-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.search-bar .input { max-width: 320px; }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--gray-500);
}

.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.detail-list { list-style: none; }
.detail-list li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 14px;
}
.detail-list li span:first-child { color: var(--gray-500); }
.detail-list li span:last-child { font-weight: 600; color: var(--gray-800); }

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tab {
  padding: 10px 16px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab.active { color: var(--brand-blue); border-bottom-color: var(--brand-blue); }

.toast {
  position: fixed;
  bottom: 24px;
  inset-inline-start: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--gray-800);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  z-index: 100;
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
}

.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open { display: flex; }

.modal {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-md);
}

.modal h3 { margin-bottom: 8px; font-size: 18px; }
.modal p { color: var(--gray-600); margin-bottom: 20px; font-size: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

.timeline { list-style: none; }
.timeline li {
  padding: 12px 0 12px 0;
  padding-inline-start: 20px;
  border-inline-start: 2px solid var(--gray-200);
  margin-inline-start: 8px;
  position: relative;
}
.timeline li::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand-blue);
  position: absolute;
  inset-inline-start: -6px;
  top: 16px;
}

.progress-bar {
  height: 8px;
  background: var(--gray-100);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(to right, var(--brand-green), var(--brand-blue));
  border-radius: 999px;
}
