/* ============ سكينة — تصميم ============ */
:root {
  --bg: #0b1613;
  --bg-2: #0f1e19;
  --card: rgba(255, 255, 255, 0.045);
  --card-solid: #14231e;
  --card-border: rgba(212, 180, 106, 0.14);
  --text: #ece7da;
  --muted: #97a69b;
  --gold: #d4b46a;
  --gold-soft: rgba(212, 180, 106, 0.16);
  --emerald: #35a583;
  --emerald-deep: #1d6b55;
  --danger: #d47a6a;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.4);
  --radius: 20px;
  --font-scale: 1;
  --nav-h: 64px;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f5f1e6;
  --bg-2: #ede7d6;
  --card: #fffdf6;
  --card-solid: #fffdf6;
  --card-border: rgba(146, 116, 46, 0.18);
  --text: #22322b;
  --muted: #6d7a70;
  --gold: #a8862e;
  --gold-soft: rgba(168, 134, 46, 0.13);
  --emerald: #1d7a5e;
  --emerald-deep: #16604a;
  --danger: #b4503e;
  --shadow: 0 8px 26px rgba(80, 66, 30, 0.14);
  color-scheme: light;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
  font-family: "Cairo", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.7;
  transition: background 0.35s, color 0.35s;
}

/* خلفية زخرفية: نجمة ثمانية متكررة */
.bg-ornament {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 96 96'%3E%3Cg fill='none' stroke='%23d4b46a' stroke-width='1'%3E%3Cpath d='M48 8 L58 38 L88 48 L58 58 L48 88 L38 58 L8 48 L38 38 Z'/%3E%3Ccircle cx='48' cy='48' r='12'/%3E%3Ccircle cx='0' cy='0' r='8'/%3E%3Ccircle cx='96' cy='0' r='8'/%3E%3Ccircle cx='0' cy='96' r='8'/%3E%3Ccircle cx='96' cy='96' r='8'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 96px 96px;
}
[data-theme="light"] .bg-ornament { opacity: 0.07; }

/* ============ الرأس ============ */
.app-header {
  position: relative; z-index: 2;
  background:
    radial-gradient(1200px 380px at 50% -180px, rgba(53, 165, 131, 0.22), transparent 70%),
    linear-gradient(180deg, var(--bg-2), transparent);
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 18px 6px;
}
.header-inner { max-width: 860px; margin: 0 auto; }
.header-row { display: flex; align-items: center; justify-content: space-between; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 52px; height: 52px; display: grid; place-items: center;
  color: var(--gold);
  background: var(--gold-soft);
  border: 1px solid var(--card-border);
  border-radius: 16px;
}
.brand-text h1 {
  font-size: 1.55rem; font-weight: 800; letter-spacing: 0.5px;
  background: linear-gradient(120deg, var(--gold), #efe0b4, var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
[data-theme="light"] .brand-text h1 { background: linear-gradient(120deg, #8a6a1d, #b5942f); -webkit-background-clip: text; background-clip: text; }
.brand-text p { font-size: 0.72rem; color: var(--muted); margin-top: -4px; }

.icon-btn {
  background: var(--card); border: 1px solid var(--card-border); color: var(--text);
  width: 42px; height: 42px; border-radius: 13px; cursor: pointer;
  display: grid; place-items: center; transition: transform 0.15s, background 0.2s;
}
.icon-btn:active { transform: scale(0.92); }
.ic-sun { display: none; }
[data-theme="light"] .ic-sun { display: block; }
[data-theme="light"] .ic-moon { display: none; }

.greeting-card {
  margin-top: 16px; padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: linear-gradient(135deg, rgba(53, 165, 131, 0.14), var(--gold-soft));
  border: 1px solid var(--card-border); border-radius: var(--radius);
  backdrop-filter: blur(8px);
}
.greeting { display: block; font-weight: 700; font-size: 1.02rem; }
.hijri-date { display: block; color: var(--muted); font-size: 0.8rem; }
.now-chip {
  border: 1px solid var(--card-border); background: var(--card-solid); color: var(--gold);
  padding: 8px 14px; border-radius: 99px; font-family: inherit; font-weight: 700;
  font-size: 0.82rem; cursor: pointer; transition: transform 0.15s;
}
.now-chip:active { transform: scale(0.95); }

/* ============ التخطيط العام ============ */
.app-main {
  position: relative; z-index: 1;
  max-width: 860px; margin: 0 auto;
  padding: 12px 18px calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 28px);
}
.hidden { display: none !important; }

.section-title {
  font-size: 1.05rem; font-weight: 800; margin: 18px 2px 12px;
  display: flex; align-items: center; gap: 10px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: linear-gradient(to left, var(--card-border), transparent); }
.section-title.center { justify-content: center; }
.section-title.center::after { display: none; }

/* ============ البحث ============ */
.search-wrap {
  position: relative; display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 16px; padding: 12px 16px; margin-top: 10px;
  color: var(--muted); transition: border-color 0.2s;
}
.search-wrap:focus-within { border-color: var(--gold); }
.search-wrap input {
  flex: 1; background: none; border: none; outline: none; color: var(--text);
  font-family: inherit; font-size: 0.95rem;
}
.search-wrap input::placeholder { color: var(--muted); }
.search-clear { display: none; background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.9rem; }
.search-wrap.has-value .search-clear { display: block; }
.search-results { margin-top: 14px; }
.search-empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ============ التقدم اليومي ============ */
.daily-progress {
  margin-top: 16px; padding: 16px 18px;
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius);
}
.daily-progress .dp-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.daily-progress .dp-title { font-weight: 800; font-size: 0.95rem; }
.daily-progress .dp-value { color: var(--gold); font-weight: 800; font-size: 0.9rem; }
.dp-bar { height: 8px; border-radius: 99px; background: rgba(128,128,128,0.18); overflow: hidden; }
.dp-bar-fill {
  height: 100%; border-radius: 99px; width: 0;
  background: linear-gradient(90deg, var(--emerald), var(--gold));
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.dp-hint { margin-top: 8px; font-size: 0.75rem; color: var(--muted); }

/* ============ شبكة الأقسام ============ */
.categories-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px;
}
.cat-card {
  position: relative; overflow: hidden; text-align: right;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 16px; cursor: pointer;
  font-family: inherit; color: var(--text);
  transition: transform 0.18s, border-color 0.2s, box-shadow 0.2s;
}
.cat-card:hover { transform: translateY(-3px); border-color: var(--gold); box-shadow: var(--shadow); }
.cat-card:active { transform: scale(0.97); }
.cat-card .cat-icon {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  font-size: 1.45rem; margin-bottom: 10px;
  background: color-mix(in srgb, var(--cat-color) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--cat-color) 30%, transparent);
}
.cat-card h3 { font-size: 0.98rem; font-weight: 800; }
.cat-card p { font-size: 0.72rem; color: var(--muted); min-height: 2.2em; }
.cat-card .cat-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.cat-card .cat-count { font-size: 0.72rem; color: var(--muted); }
.cat-card .cat-done-badge {
  font-size: 0.68rem; color: var(--emerald); font-weight: 800;
  opacity: 0; transition: opacity 0.3s;
}
.cat-card.complete .cat-done-badge { opacity: 1; }
.cat-card .cat-ring { position: absolute; top: 14px; left: 14px; width: 26px; height: 26px; }
.cat-ring circle { fill: none; stroke-width: 3; }
.cat-ring .track { stroke: rgba(128,128,128,0.22); }
.cat-ring .fill {
  stroke: var(--emerald); stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: center;
  transition: stroke-dashoffset 0.5s;
}

/* ============ صفحة القسم ============ */
.cat-header {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; margin: 0 -18px; padding-inline: 18px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
}
.cat-title-wrap { flex: 1; }
.cat-title-wrap h2 { font-size: 1.15rem; font-weight: 800; }
.cat-progress-label { font-size: 0.75rem; color: var(--muted); }
.cat-progressbar { height: 5px; border-radius: 99px; background: rgba(128,128,128,0.18); overflow: hidden; margin-bottom: 16px; }
.cat-progressbar-fill {
  height: 100%; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, var(--emerald), var(--gold));
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ============ بطاقة الذكر ============ */
.dhikr-list { display: flex; flex-direction: column; gap: 14px; }
.dhikr-card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 20px 20px 14px;
  cursor: pointer; user-select: none;
  transition: border-color 0.25s, opacity 0.4s, transform 0.15s;
  animation: cardIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(14px); } }
.dhikr-card:active { transform: scale(0.99); }
.dhikr-card.done { opacity: 0.55; border-color: var(--emerald); }
.dhikr-card .dhikr-text {
  font-family: "Amiri", serif;
  font-size: calc(1.28rem * var(--font-scale));
  line-height: 2.15; text-align: justify; text-align-last: right;
}
.dhikr-card .dhikr-fadl {
  margin-top: 12px; padding: 10px 14px; border-radius: 12px;
  background: var(--gold-soft); border-right: 3px solid var(--gold);
  font-size: 0.82rem; color: var(--text);
}
.dhikr-card .dhikr-fadl::before { content: "الفضل: "; font-weight: 800; color: var(--gold); }
.dhikr-card .dhikr-source { margin-top: 10px; font-size: 0.72rem; color: var(--muted); }
.dhikr-card .dhikr-source::before { content: "📚 "; }

.dhikr-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px; padding-top: 12px;
  border-top: 1px dashed var(--card-border);
}
.dhikr-actions { display: flex; gap: 4px; }
.action-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  transition: color 0.2s, background 0.2s, transform 0.15s;
}
.action-btn:hover { background: var(--card); color: var(--text); }
.action-btn:active { transform: scale(0.88); }
.action-btn.fav-on { color: var(--danger); }
.action-btn.fav-on svg { fill: currentColor; }

.counter-wrap { display: flex; align-items: center; gap: 12px; }
.counter-label { font-size: 0.78rem; color: var(--muted); font-weight: 700; }
.counter-btn {
  position: relative; width: 58px; height: 58px; flex: none;
  border: none; background: none; cursor: pointer; color: var(--text);
}
.counter-btn svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.counter-btn circle { fill: none; stroke-width: 4; }
.counter-btn .track { stroke: rgba(128,128,128,0.22); }
.counter-btn .fill {
  stroke: var(--emerald); stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: center;
  transition: stroke-dashoffset 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.counter-btn .num {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-weight: 800; font-size: 1rem;
}
.dhikr-card.done .counter-btn .fill { stroke: var(--gold); }
.dhikr-card.done .counter-btn .num { color: var(--gold); }
.counter-btn.bump { animation: bump 0.25s; }
@keyframes bump { 40% { transform: scale(1.14); } }

/* شارة القسم في نتائج البحث/المفضلة */
.dhikr-cat-badge {
  display: inline-block; margin-bottom: 8px; font-size: 0.7rem; font-weight: 800;
  color: var(--gold); background: var(--gold-soft);
  padding: 3px 12px; border-radius: 99px;
}

/* ============ السبحة ============ */
.tasbih-phrases {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 10px;
}
.phrase-chip {
  border: 1px solid var(--card-border); background: var(--card); color: var(--text);
  border-radius: 99px; padding: 8px 16px; font-family: "Amiri", serif; font-size: 1rem;
  cursor: pointer; transition: all 0.2s;
}
.phrase-chip.active { background: var(--gold-soft); border-color: var(--gold); color: var(--gold); font-weight: 700; }
.phrase-chip.custom { display: inline-flex; align-items: center; gap: 8px; }
.chip-del {
  display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  font-size: 0.62rem; font-family: "Cairo", sans-serif; line-height: 1;
  background: rgba(128,128,128,0.18); color: var(--muted);
  transition: background 0.2s, color 0.2s;
}
.chip-del:hover { background: var(--danger); color: #fff; }
.phrase-chip.add-chip {
  font-family: "Cairo", sans-serif; font-size: 0.82rem; font-weight: 700;
  color: var(--emerald); border-style: dashed;
}
.phrase-chip.add-chip:hover { border-color: var(--emerald); }

.add-phrase-form {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  max-width: 560px; margin: 4px auto 8px;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 16px; padding: 12px 14px;
  animation: cardIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.add-phrase-form input {
  flex: 1 1 220px; background: none; border: none; outline: none;
  color: var(--text); font-family: "Amiri", serif; font-size: 1.05rem;
  padding: 4px 2px; border-bottom: 1px dashed var(--card-border);
}
.add-phrase-form input:focus { border-bottom-color: var(--gold); }
.add-phrase-form input::placeholder { font-family: "Cairo", sans-serif; font-size: 0.85rem; color: var(--muted); }
.add-phrase-actions { display: flex; gap: 8px; }

.tasbih-stage { display: grid; place-items: center; padding: 26px 0 10px; }
.tasbih-btn {
  position: relative; width: min(74vw, 300px); aspect-ratio: 1;
  border-radius: 50%; border: none; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--emerald) 24%, var(--card-solid)), var(--card-solid) 70%);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.06);
  color: var(--text); display: grid; place-items: center; align-content: center; gap: 6px;
  transition: transform 0.12s;
}
.tasbih-btn:active { transform: scale(0.965); }
.tasbih-ring { position: absolute; inset: 6px; width: calc(100% - 12px); height: calc(100% - 12px); pointer-events: none; }
.tasbih-ring circle { fill: none; stroke-width: 5; }
.tasbih-ring .ring-track { stroke: rgba(128,128,128,0.2); }
.tasbih-ring .ring-fill {
  stroke: var(--gold); stroke-linecap: round;
  stroke-dasharray: 628.3; stroke-dashoffset: 628.3;
  transform: rotate(-90deg); transform-origin: center;
  transition: stroke-dashoffset 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.tasbih-count { font-size: 3.6rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.tasbih-phrase { font-family: "Amiri", serif; font-size: 1.25rem; color: var(--gold); padding: 0 30px; text-align: center; }

.tasbih-meta { display: flex; flex-direction: column; align-items: center; gap: 16px; margin-top: 14px; }
.tasbih-targets { display: flex; gap: 8px; }
.target-chip {
  border: 1px solid var(--card-border); background: var(--card); color: var(--text);
  width: 56px; padding: 8px 0; border-radius: 14px; font-family: inherit; font-weight: 800;
  font-size: 0.95rem; cursor: pointer; transition: all 0.2s;
}
.target-chip.active { background: var(--gold-soft); border-color: var(--gold); color: var(--gold); }
.tasbih-stats { display: flex; gap: 34px; }
.stat { text-align: center; }
.stat span { font-size: 1.35rem; font-weight: 800; color: var(--emerald); display: block; font-variant-numeric: tabular-nums; }
.stat label { font-size: 0.72rem; color: var(--muted); }

.ghost-btn {
  border: 1px solid var(--card-border); background: var(--card); color: var(--text);
  border-radius: 13px; padding: 9px 20px; font-family: inherit; font-weight: 700;
  font-size: 0.85rem; cursor: pointer; transition: all 0.2s;
}
.ghost-btn:hover { border-color: var(--gold); }
.ghost-btn:active { transform: scale(0.95); }
.ghost-btn.danger { color: var(--danger); }
.ghost-btn.sm { padding: 6px 14px; }

/* ============ الإعدادات ============ */
.settings-card, .about-card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 6px 20px; margin-bottom: 16px;
}
.setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 0; border-bottom: 1px dashed var(--card-border);
}
.setting-row:last-child { border-bottom: none; }
.setting-row strong { font-size: 0.92rem; }
.setting-row p { font-size: 0.74rem; color: var(--muted); }
.font-controls { display: flex; align-items: center; gap: 10px; }
#fontScaleLabel { font-size: 0.85rem; font-weight: 800; color: var(--gold); min-width: 44px; text-align: center; }
.about-card { padding: 18px 20px; }
.about-card h3 { color: var(--gold); margin-bottom: 8px; font-size: 1rem; }
.about-card p { font-size: 0.85rem; margin-bottom: 8px; }
.about-card .muted { color: var(--muted); font-size: 0.78rem; }

/* ============ التنقل السفلي ============ */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-around;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: color-mix(in srgb, var(--bg-2) 88%, transparent);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--card-border);
}
.nav-item {
  flex: 1; max-width: 130px; background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-family: inherit; font-size: 0.68rem; font-weight: 700;
  transition: color 0.2s;
}
.nav-item.active { color: var(--gold); }
.nav-item.active svg { filter: drop-shadow(0 0 8px color-mix(in srgb, var(--gold) 55%, transparent)); }

/* ============ الإشعار ============ */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 18px);
  left: 50%; transform: translateX(-50%) translateY(20px); z-index: 20;
  background: var(--card-solid); color: var(--text);
  border: 1px solid var(--gold); border-radius: 99px;
  padding: 10px 24px; font-size: 0.85rem; font-weight: 700;
  opacity: 0; pointer-events: none; transition: all 0.3s;
  box-shadow: var(--shadow); white-space: nowrap; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ استجابة الشاشات ============ */
@media (max-width: 480px) {
  .categories-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .cat-card { padding: 13px; }
  .dhikr-card { padding: 16px 16px 12px; }
  .dhikr-card .dhikr-text { font-size: calc(1.14rem * var(--font-scale)); }
  .brand-text h1 { font-size: 1.35rem; }
  .tasbih-count { font-size: 3rem; }
}
@media (min-width: 720px) {
  .dhikr-list { max-width: 720px; margin-inline: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
