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

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

:root {
  --primary: #1e3a5f;
  --primary-light: #2a4f82;
  --primary-fg: #fff;
  --bg: #f4f6fa;
  --surface: #fff;
  --border: #dde3ec;
  --muted: #6b7280;
  --muted-bg: #f0f3f8;
  --green: #16a34a;
  --green-bg: #f0fdf4;
  --green-border: #bbf7d0;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --red-border: #fecaca;
  --yellow: #d97706;
  --yellow-bg: #fffbeb;
  --yellow-border: #fed7aa;
  --blue: #2563eb;
  --blue-bg: #eff6ff;
  --blue-border: #bfdbfe;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --sidebar-w: 240px;
}

body {
  font-family: 'Vazirmatn', sans-serif;
  background: var(--bg);
  color: #1a202c;
  direction: rtl;
  min-height: 100vh;
  display: flex;
}

/* ── Sidebar ─────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--primary);
  color: var(--primary-fg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar-brand h1 {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  color: #fff;
}
.sidebar-brand p {
  font-size: 11px;
  color: rgba(255,255,255,.55);
  margin-top: 4px;
}
.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
}
.nav-link svg { flex-shrink: 0; }
.nav-link:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-link.active { background: rgba(255,255,255,.18); color: #fff; }
.nav-form { margin: 0; }
.nav-button {
  width: 100%;
  border: 0;
  background: transparent;
  font-family: inherit;
  text-align: right;
}

/* ── Main content ─────────────────────────────── */
.main {
  flex: 1;
  padding: 32px 36px;
  overflow-x: hidden;
  min-width: 0;
}

/* ── Page header ─────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
}

/* ── Cards ───────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-body { padding: 20px; }

/* ── Stat grid ───────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon.blue { background: var(--blue-bg); color: var(--blue); }
.stat-icon.green { background: var(--green-bg); color: var(--green); }
.stat-icon.yellow { background: var(--yellow-bg); color: var(--yellow); }
.stat-icon.red { background: var(--red-bg); color: var(--red); }
.stat-label { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--primary); }

/* ── Tables ──────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead { background: var(--muted-bg); }
th {
  padding: 11px 16px;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--muted-bg); }

/* ── Badges ──────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge-green { background: var(--green-bg); color: var(--green); border-color: var(--green-border); }
.badge-red { background: var(--red-bg); color: var(--red); border-color: var(--red-border); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); border-color: var(--yellow-border); }
.badge-gray { background: var(--muted-bg); color: var(--muted); border-color: var(--border); }
.badge-blue { background: var(--blue-bg); color: var(--blue); border-color: var(--blue-border); }

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: opacity .15s, background .15s;
}
.btn:hover { opacity: .9; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); opacity: 1; }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--border); }
.btn-outline:hover { background: var(--muted-bg); opacity: 1; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; opacity: 1; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-green { background: var(--green); color: #fff; }

/* ── Forms ───────────────────────────────────── */
.form-section {
  display: none;
  animation: fadeIn .25s ease;
}
.form-section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.form-group { margin-bottom: 18px; }
label.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}
input[type="text"], input[type="date"], input[type="time"], input[type="number"], input[type="password"],
textarea, select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  background: var(--surface);
  color: inherit;
  direction: rtl;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30,58,95,.12);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Login ───────────────────────────────────── */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-shell {
  width: 100%;
  max-width: 400px;
}
.login-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.login-brand {
  text-align: center;
  margin-bottom: 24px;
}
.login-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.login-brand h1 {
  font-size: 22px;
  color: var(--primary);
  margin-bottom: 4px;
}
.login-brand p {
  color: var(--muted);
  font-size: 13px;
}
.login-form { margin-top: 18px; }
.login-submit { width: 100%; }

/* ── Radio groups ─────────────────────────────── */
.radio-group { display: flex; gap: 20px; flex-wrap: wrap; }
.radio-opt {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-size: 14px;
}
.radio-opt input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

.residency-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.residency-opt {
  display: flex; align-items: center; gap: 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  font-size: 13px;
}
.residency-opt:hover { background: var(--muted-bg); }
.residency-opt.selected { border-color: var(--primary); background: #eff3fb; }
.residency-opt.selected-danger { border-color: var(--red); background: var(--red-bg); }
.residency-opt input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ── Checklist ────────────────────────────────── */
.check-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.check-item:last-child { border-bottom: none; }
.check-radios { display: flex; gap: 18px; flex-shrink: 0; }
.check-radios label { display: flex; align-items: center; gap: 5px; cursor: pointer; font-weight: 600; }
.check-radios input { accent-color: var(--primary); }
.check-present { accent-color: var(--green) !important; }
.check-incomplete { accent-color: var(--red) !important; }

.doc-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.doc-table th { padding: 10px 12px; font-size: 12px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); background: var(--muted-bg); text-align: right; }
.doc-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: right; vertical-align: middle; }
.doc-table tr:last-child td { border-bottom: none; }
.doc-table td:nth-child(3), .doc-table td:nth-child(4) { text-align: center; width: 70px; }

/* ── Sub-sections ─────────────────────────────── */
.sub-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--muted-bg);
  margin-top: 12px;
  display: none;
}
.sub-section.visible { display: block; }
.sub-section-title { font-weight: 700; font-size: 13px; margin-bottom: 12px; color: var(--primary); }

/* ── Alerts ──────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid;
  margin: 12px 0;
  font-size: 13px;
  line-height: 1.6;
}
.alert-danger { background: var(--red-bg); border-color: var(--red-border); color: #991b1b; }
.alert-warning { background: var(--yellow-bg); border-color: var(--yellow-border); color: #92400e; }
.alert-success { background: var(--green-bg); border-color: var(--green-border); color: #166534; }
.alert-info { background: var(--blue-bg); border-color: var(--blue-border); color: #1e40af; }
.alert-icon { flex-shrink: 0; margin-top: 1px; }
.alert-title { font-weight: 700; margin-bottom: 2px; }

/* ── Result options ───────────────────────────── */
.result-opts { display: flex; flex-direction: column; gap: 10px; }
.result-opt {
  display: flex; align-items: center; gap: 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  font-size: 14px;
  transition: border-color .15s, background .15s;
}
.result-opt:hover { background: var(--muted-bg); }
.result-opt.sel-green { border-color: var(--green); background: var(--green-bg); color: #166534; }
.result-opt.sel-yellow { border-color: var(--yellow); background: var(--yellow-bg); color: #92400e; }
.result-opt.sel-red { border-color: var(--red); background: var(--red-bg); color: #991b1b; }

/* ── Step progress ─────────────────────────────── */
.step-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 24px; }
.step-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 99px;
  border: none;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
  background: var(--muted-bg);
  color: var(--muted);
}
.step-btn.active { background: var(--primary); color: #fff; }
.step-btn.done { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }

/* ── Step nav ─────────────────────────────────── */
.step-nav { display: flex; justify-content: space-between; margin-top: 24px; }

/* ── Detail view ──────────────────────────────── */
.result-banner {
  text-align: center;
  font-weight: 700;
  font-size: 15px;
  padding: 14px;
  border-radius: var(--radius);
  border: 2px solid;
  margin-bottom: 24px;
}
.result-banner.green { border-color: var(--green); background: var(--green-bg); color: #166534; }
.result-banner.yellow { border-color: var(--yellow); background: var(--yellow-bg); color: #92400e; }
.result-banner.red { border-color: var(--red); background: var(--red-bg); color: #991b1b; }

.info-row {
  display: flex;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--muted); width: 200px; flex-shrink: 0; }
.info-value { font-weight: 500; }

.check-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13px; }
.check-row .icon-ok { color: var(--green); }
.check-row .icon-no { color: var(--red); }

/* ── Report (print-only tweaks) ────────────────── */
.print-only { display: none; }
@media print {
  .sidebar, .page-header .btn, .no-print { display: none !important; }
  .main { padding: 0; }
  body { background: #fff; }
  .print-only { display: block; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ── Misc ─────────────────────────────────────── */
.text-link { color: var(--primary); text-decoration: none; font-weight: 500; font-size: 13px; }
.text-link:hover { text-decoration: underline; }
.text-muted { color: var(--muted); font-size: 13px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.items-center { align-items: center; }
.empty-state { text-align: center; padding: 40px 0; color: var(--muted); font-size: 14px; }
hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
