/**
 * IAG System — Unified Theme v2
 * "Government Digital — Refined Authority"
 * Single source of truth. Do not duplicate these rules in page-level <style> blocks.
 */

:root {
  --primary: #0f766e;
  --primary-dark: #0d6b63;
  --primary-light: #f0fdfa;
  --accent: #0369a1;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-1: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --danger: #dc2626;
  --warning: #d97706;
  --success: #059669;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.10);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

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

body {
  font-family: 'Cairo', sans-serif;
  background: var(--bg);
  color: var(--text-1);
  direction: rtl;
  padding-bottom: 80px;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

/* ── PAGE HEADER ───────────────────────────────────────────────── */
.page-header {
  background: #0f172a;
  background-image:
    radial-gradient(ellipse at top right, rgba(15,118,110,0.6) 0%, transparent 55%),
    radial-gradient(ellipse at bottom left, rgba(3,105,161,0.4) 0%, transparent 55%);
  padding: 1rem 1.25rem 4.5rem;
  position: relative;
  z-index: 10;
  padding-top: max(1rem, env(safe-area-inset-top));
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.header-btn {
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: white; cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background 0.2s;
  flex-shrink: 0;
  position: relative;
}
.header-btn:hover { background: rgba(255,255,255,0.18); }

.header-center { text-align: center; flex: 1; padding: 0 8px; }

.header-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 20px;
  padding: 3px 12px;
  font-size: 0.7rem; font-weight: 700;
  color: #99f6e4;
  margin-bottom: 5px;
}
.header-title {
  font-size: 1.1rem; font-weight: 800;
  color: #ffffff; line-height: 1.3;
}
.header-sub {
  font-size: 0.7rem; color: rgba(255,255,255,0.5);
  margin-top: 2px; font-family: sans-serif; letter-spacing: 0.3px;
}
.header-page-title {
  font-size: 1rem; font-weight: 700;
  color: #ffffff; margin-top: 8px;
}
.header-user {
  font-size: 0.75rem; color: #99f6e4; margin-top: 3px; font-weight: 600;
}

/* notification dot */
.notif-dot {
  position: absolute; top: 7px; right: 7px;
  width: 9px; height: 9px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid #0f172a;
}

/* ── FILTER CARD ───────────────────────────────────────────────── */
.filter-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 1.25rem;
  margin: -3rem 1rem 1rem;
  position: relative; z-index: 20;
}
@media (min-width: 1024px) {
  .filter-card { max-width: 1300px; margin: -3rem auto 1rem; }
}

/* ── CONTENT ───────────────────────────────────────────────────── */
.content-wrapper {
  max-width: 1300px; margin: 0 auto; padding: 0 1rem;
}

/* ── CARDS ─────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, transform 0.2s;
}
.card:hover { box-shadow: var(--shadow-md); }

/* ── KPI CARDS ─────────────────────────────────────────────────── */
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  text-align: center;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.kpi-num { font-size: 1.8rem; font-weight: 900; line-height: 1; }
.kpi-lbl { font-size: 0.7rem; font-weight: 700; color: var(--text-3); margin-top: 4px; }

/* ── BUTTONS ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border-radius: var(--radius-md);
  font-family: 'Cairo', sans-serif; font-weight: 700;
  font-size: 0.85rem; cursor: pointer; border: none;
  transition: all 0.18s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost {
  background: transparent; color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }

/* ── FORM INPUTS ───────────────────────────────────────────────── */
.f-input {
  width: 100%; height: 42px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: 'Cairo', sans-serif; font-size: 0.85rem;
  padding: 0 12px; color: var(--text-1);
  transition: border-color 0.18s, box-shadow 0.18s;
  outline: none;
}
.f-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15,118,110,0.12);
  background: white;
}
.f-label {
  display: block; font-size: 0.72rem; font-weight: 700;
  color: var(--text-2); margin-bottom: 5px;
}

/* ── BOTTOM NAV ────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 64px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; align-items: stretch;
  z-index: 90;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  background: none; border: none; cursor: pointer;
  color: var(--text-3); font-family: 'Cairo', sans-serif;
  font-size: 0.6rem; font-weight: 700;
  text-decoration: none;
  transition: color 0.18s;
}
.nav-btn svg, .nav-btn i { width: 20px; height: 20px; }
.nav-btn.active { color: var(--primary); }

/* ── SIDE MENU ─────────────────────────────────────────────────── */
.side-menu {
  position: fixed; top: 0; right: -280px; width: 280px;
  height: 100vh; background: var(--surface);
  box-shadow: -4px 0 24px rgba(0,0,0,0.12);
  z-index: 200; transition: right 0.28s cubic-bezier(0.4,0,0.2,1);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.side-menu.open { right: 0; }

.menu-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 199; display: none; backdrop-filter: blur(2px);
}
.menu-overlay.open { display: block; }

.side-menu-header {
  background: #0f172a;
  background-image: radial-gradient(ellipse at top right, rgba(15,118,110,0.5) 0%, transparent 60%);
  padding: 1.5rem 1.25rem;
  color: white;
  flex-shrink: 0;
}
.side-menu-body { flex: 1; padding: 0.5rem 0; overflow-y: auto; }

.menu-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 1.25rem; cursor: pointer;
  color: var(--text-2); font-size: 0.88rem; font-weight: 600;
  border-right: 3px solid transparent;
  transition: all 0.18s;
  text-decoration: none;
}
.menu-item:hover { background: var(--surface-2); color: var(--primary); }
.menu-item.active {
  background: var(--primary-light);
  color: var(--primary);
  border-right-color: var(--primary);
  font-weight: 700;
}
.menu-item svg, .menu-item i { width: 18px; height: 18px; flex-shrink: 0; }

.menu-footer {
  padding: 1rem 1.25rem; border-top: 1px solid var(--border); flex-shrink: 0;
}

/* ── TABS ──────────────────────────────────────────────────────── */
.tab-bar {
  display: flex; gap: 4px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 4px;
}
.tab-btn {
  flex: 1; padding: 8px 12px; border: none; cursor: pointer;
  border-radius: var(--radius-sm); font-family: 'Cairo', sans-serif;
  font-size: 0.8rem; font-weight: 700;
  background: transparent; color: var(--text-2);
  transition: all 0.18s;
}
.tab-btn.active {
  background: var(--surface); color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ── MODAL ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center;
  z-index: 300;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 92%; max-width: 520px; max-height: 85vh;
  overflow-y: auto; box-shadow: var(--shadow-lg);
  animation: slideUp 0.22s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface-2);
}
.modal-body { padding: 1.25rem; }

/* ── TOAST ─────────────────────────────────────────────────────── */
.toast-container {
  position: fixed; top: 1rem; left: 50%; transform: translateX(-50%);
  z-index: 400; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 18px; border-radius: var(--radius-md);
  font-size: 0.85rem; font-weight: 600; font-family: 'Cairo', sans-serif;
  color: white; box-shadow: var(--shadow-md);
  animation: fadeInDown 0.2s ease;
  white-space: nowrap;
}
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }

/* ── BADGES / PILLS ────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 0.68rem; font-weight: 700;
  white-space: nowrap;
}
.badge-green { background: #d1fae5; color: #065f46; }
.badge-red   { background: #fee2e2; color: #991b1b; }
.badge-yellow{ background: #fef3c7; color: #92400e; }
.badge-blue  { background: #dbeafe; color: #1d4ed8; }
.badge-purple{ background: #ede9fe; color: #6d28d9; }
.badge-grey  { background: var(--surface-2); color: var(--text-3); }

/* ── DIVIDER / EMPTY STATE ─────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 1rem 0; }

.empty-state {
  text-align: center; padding: 3rem 1rem;
  color: var(--text-3);
}
.empty-state svg, .empty-state i {
  width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.35;
  display: block; margin-left: auto; margin-right: auto;
}

/* ── LOADING ───────────────────────────────────────────────────── */
.loading {
  position: fixed; inset: 0;
  background: rgba(255,255,255,0.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
}
.loading.hidden { display: none; }
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── SCROLLBAR ─────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

/* ── UTILITY ───────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── RESPONSIVE ────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .header-title { font-size: 1rem; }
  .filter-card { margin: -2.5rem 0.75rem 1rem; }
}
@media (min-width: 1024px) {
  .bottom-nav { display: none; }
}
