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

: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(92px + 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: 9px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 800; font-size: 1.15rem; letter-spacing: .5px; }
.brand-sub { font-size: .68rem; color: var(--muted); font-weight: 600; }
.icon-btn {
  background: none; border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; font: inherit; color: var(--muted); cursor: pointer;
}

/* ===== الآية الكريمة ===== */
.ayah {
  background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%);
  color: #fff; text-align: center; padding: 18px 20px 14px;
}
.ayah-text {
  margin: 0; font-size: 1.12rem; font-weight: 600; line-height: 1.9;
  font-family: "Traditional Arabic", "Amiri", "Noto Naskh Arabic", "Scheherazade New", serif;
}
.ayah-src { margin: 5px 0 0; font-size: .74rem; opacity: .8; letter-spacing: 1px; }

/* ===== العبارات المتغيّرة ===== */
.quote {
  background: var(--red-soft); color: var(--red-dark);
  text-align: center; padding: 11px 18px; font-size: .88rem;
  font-weight: 600; border-bottom: 1px solid var(--line);
  min-height: 44px; display: flex; align-items: center; justify-content: center;
  transition: opacity .4s ease;
}
.quote.fading { opacity: 0; }
.quote small { display: block; font-weight: 400; opacity: .7; font-size: .76rem; }

/* ===== التذييل ===== */
.foot {
  text-align: center; padding: 26px 20px 16px; margin-top: 10px;
  border-top: 1px solid var(--line);
}
.foot-hadith {
  margin: 0; font-size: .98rem; font-weight: 600; color: var(--ink);
  font-family: "Traditional Arabic", "Amiri", "Noto Naskh Arabic", serif;
  line-height: 1.9;
}
.foot-src { margin: 4px 0 12px; font-size: .74rem; color: var(--muted); }
.foot-note { margin: 0; font-size: .74rem; color: var(--muted); line-height: 1.7; }

/* ===== البانر ===== */
.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: 12px;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 20;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  gap: 4px;
  padding: 7px;
  border-radius: 22px;
  background: rgba(255, 255, 255, .78);
  border: 1px solid rgba(255, 255, 255, .6);
  box-shadow: 0 10px 30px rgba(24, 12, 14, .16),
              0 2px 6px rgba(24, 12, 14, .08);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
}

/* توهّج أحمر خفيف خلف الشريط */
.tabbar::before {
  content: '';
  position: absolute; inset: -1px;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(179, 20, 28, .07), rgba(179, 20, 28, .02));
  pointer-events: none;
}

.tabbar button {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 9px 2px 7px;
  border: none;
  border-radius: 16px;
  background: transparent;
  font: inherit;
  font-size: .73rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color .25s ease, transform .25s cubic-bezier(.34, 1.4, .5, 1);
}

.tabbar .ico {
  display: grid; place-items: center;
  width: 26px; height: 26px;
  transition: transform .3s cubic-bezier(.34, 1.4, .5, 1);
}
.tabbar .ico svg { width: 22px; height: 22px; }
.tabbar .lbl { line-height: 1; }

/* الخلفية المتحركة للتبويب النشط */
.tabbar button::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: 16px;
  background: linear-gradient(145deg, var(--red) 0%, var(--red-dark) 100%);
  opacity: 0;
  transform: scale(.72);
  transition: opacity .28s ease, transform .32s cubic-bezier(.34, 1.4, .5, 1);
  z-index: -1;
}

.tabbar button.active {
  color: #fff;
  transform: translateY(-2px);
}
.tabbar button.active::before {
  opacity: 1;
  transform: scale(1);
  box-shadow: 0 6px 16px rgba(179, 20, 28, .38);
}
.tabbar button.active .ico { transform: translateY(-1px) scale(1.06); }

/* تبويب الطلب العاجل: لمسة حمراء دائمة */
.tabbar button.urgent:not(.active) { color: var(--red); }
.tabbar .ico { position: relative; }
.tabbar button.urgent:not(.active) .ico::after {
  content: '';
  position: absolute; top: -1px; inset-inline-end: -1px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--red);
  border: 1.5px solid var(--card);
  box-shadow: 0 0 0 0 rgba(179, 20, 28, .55);
  animation: pulseDot 2.4s ease-out infinite;
}
@keyframes pulseDot {
  0%   { box-shadow: 0 0 0 0 rgba(179, 20, 28, .5); }
  70%  { box-shadow: 0 0 0 9px rgba(179, 20, 28, 0); }
  100% { box-shadow: 0 0 0 0 rgba(179, 20, 28, 0); }
}

.tabbar button:active { transform: scale(.94); }

/* احترام تفضيل تقليل الحركة */
@media (prefers-reduced-motion: reduce) {
  .tabbar button, .tabbar button::before, .tabbar .ico { transition: none; }
  .tabbar button.urgent:not(.active) .ico::after { animation: none; }
}

/* ===== التنبيه ===== */
.toast {
  position: fixed; bottom: calc(104px + 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); }

  :root:not([data-theme="light"]) .tabbar {
    background: rgba(27, 30, 36, .82);
    border-color: rgba(255, 255, 255, .08);
    box-shadow: 0 10px 32px rgba(0, 0, 0, .55);
  }
}

/* ===== دعوة تثبيت التطبيق ===== */
.install-sheet {
  position: fixed;
  inset-inline: 10px;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  max-width: 460px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px 16px 14px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .22);
  transform: translateY(130%);
  opacity: 0;
  transition: transform .38s cubic-bezier(.2, .8, .3, 1), opacity .3s ease;
}
.install-sheet.show { transform: translateY(0); opacity: 1; }

.install-x {
  position: absolute; inset-inline-start: 10px; top: 8px;
  background: none; border: none; font-size: 1.5rem; line-height: 1;
  color: var(--muted); cursor: pointer; padding: 4px 8px;
}

.install-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.install-top img { flex: 0 0 auto; }
.install-top b { display: block; font-size: .98rem; }
.install-top span { display: block; font-size: .82rem; color: var(--muted); line-height: 1.5; }

.install-actions { display: flex; gap: 8px; }
.install-actions .btn { margin: 0; }
.install-actions .install-go { flex: 2; }
.install-actions .install-later { flex: 1; }

.install-steps {
  margin: 0 0 12px; padding-inline-start: 20px;
  font-size: .87rem; line-height: 2; color: var(--ink);
}
.install-steps b { color: var(--red); }
.ios-share {
  display: inline-block; vertical-align: -4px;
  background: var(--red-soft); color: var(--red);
  border-radius: 6px; padding: 2px 5px; box-sizing: content-box;
}

.install-mini { border-color: var(--red); color: var(--red); font-weight: 700; }

/* فقرة إرشادية داخل بطاقة التثبيت */
.install-note {
  margin: 0 0 12px; font-size: .86rem; line-height: 1.9; color: var(--ink);
}
.install-note b { color: var(--red); }
.install-actions .install-safari { flex: 2; }
.install-actions .install-copy { flex: 1.3; }
