:root {
  --bg: #f3f4f2;
  --surface: #ffffff;
  --surface-2: #fafaf9;
  --ink: #1b1f27;
  --muted: #6b7280;
  --muted-2: #9aa0ab;
  --navy: #1f2a44;
  --navy-2: #2c3a5e;
  --line: #e5e5e1;
  --gold: #b08d57;
  --danger: #9b3b3b;
  --ok: #2f6b4f;
  --shadow: 0 1px 2px rgba(20, 25, 40, .04), 0 8px 24px rgba(20, 25, 40, .06);
  --radius: 16px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Tajawal", system-ui, "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.85;
  font-size: 17px;
}
.quran, .amiri, .name-ar { font-family: "Amiri", "Tajawal", serif; }

a { color: var(--navy-2); text-decoration: none; }
a:hover { color: var(--navy); }
img { max-width: 100%; display: block; }
.container { max-width: 920px; margin: 0 auto; padding: 0 18px; }
.narrow { max-width: 720px; }

/* ===== Header ===== */
.site-header {
  background: var(--navy);
  color: #eef0f5;
  position: sticky; top: 0; z-index: 50;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 62px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; color: #fff; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 4px rgba(176,141,87,.18); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a {
  color: #cdd2de; padding: 7px 12px; border-radius: 10px; font-size: .95rem;
  transition: background .15s, color .15s;
}
.nav a:hover, .nav a.active { background: rgba(255,255,255,.08); color: #fff; }
.nav a.admin { color: var(--gold); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--navy); color: #fff; border: 0; cursor: pointer;
  padding: 12px 22px; border-radius: 12px; font-size: 1rem; font-weight: 600;
  font-family: inherit; transition: transform .08s, background .15s; text-align: center;
}
.btn:hover { background: var(--navy-2); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--navy); border: 1.5px solid var(--line); }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--muted-2); }
.btn.gold { background: var(--gold); }
.btn.gold:hover { background: #9c7b48; }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 8px 14px; font-size: .9rem; border-radius: 10px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ===== Cards ===== */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px;
}
.section { margin: 26px 0; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* ===== Home page ===== */
.hero { text-align: center; padding: 54px 18px 30px; }
.hero h1 { font-size: 2.1rem; margin: 0 0 10px; color: var(--navy); letter-spacing: -.5px; }
.hero .ayah { font-family: "Amiri", serif; font-size: 1.5rem; color: var(--ink); margin: 14px auto; max-width: 620px; }
.hero p { color: var(--muted); max-width: 560px; margin: 8px auto 22px; }
.divider { width: 60px; height: 2px; background: var(--gold); margin: 18px auto; border: 0; opacity: .7; }

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

/* Deceased card */
.person-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s;
  display: flex; flex-direction: column;
}
.person-card:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(20,25,40,.10); }
.person-card .photo { aspect-ratio: 1/1; background: var(--navy); overflow: hidden; }
.person-card .photo img { width: 100%; height: 100%; object-fit: cover; }
.person-card .photo.placeholder { display: flex; align-items: center; justify-content: center; }
.photo.placeholder { background: linear-gradient(160deg, #233152, #1a2238); }
.photo.placeholder span { color: rgba(255,255,255,.5); font-size: 2.6rem; }
.person-card .body { padding: 16px; text-align: center; flex: 1; display: flex; flex-direction: column; }
.person-card .body h3 { margin: 0 0 6px; font-size: 1.2rem; color: var(--navy); font-family: "Amiri", serif; }
.person-card .body .bio { color: var(--muted); font-size: .92rem; flex: 1; }
.person-card .meta { color: var(--muted-2); font-size: .82rem; margin-top: 10px; }

/* ===== Deceased page ===== */
.person-hero { text-align: center; padding: 30px 0 10px; }
.person-hero .avatar {
  width: 130px; height: 130px; border-radius: 50%; margin: 0 auto 14px; overflow: hidden;
  border: 4px solid #fff; box-shadow: var(--shadow); background: linear-gradient(160deg, #233152, #1a2238);
  display: flex; align-items: center; justify-content: center;
}
.person-hero .avatar img { width: 100%; height: 100%; object-fit: cover; }
.person-hero .avatar span { color: rgba(255,255,255,.55); font-size: 3rem; }
.person-hero h1 { font-family: "Amiri", serif; color: var(--navy); font-size: 2rem; margin: 6px 0; }
.person-hero .bio { color: var(--muted); max-width: 560px; margin: 6px auto 0; }
.stat-row { display: flex; gap: 14px; justify-content: center; margin: 18px 0; flex-wrap: wrap; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 18px; box-shadow: var(--shadow); }
.stat b { color: var(--navy); font-size: 1.3rem; display: block; }
.stat small { color: var(--muted); }

/* Tool tabs */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 22px 0 18px; }
.tab-btn {
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
  padding: 9px 16px; border-radius: 999px; cursor: pointer; font-family: inherit; font-size: .95rem;
  transition: all .15s;
}
.tab-btn:hover { border-color: var(--navy-2); }
.tab-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ===== Forms ===== */
label { display: block; font-weight: 600; margin: 16px 0 6px; color: var(--ink); }
input[type=text], input[type=password], textarea, select {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  font-family: inherit; font-size: 1rem; background: var(--surface); color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--navy-2); }
textarea { resize: vertical; min-height: 90px; }
.checks { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.check {
  display: flex; align-items: center; gap: 10px; border: 1.5px solid var(--line);
  padding: 11px 14px; border-radius: 12px; cursor: pointer; font-weight: 500; margin: 0;
}
.check input { width: auto; }
.check:has(input:checked) { border-color: var(--navy); background: var(--surface-2); }
.hint { color: var(--muted); font-size: .88rem; margin-top: 4px; }

/* ===== Quran ===== */
.quran-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.quran-controls select { width: auto; min-width: 220px; }
.surah-text {
  font-family: "Amiri", serif; font-size: 1.75rem; line-height: 2.4; text-align: justify;
  color: var(--ink); background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 26px; min-height: 120px;
}
.ayah-num {
  font-family: "Tajawal"; font-size: .9rem; color: var(--gold); margin: 0 4px;
  display: inline-block; min-width: 1.6em; text-align: center;
}
.basmala { text-align: center; font-family: "Amiri", serif; font-size: 1.6rem; margin-bottom: 16px; color: var(--navy); }

/* ===== Adhkar ===== */
.dhikr-toggle { display: flex; gap: 8px; margin-bottom: 16px; }
.dhikr {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 12px; box-shadow: var(--shadow); cursor: pointer; transition: border-color .15s;
  -webkit-user-select: none; -moz-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.dhikr .text { font-family: "Amiri", serif; font-size: 1.4rem; line-height: 2.1; }
.dhikr .note { color: var(--muted); font-size: .88rem; margin-top: 8px; }
.dhikr .counter { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.dhikr .badge { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 14px; font-size: .9rem; color: var(--navy); font-weight: 700; }
.dhikr.done { border-color: var(--ok); background: #f3f9f5; }
.dhikr.done .badge { background: var(--ok); color: #fff; border-color: var(--ok); }

/* ===== Tasbeeh ===== */
.tasbeeh { text-align: center; padding: 10px 0; }
.tasbeeh .count { font-size: 4.5rem; font-weight: 800; color: var(--navy); font-family: "Tajawal"; line-height: 1.1; }
.tasbeeh .phrase { font-family: "Amiri", serif; font-size: 1.8rem; color: var(--ink); margin: 4px 0 18px; min-height: 2.2rem; }
.tasbeeh { -webkit-user-select: none; -moz-user-select: none; user-select: none; }
.tap-btn {
  width: 200px; height: 200px; border-radius: 50%; border: 0; cursor: pointer;
  background: radial-gradient(circle at 30% 30%, #2c3a5e, #1f2a44);
  color: #fff; font-size: 1.3rem; font-weight: 700; box-shadow: 0 10px 30px rgba(31,42,68,.35);
  transition: transform .08s; font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.tap-btn:active { transform: scale(.96); }
.tasbeeh .phrases { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 18px 0; }

/* ===== Prayer times ===== */
.times-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; margin-top: 16px; }
.time-cell { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; text-align: center; box-shadow: var(--shadow); }
.time-cell.next { border-color: var(--gold); background: #fbf8f2; }
.time-cell .label { color: var(--muted); font-size: .9rem; }
.time-cell .val { font-size: 1.5rem; font-weight: 700; color: var(--navy); }

/* The deceased name never wraps; prefix + name stay one unit */
.mname { white-space: nowrap; }
.for-name { white-space: nowrap; }
.wa-icon { fill: #25D366; width: 22px; height: 22px; vertical-align: -5px; margin-inline-end: 3px; }

@media (max-width: 720px) {
  /* Mobile: prefix + name drops to its own line */
  .person-hero .hint .for-name { display: block; margin: 2px 0; }
}

/* ===== Search ===== */
.search-box { margin: 0 auto 18px; max-width: 460px; }
.search-box input {
  text-align: center; font-size: 1.05rem; border-radius: 999px;
  border: 1.5px solid var(--line); box-shadow: var(--shadow);
}
.search-box input:focus { border-color: var(--navy-2); }

/* ===== Duas ===== */
.dua-foot { display: flex; align-items: center; justify-content: flex-start; gap: 10px; margin-top: 12px; }
.dua-foot form { margin-inline-start: auto; } /* delete button (admin) pushed to the other end */
.like-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer;
  background: var(--surface-2); border: 1.5px solid var(--line); color: var(--muted);
  padding: 7px 16px; min-height: 38px; line-height: 1; border-radius: 999px;
  font-family: inherit; font-size: .95rem; font-weight: 700; -webkit-tap-highlight-color: transparent;
  transition: transform .12s cubic-bezier(.34,1.56,.64,1), border-color .15s, background .15s, color .15s;
}
.like-btn:hover { border-color: #ecc4c4; background: #fdf5f5; }
.like-btn:active { transform: scale(.9); }
.like-btn.liked { border-color: #f0c4c4; background: #fdeeee; color: #c0392b; }
.like-btn .heart {
  width: 18px; height: 18px; display: block; flex: 0 0 auto;
  fill: none; stroke: #b9bdc7; stroke-width: 2.2; stroke-linejoin: round;
  transform-origin: center; transition: transform .12s, fill .15s, stroke .15s;
}
.like-btn:hover .heart { stroke: #d98a8a; }
.like-btn.liked .heart { fill: #e23b3b; stroke: #e23b3b; }
.like-btn .like-count { min-width: 1ch; font-variant-numeric: tabular-nums; line-height: 1; }

@keyframes heartPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.45); }
  70% { transform: scale(.9); }
  100% { transform: scale(1); }
}
.like-btn.pop .heart { animation: heartPop .4s ease; }

@media (max-width: 720px) {
  .dua-foot { margin-top: 14px; }
  .like-btn { padding: 8px 18px; min-height: 40px; font-size: 1rem; gap: 9px; }
  .like-btn .heart { width: 20px; height: 20px; }
}

.dua-item { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow); }
.dua-item .who { font-weight: 700; color: var(--navy); font-size: .92rem; }
.dua-item .when { color: var(--muted-2); font-size: .8rem; }
.dua-item .txt { margin-top: 4px; }
.dua-empty { text-align: center; color: var(--muted); padding: 24px; }

/* ===== Admin dashboard ===== */
.admin-row { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); margin-bottom: 10px; box-shadow: var(--shadow); }
.admin-row .thumb { width: 60px; height: 60px; border-radius: 10px; object-fit: cover; background: var(--navy); flex-shrink: 0; }
.admin-row .info { flex: 1; }
.admin-row .info h4 { margin: 0 0 2px; color: var(--navy); }
.tag { display: inline-block; font-size: .78rem; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); margin: 2px 2px 0 0; }
.badge-pending { background: #fdf6e9; color: #93701f; border-color: #f0e2c2; }
.badge-approved { background: #eef7f1; color: var(--ok); border-color: #cfe7d8; }

/* ===== Footer ===== */
.site-footer { text-align: center; color: var(--muted); padding: 40px 18px; font-size: .9rem; margin-top: 40px; border-top: 1px solid var(--line); }
.site-footer .ayah { font-family: "Amiri", serif; font-size: 1.15rem; color: var(--navy); margin-bottom: 8px; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 12px 22px; border-radius: 12px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 99;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Hide the nav's horizontal scrollbar while keeping it scrollable */
.nav::-webkit-scrollbar { display: none; }
.nav { scrollbar-width: none; }

@media (max-width: 720px) {
  body { font-size: 16px; }

  /* Header: brand on top, nav as one horizontally-scrolling row */
  .site-header .container {
    height: auto; flex-direction: column; align-items: stretch;
    padding-top: 10px; padding-bottom: 6px; gap: 8px;
  }
  .brand { justify-content: center; font-size: 1.1rem; }
  .nav {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    gap: 2px; padding-bottom: 4px; justify-content: flex-start;
  }
  .nav a { white-space: nowrap; flex: 0 0 auto; padding: 8px 12px; font-size: .92rem; }

  .hero { padding: 36px 4px 22px; }
  .hero h1 { font-size: 1.7rem; }
  .hero .ayah { font-size: 1.25rem; }
  .btn-row { gap: 8px; }
  .btn { padding: 12px 18px; }

  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }

  .surah-text { font-size: 1.5rem; padding: 18px; line-height: 2.2; }
  .quran-controls select { min-width: 0; flex: 1 1 160px; }

  .dhikr .text { font-size: 1.25rem; }
  .person-hero .avatar { width: 110px; height: 110px; }
  .person-hero h1 { font-size: 1.7rem; }
  .tap-btn { width: 170px; height: 170px; font-size: 1.15rem; }
  .tasbeeh .count { font-size: 3.6rem; }
  .times-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }

  /* Admin rows stack vertically */
  .admin-row { flex-wrap: wrap; }
  .admin-row .info { flex-basis: 60%; }
  .admin-row .btn-row { width: 100%; }
}

@media (max-width: 380px) {
  .stat-row { gap: 8px; }
  .stat { padding: 8px 12px; }
  .tap-btn { width: 150px; height: 150px; }
}
