/* ==========================================================================
   Salah — Unified Glassmorphism Design System
   ========================================================================== */

/* ---- Palettes (switchable via [data-palette] on <html>) ---- */
:root,
[data-palette="emerald"] {
  --bg-0: #0B1220;
  --bg-1: #0F172A;
  --bg-2: #064E3B;
  --accent: #F59E0B;
  --accent-2: #FCD34D;
  --accent-rgb: 245, 158, 11;
  --glow: rgba(245, 158, 11, .35);
}
[data-palette="sapphire"] {
  --bg-0: #060B18;
  --bg-1: #0B1730;
  --bg-2: #0E2A5E;
  --accent: #38BDF8;
  --accent-2: #93C5FD;
  --accent-rgb: 56, 189, 248;
  --glow: rgba(56, 189, 248, .35);
}
[data-palette="maroon"] {
  --bg-0: #10060A;
  --bg-1: #1A0B12;
  --bg-2: #5C0E22;
  --accent: #F59E0B;
  --accent-2: #FBBF24;
  --accent-rgb: 245, 158, 11;
  --glow: rgba(245, 158, 11, .30);
}
[data-palette="ocean"] {
  --bg-0: #041312;
  --bg-1: #072320;
  --bg-2: #0B4F4A;
  --accent: #2DD4BF;
  --accent-2: #99F6E4;
  --accent-rgb: 45, 212, 191;
  --glow: rgba(45, 212, 191, .35);
}

:root {
  --text-0: #F8FAFC;
  --text-1: #CBD5E1;
  --text-2: #94A3B8;
  --danger: #F87171;
  --success: #34D399;

  --glass-bg: rgba(255, 255, 255, .06);
  --glass-bg-strong: rgba(255, 255, 255, .10);
  --glass-border: rgba(255, 255, 255, .14);
  --shadow-soft: 0 8px 32px rgba(0, 0, 0, .35);

  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;

  --font-scale: 1;
  --font-base: 16px;

  --nav-h: 64px;
  --bottomnav-h: 74px;
  --font-arabic: "Traditional Arabic", "Scheherazade New", "Amiri", "Noto Naskh Arabic", serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: calc(16px * var(--font-scale)); scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  color: var(--text-0);
  background: radial-gradient(1200px 800px at 15% -10%, var(--bg-2) 0%, transparent 55%),
              radial-gradient(1000px 700px at 110% 10%, rgba(var(--accent-rgb), .15) 0%, transparent 50%),
              linear-gradient(180deg, var(--bg-1), var(--bg-0) 60%);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.6;
  padding-top: var(--nav-h);
  padding-bottom: calc(var(--bottomnav-h) + 12px);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

[dir="rtl"] body { direction: rtl; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img, svg { display: block; max-width: 100%; }
ul { list-style: none; }
input, select, textarea { font-family: inherit; font-size: 1rem; }

/* ---- Floating ambient orbs (futuristic backdrop) ---- */
.orb {
  position: fixed; border-radius: 50%; filter: blur(60px);
  opacity: .35; pointer-events: none; z-index: 0;
  animation: float 18s ease-in-out infinite;
}
.orb-1 { width: 260px; height: 260px; background: var(--accent); top: -60px; left: -60px; }
.orb-2 { width: 320px; height: 320px; background: var(--bg-2); bottom: -100px; right: -80px; animation-delay: -6s; }
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(20px, -30px) scale(1.08); }
}
@media (prefers-reduced-motion: reduce) {
  .orb, .fade-in, .pulse-ring { animation: none !important; }
}

/* ---- Layout ---- */
.container { max-width: 720px; margin: 0 auto; padding: 0 16px; position: relative; z-index: 1; }
.page-section { padding: 20px 0; }
.fade-in { animation: fadeIn .5s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Glass primitives ---- */
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--shadow-soft);
}
.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 18px;
}
.glass-card.tight { padding: 12px; }
.glass-card:hover { border-color: rgba(var(--accent-rgb), .4); }

/* ---- Top navigation ---- */
.app-nav {
  position: fixed; top: 0; left: 0; right: 0; height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; z-index: 50;
  background: rgba(10, 15, 28, .55);
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
}
.app-nav .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; letter-spacing: .2px; }
.app-nav .brand img { width: 30px; height: 30px; border-radius: 8px; }
.app-nav .brand .en { color: var(--text-0); }
.app-nav .brand .ar { color: var(--accent); font-family: var(--font-arabic); font-size: 1.2rem; }
.app-nav .nav-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--glass-bg); border: 1px solid var(--glass-border);
  color: var(--text-0); transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.icon-btn:hover { border-color: rgba(var(--accent-rgb), .5); transform: translateY(-1px); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 18px; height: 18px; }
.back-btn { display: flex; align-items: center; gap: 8px; font-weight: 600; }

/* ---- Bottom navigation ---- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--bottomnav-h);
  display: flex; z-index: 50;
  background: rgba(10, 15, 28, .65);
  border-top: 1px solid var(--glass-border);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; font-size: .68rem; color: var(--text-2); font-weight: 600;
  padding: 8px 2px; transition: color .15s ease;
}
.bottom-nav a svg { width: 21px; height: 21px; }
.bottom-nav a.active { color: var(--accent); }
.bottom-nav a.active svg { filter: drop-shadow(0 0 6px var(--glow)); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 14px; font-weight: 700; font-size: .95rem;
  border: 1px solid var(--glass-border); background: var(--glass-bg); color: var(--text-0);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  min-height: 44px;
}
.btn:hover { transform: translateY(-1px); border-color: rgba(var(--accent-rgb), .5); }
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1A1200; border: none; box-shadow: 0 6px 20px var(--glow);
}
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: .82rem; min-height: 36px; border-radius: 10px; }
.btn-ghost { background: transparent; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  border-radius: 999px; font-size: .78rem; font-weight: 700;
  background: var(--glass-bg); border: 1px solid var(--glass-border); color: var(--text-1);
}
.chip.active { background: rgba(var(--accent-rgb), .18); border-color: var(--accent); color: var(--accent-2); }

/* ---- Text scale controls ---- */
.text-scale-ctrl { display: flex; align-items: center; gap: 6px; }
.text-scale-ctrl button { font-weight: 800; }

/* ---- Hero (landing) ---- */
.hero { text-align: center; padding: 36px 0 8px; }
.hero .eyebrow { color: var(--accent-2); font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; font-size: .75rem; }
.hero h1 { font-size: 2rem; margin: 10px 0 6px; line-height: 1.2; }
.hero .arabic-hero { font-family: var(--font-arabic); font-size: 2.1rem; color: var(--accent); margin-bottom: 10px; }
.hero p { color: var(--text-1); max-width: 460px; margin: 0 auto; }

/* ---- Module grid (portal + home dashboard) ---- */
.module-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-top: 22px;
}
.module-card {
  border-radius: var(--radius-md); padding: 18px 14px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  transition: transform .2s ease, box-shadow .2s ease;
  position: relative; overflow: hidden;
}
.module-card:hover { transform: translateY(-4px); }
.module-card .icon-wrap {
  width: 52px; height: 52px; border-radius: 16px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, rgba(var(--accent-rgb), .25), rgba(var(--accent-rgb), .05));
  border: 1px solid rgba(var(--accent-rgb), .3);
}
.module-card .icon-wrap svg { width: 26px; height: 26px; color: var(--accent-2); }
.module-card h3 { font-size: .95rem; }
.module-card p { font-size: .74rem; color: var(--text-2); }

/* ---- Countdown ---- */
.countdown-wrap { text-align: center; padding: 22px 10px; }
.countdown-label { color: var(--text-2); font-size: .8rem; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }
.countdown-name { font-size: 1.6rem; font-weight: 800; margin: 6px 0; color: var(--accent-2); }
.countdown-name .ar { font-family: var(--font-arabic); margin-inline-start: 8px; }
.countdown-time { font-size: 2.6rem; font-weight: 800; letter-spacing: 1px; font-variant-numeric: tabular-nums; }
.countdown-time span { color: var(--accent); }
.pulse-ring {
  width: 10px; height: 10px; border-radius: 50%; background: var(--success); display: inline-block;
  box-shadow: 0 0 0 0 rgba(52, 211, 153, .6); animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, .6); }
  70% { box-shadow: 0 0 0 10px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

/* ---- Prayer times list ---- */
.prayer-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.prayer-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-radius: var(--radius-md);
}
.prayer-row.current { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(var(--accent-rgb), .4) inset, 0 8px 24px var(--glow); }
.prayer-row .p-name { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.prayer-row .p-name .ar { font-family: var(--font-arabic); color: var(--text-1); font-weight: 400; }
.prayer-row .p-time { font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .5px; }
.prayer-row .p-icon { width: 30px; height: 30px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: rgba(var(--accent-rgb), .12); }
.prayer-row .p-icon svg { width: 16px; height: 16px; color: var(--accent-2); }

/* ---- Forms ---- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .82rem; color: var(--text-1); margin-bottom: 6px; font-weight: 600; }
.field input[type="text"], .field input[type="search"], .field select {
  width: 100%; padding: 12px 14px; border-radius: 12px; color: var(--text-0);
  background: var(--glass-bg); border: 1px solid var(--glass-border); min-height: 44px;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }
.search-bar { position: relative; }
.search-bar svg { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-2); }
.search-bar input { padding-inline-start: 42px; }

.toggle { position: relative; width: 46px; height: 26px; border-radius: 999px; background: var(--glass-bg); border: 1px solid var(--glass-border); flex-shrink: 0; }
.toggle span { position: absolute; top: 2px; inset-inline-start: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--text-2); transition: all .2s ease; }
.toggle.on { background: rgba(var(--accent-rgb), .35); border-color: var(--accent); }
.toggle.on span { inset-inline-start: calc(100% - 22px); background: var(--accent-2); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--glass-border); }
.toggle-row:last-child { border-bottom: none; }
.toggle-row .t-title { font-weight: 700; font-size: .9rem; }
.toggle-row .t-sub { font-size: .75rem; color: var(--text-2); }

/* ---- Section headers ---- */
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 22px 0 10px; }
.section-title h2 { font-size: 1.05rem; }
.section-title a { font-size: .8rem; color: var(--accent-2); font-weight: 700; }

/* ---- Palette + language pickers (popovers) ---- */
.popover {
  position: absolute; top: calc(var(--nav-h) + 6px); inset-inline-end: 12px;
  width: 220px; border-radius: var(--radius-md); padding: 12px; z-index: 60;
  display: none; flex-direction: column; gap: 10px;
}
.popover.open { display: flex; }
.popover .p-title { font-size: .72rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-2); font-weight: 700; }
.swatch-row { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 34px; height: 34px; border-radius: 10px; border: 2px solid transparent; position: relative;
}
.swatch.selected { border-color: var(--text-0); }
.lang-option {
  display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: 10px;
}
.lang-option.selected { background: rgba(var(--accent-rgb), .16); color: var(--accent-2); font-weight: 700; }

/* ---- Grids: Asmaul Husna / Surah list ---- */
.names-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 16px; }
.name-card { text-align: center; padding: 16px 10px; cursor: pointer; }
.name-card .n-index { font-size: .68rem; color: var(--text-2); font-weight: 700; }
.name-card .n-arabic { font-family: var(--font-arabic); font-size: 1.5rem; color: var(--accent-2); margin: 6px 0; }
.name-card .n-translit { font-weight: 700; font-size: .85rem; }
.name-card .n-meaning { font-size: .72rem; color: var(--text-2); }

.surah-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.surah-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.surah-row .s-num {
  width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: rgba(var(--accent-rgb), .12); color: var(--accent-2); font-weight: 800; font-size: .82rem; flex-shrink: 0;
}
.surah-row .s-info { flex: 1; min-width: 0; }
.surah-row .s-name-en { font-weight: 700; font-size: .92rem; }
.surah-row .s-meta { font-size: .72rem; color: var(--text-2); }
.surah-row .s-name-ar { font-family: var(--font-arabic); font-size: 1.25rem; color: var(--text-0); }

/* ---- Quran reader ---- */
.ayah-block { padding: 18px; border-radius: var(--radius-md); margin-bottom: 12px; scroll-margin-top: calc(var(--nav-h) + 90px); transition: box-shadow .3s ease, border-color .3s ease; }
.ayah-block.playing { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(var(--accent-rgb), .5) inset, 0 10px 28px var(--glow); }
.ayah-block .a-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.ayah-block .a-num { font-size: .72rem; color: var(--text-2); font-weight: 700; }
.ayah-arabic { font-family: var(--font-arabic); font-size: calc(1.7rem * var(--font-scale, 1)); line-height: 2.2; text-align: end; direction: rtl; color: var(--text-0); }
.ayah-translation { margin-top: 10px; font-size: .88rem; color: var(--text-1); }
.play-mini { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: rgba(var(--accent-rgb), .14); color: var(--accent-2); }

.audio-bar {
  position: fixed; bottom: var(--bottomnav-h); left: 0; right: 0; z-index: 45;
  padding: 10px 14px; display: flex; align-items: center; gap: 12px;
  border-top: 1px solid var(--glass-border);
  background: rgba(10, 15, 28, .7); backdrop-filter: blur(20px);
  transform: translateY(120%); transition: transform .25s ease;
}
.audio-bar.show { transform: translateY(0); }
.audio-bar .a-info { flex: 1; min-width: 0; }
.audio-bar .a-title { font-size: .8rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.audio-bar .a-sub { font-size: .68rem; color: var(--text-2); }
.audio-bar .a-controls { display: flex; align-items: center; gap: 8px; }

/* ---- Reader (moulid) ---- */
.reader-toolbar {
  position: sticky; top: var(--nav-h); z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; margin: 0 -16px 14px; border-bottom: 1px solid var(--glass-border);
  background: rgba(10, 15, 28, .5); backdrop-filter: blur(16px);
}
.reader-text { font-family: var(--font-arabic); font-size: calc(1.6rem * var(--font-scale, 1)); line-height: 2.4; text-align: center; direction: rtl; }
.reader-text p { margin-bottom: 18px; }

/* ---- Daily widget ---- */
.daily-card { position: relative; overflow: hidden; }
.daily-card .d-label { font-size: .7rem; text-transform: uppercase; letter-spacing: 1px; color: var(--accent-2); font-weight: 700; }
.daily-card .d-arabic { font-family: var(--font-arabic); font-size: 1.3rem; margin: 8px 0; color: var(--text-0); }
.daily-card .d-text { font-size: .85rem; color: var(--text-1); }
.streak-row { display: flex; gap: 8px; margin-top: 14px; }
.streak-dot {
  flex: 1; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: var(--glass-bg); border: 1px solid var(--glass-border); font-size: .7rem; font-weight: 800; color: var(--text-2);
}
.streak-dot.done { background: rgba(var(--accent-rgb), .2); border-color: var(--accent); color: var(--accent-2); }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: calc(var(--bottomnav-h) + 16px); left: 50%; transform: translateX(-50%) translateY(20px);
  padding: 12px 20px; border-radius: 14px; z-index: 100; font-size: .85rem; font-weight: 600;
  opacity: 0; transition: all .3s ease; pointer-events: none; max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Skeleton loading ---- */
.skeleton { background: linear-gradient(90deg, var(--glass-bg) 25%, var(--glass-bg-strong) 50%, var(--glass-bg) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius-md); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---- Utility ---- */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-2); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-2); }
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 12px; opacity: .5; }

/* ---- Responsive ---- */
@media (min-width: 640px) {
  .module-grid { grid-template-columns: repeat(3, 1fr); }
  .names-grid { grid-template-columns: repeat(3, 1fr); }
  .container { max-width: 760px; }
}
@media (min-width: 900px) {
  .module-grid { grid-template-columns: repeat(4, 1fr); }
  .names-grid { grid-template-columns: repeat(4, 1fr); }
}
