/* ===== حياة — التنسيقات الأساسية ===== */

:root {
  --red: #b3141c;
  --red-dark: #8c0f16;
  --red-soft: #fdecec;
  --ink: #16181d;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f6f7f9;
  --card: #ffffff;
  --ok: #157347;
  --warn: #b45309;
  --radius: 14px;
  --pad: 16px;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
}

*, *::before, *::after { box-sizing: inherit; }

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, "Noto Naskh Arabic", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px));
}

/* ===== الشريط العلوي ===== */
.topbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px var(--pad);
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; }
.icon-btn {
  background: none; border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; font: inherit; color: var(--muted); cursor: pointer;
}

/* ===== البانر ===== */
.banner {
  background: var(--red); color: #fff; padding: 10px var(--pad);
  font-size: .92rem; text-align: center;
}

/* ===== التخطيط ===== */
main { padding: var(--pad); max-width: 760px; margin: 0 auto; }
.view { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.pad { padding: var(--pad); }
h2 { margin: 0 0 12px; font-size: 1.15rem; }
h3 { margin: 0 0 10px; font-size: 1rem; }
.muted { color: var(--muted); font-size: .88rem; }
.hint { color: var(--muted); font-size: .82rem; margin: 10px 0 0; }

/* ===== النماذج ===== */
label { display: block; margin-bottom: 12px; font-size: .9rem; font-weight: 600; }
input, select {
  width: 100%; margin-top: 5px; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--red); outline-offset: 1px; border-color: var(--red); }
.row { display: flex; gap: 10px; }
.row > label { flex: 1; }
.chk { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.chk input { width: auto; margin: 0; }

.btn {
  width: 100%; padding: 12px; margin-top: 6px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fff; font: inherit; font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:active { background: var(--red-dark); }
.btn.ghost { background: none; color: var(--muted); border: none; }

/* ===== التبويبات ===== */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tab {
  flex: 1; padding: 9px; border: 1px solid var(--line);
  background: #fff; border-radius: 10px; font: inherit; cursor: pointer;
}
.tab.active { background: var(--red-soft); border-color: var(--red); color: var(--red); font-weight: 700; }

/* ===== الفلاتر ===== */
.filters {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 14px;
}
.filters select { width: auto; flex: 1; min-width: 130px; margin: 0; }

/* ===== القوائم ===== */
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
.item-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.item-title { font-weight: 700; }
.item-body { margin-top: 6px; font-size: .88rem; color: var(--muted); }
.item-actions { margin-top: 12px; display: flex; gap: 8px; }
.item-actions .btn { margin: 0; padding: 9px; font-size: .88rem; }

.blood {
  background: var(--red); color: #fff; font-weight: 700;
  border-radius: 10px; padding: 5px 11px; font-size: .95rem;
  direction: ltr; min-width: 46px; text-align: center;
}

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: .75rem; font-weight: 600; border: 1px solid var(--line);
}
.badge.critical { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.badge.high { background: #ffedd5; color: #9a3412; border-color: #fed7aa; }
.badge.normal { background: #e0f2fe; color: #075985; border-color: #bae6fd; }
.badge.low { background: #f3f4f6; color: #4b5563; }
.badge.ok { background: #dcfce7; color: #166534; border-color: #bbf7d0; }

/* ===== الأهلية ===== */
.eligibility { padding: 12px; border-radius: 10px; margin: 12px 0; font-size: .9rem; }
.eligibility.yes { background: #dcfce7; color: #14532d; }
.eligibility.no { background: #fef3c7; color: #78350f; }

/* ===== الشريط السفلي ===== */
.tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar button {
  flex: 1; padding: 13px 4px; border: none; background: none;
  font: inherit; font-size: .82rem; color: var(--muted); cursor: pointer;
}
.tabbar button.active { color: var(--red); font-weight: 700; }

/* ===== التنبيه ===== */
.toast {
  position: fixed; bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  inset-inline: 20px; z-index: 50;
  background: var(--ink); color: #fff; padding: 12px 16px;
  border-radius: 10px; text-align: center; font-size: .9rem;
}
.toast.err { background: var(--red); }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

/* ===== الوضع الليلي ===== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e8eaed; --muted: #9aa0a6; --line: #2d3138;
    --bg: #121418; --card: #1b1e24; --red-soft: #3b1216;
  }
  :root:not([data-theme="light"]) input,
  :root:not([data-theme="light"]) select,
  :root:not([data-theme="light"]) .tab,
  :root:not([data-theme="light"]) .btn { background: #22262d; color: var(--ink); }
}
