/* ============================================================
   TestPulse14 — style.css
   Pure CSS3. Theme colors/radii are driven by CSS custom
   properties that js/config.js rewrites at runtime from the
   Supabase `site_settings` row (Admin Panel CMS).
   ============================================================ */

:root {
  --primary-color: #4f46e5;
  --secondary-color: #06b6d4;
  --accent-color: #f59e0b;
  --bg-color: #f4f6fb;
  --card-surface: #ffffff;
  --text-color: #0f172a;
  --muted-color: #64748b;
  --border-color: rgba(15, 23, 42, .10);
  --danger-color: #ef4444;
  --success-color: #10b981;
  --card-radius: 18px;
  --btn-radius: 12px;
  --glass-blur: 14px;
  --glass-alpha: .72;
  --font-scale: 1;
  --shadow-1: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 14px rgba(15, 23, 42, .06);
  --shadow-2: 0 10px 40px rgba(15, 23, 42, .14);
  --topbar-h: 60px;
  --bottomnav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

html[data-theme="dark"] {
  --bg-color: #0b1020;
  --card-surface: #141b2e;
  --text-color: #e7ecf5;
  --muted-color: #93a0b4;
  --border-color: rgba(231, 236, 245, .12);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .35), 0 4px 14px rgba(0, 0, 0, .35);
  --shadow-2: 0 10px 40px rgba(0, 0, 0, .5);
}

/* ---------- Base & fonts (web fonts only, never system-ui) ---------- */
html { overflow-x: hidden; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  overflow-x: hidden;
  margin: 0;
  background: var(--bg-color);
  color: var(--text-color);
  font-family: 'Poppins', 'Baloo Da 2', sans-serif;
  font-size: calc(1rem * var(--font-scale));
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
html[lang="bn"] body,
body.bn { font-family: 'Baloo Da 2', 'Anek Bangla', 'Poppins', sans-serif; }

h1, h2, h3, h4 { font-family: 'Poppins', 'Anek Bangla', sans-serif; margin: 0 0 .5em; line-height: 1.25; }
html[lang="bn"] h1, html[lang="bn"] h2, html[lang="bn"] h3, html[lang="bn"] h4,
body.bn h1, body.bn h2, body.bn h3, body.bn h4 { font-family: 'Anek Bangla', 'Baloo Da 2', sans-serif; }

/* Numbers, timers, counters, day badges — digit "1" stays unmistakable */
.num-font, .num, .timer, .counter, .points-pill, .day-badge, .stat-value {
  font-family: 'IBM Plex Sans', 'Baloo Da 2', monospace !important;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: .01em;
}

::selection { background: var(--primary-color); color: #fff; }
img { max-width: 100%; }
a { color: var(--primary-color); }

/* ---------- Fluid type scale ---------- */
.fs-xs  { font-size: clamp(.66rem, 1.9vw, .78rem); }
.fs-sm  { font-size: clamp(.72rem, 2.1vw, .85rem); }
.fs-md  { font-size: clamp(.8rem, 2.4vw, .95rem); }
.fs-lg  { font-size: clamp(.95rem, 2.9vw, 1.12rem); }
.fs-xl  { font-size: clamp(1.15rem, 3.6vw, 1.5rem); }
.fs-2xl { font-size: clamp(1.45rem, 4.6vw, 2.1rem); }
.fs-hero{ font-size: clamp(1.7rem, 6vw, 3.4rem); }

/* ---------- CRITICAL single-line rule: buttons/tabs/badges/nav ---------- */
.btn, .tab, .badge, .chip, .nav-item, .pill, .bottomnav a, .sidebar a, .form-label {
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45em;
  user-select: none;
  -webkit-user-select: none;
  max-width: 100%;
}

.btn {
  font-size: clamp(.72rem, 2.2vw, .95rem);
  padding: clamp(.42rem, 1.5vw, .72rem) clamp(.7rem, 2.5vw, 1.25rem);
  border-radius: var(--btn-radius);
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .12s ease, filter .15s ease, box-shadow .15s ease;
  text-decoration: none;
  line-height: 1.2;
}
.btn:active { transform: scale(.95); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary-color); color: #fff; box-shadow: var(--shadow-1); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-secondary { background: var(--secondary-color); color: #fff; }
.btn-accent { background: var(--accent-color); color: #1c1400; }
.btn-ghost { background: transparent; border-color: var(--border-color); color: var(--text-color); }
.btn-ghost:hover:not(:disabled) { background: rgba(127,127,127,.08); }
.btn-danger { background: var(--danger-color); color: #fff; }
.btn-success { background: var(--success-color); color: #fff; }
.btn-lg { font-size: clamp(.85rem, 2.8vw, 1.05rem); padding: clamp(.6rem, 2vw, .9rem) clamp(1rem, 3.5vw, 1.7rem); }
.btn-block { width: 100%; }

.badge, .chip, .pill {
  font-size: clamp(.6rem, 1.8vw, .74rem);
  padding: clamp(.16rem, .7vw, .3rem) clamp(.5rem, 1.8vw, .8rem);
  border-radius: 999px;
  font-weight: 600;
  background: color-mix(in srgb, var(--primary-color) 14%, transparent);
  color: var(--primary-color);
}
.badge-accent { background: color-mix(in srgb, var(--accent-color) 18%, transparent); color: var(--accent-color); }
.badge-success { background: color-mix(in srgb, var(--success-color) 16%, transparent); color: var(--success-color); }
.badge-danger { background: color-mix(in srgb, var(--danger-color) 15%, transparent); color: var(--danger-color); }
.badge-muted { background: rgba(127,127,127,.14); color: var(--muted-color); }

/* ---------- Cards & surfaces ---------- */
.card {
  background: var(--card-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-1);
  padding: clamp(.85rem, 3vw, 1.35rem);
}
.card-title {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: clamp(.92rem, 2.8vw, 1.1rem); font-weight: 700;
}
.glass {
  background: color-mix(in srgb, var(--card-surface) calc(var(--glass-alpha) * 100%), transparent);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
}

/* ---------- Announcement top bar ---------- */
#annbar {
  display: none; align-items: center; justify-content: center; gap: .5rem;
  padding: .45rem 1rem; font-size: clamp(.68rem, 2vw, .82rem); font-weight: 600;
  background: var(--primary-color); color: #fff; text-align: center;
}
#annbar.show { display: flex; }

/* ---------- Sticky app top bar ---------- */
#topbar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: .6rem;
  min-height: var(--topbar-h);
  padding: .4rem clamp(.7rem, 3vw, 1.4rem);
  padding-top: calc(.4rem + var(--safe-t));
  border-bottom: 1px solid var(--border-color);
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 800; text-decoration: none; color: var(--text-color); }
.brand .brand-name { font-size: clamp(.95rem, 3vw, 1.2rem); white-space: nowrap; }
.brand img, .brand .logo-fallback {
  width: clamp(28px, 8vw, 38px); height: clamp(28px, 8vw, 38px); border-radius: 10px; object-fit: cover;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)); color: #fff; font-weight: 800;
}
.points-pill {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: clamp(.62rem, 1.9vw, .76rem); font-weight: 700;
  padding: .22rem .6rem; border-radius: 999px;
  background: color-mix(in srgb, var(--primary-color) 12%, transparent); color: var(--primary-color);
  white-space: nowrap;
}
.points-pill.pending { background: color-mix(in srgb, var(--accent-color) 16%, transparent); color: var(--accent-color); }
.lang-toggle {
  font-size: clamp(.62rem, 1.9vw, .76rem); font-weight: 700;
  border: 1px solid var(--border-color); border-radius: 999px;
  padding: .22rem .55rem; background: transparent; color: var(--text-color); cursor: pointer;
  white-space: nowrap; user-select: none;
}
.avatar { width: clamp(30px, 8vw, 40px); height: clamp(30px, 8vw, 40px); border-radius: 50%; object-fit: cover; border: 2px solid var(--primary-color); cursor: pointer; }

/* ---------- Native bottom navigation (mobile app shell) ---------- */
#bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  display: flex; align-items: stretch; justify-content: space-around;
  padding: .3rem .3rem calc(.3rem + var(--safe-b));
  border-top: 1px solid var(--border-color);
}
#bottomnav a {
  flex: 1 1 0; min-width: 0;
  flex-direction: column; gap: .12rem;
  padding: .3rem .1rem;
  font-size: clamp(.56rem, 1.7vw, .72rem); font-weight: 600;
  color: var(--muted-color); text-decoration: none; border-radius: 14px;
  transition: color .15s ease;
}
#bottomnav a svg, #bottomnav a i { width: clamp(19px, 5.6vw, 24px); height: clamp(19px, 5.6vw, 24px); }
#bottomnav a .ind {
  padding: .1rem .55rem; border-radius: 999px; transition: background .15s ease;
}
#bottomnav a.active { color: var(--primary-color); }
#bottomnav a.active .ind { background: color-mix(in srgb, var(--primary-color) 15%, transparent); }

/* ---------- Desktop sidebar (SaaS dashboard) ---------- */
#sidebar {
  display: none; position: fixed; top: 0; bottom: 0; left: 0; z-index: 65;
  width: 250px; flex-direction: column; gap: .2rem;
  padding: 1rem .8rem; border-right: 1px solid var(--border-color);
  background: var(--card-surface); overflow-y: auto;
}
#sidebar a {
  justify-content: flex-start; font-size: clamp(.8rem, 1vw, .92rem); font-weight: 600;
  padding: .6rem .8rem; border-radius: 12px; color: var(--muted-color); text-decoration: none;
}
#sidebar a svg, #sidebar a i { width: 19px; height: 19px; }
#sidebar a.active { background: color-mix(in srgb, var(--primary-color) 13%, transparent); color: var(--primary-color); }

/* ---------- Layout ---------- */
.page-wrap { padding-bottom: calc(var(--bottomnav-h) + var(--safe-b) + 1.2rem); }
@media (min-width: 1024px) {
  #bottomnav { display: none; }
  #sidebar { display: flex; }
  .with-sidebar { margin-left: 250px; }
  .page-wrap { padding-bottom: 2rem; }
}
.container { width: min(100% - clamp(1rem, 4vw, 3rem), 1200px); margin-inline: auto; }
.container-sm { width: min(100% - clamp(1rem, 4vw, 2rem), 720px); margin-inline: auto; }

.grid-fluid {
  display: grid; gap: clamp(.7rem, 2.4vw, 1.15rem);
  grid-template-columns: repeat(auto-fit, minmax(clamp(240px, 100%, 320px), 1fr));
}

/* ---------- Tabs (dashboard sections) ---------- */
.seg { display: flex; gap: .35rem; padding: .28rem; border-radius: 999px; background: rgba(127,127,127,.10); overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg .tab {
  flex: 1 0 auto; font-size: clamp(.62rem, 2vw, .8rem); font-weight: 700;
  padding: clamp(.34rem, 1.3vw, .55rem) clamp(.6rem, 2.2vw, 1.1rem);
  border-radius: 999px; color: var(--muted-color); cursor: pointer; border: none; background: transparent;
}
.seg .tab.active { background: var(--card-surface); color: var(--primary-color); box-shadow: var(--shadow-1); }

/* ---------- Forms ---------- */
.form-label { font-size: clamp(.68rem, 2vw, .8rem); font-weight: 700; color: var(--muted-color); justify-content: flex-start; margin-bottom: .25rem; }
.input, .select, .textarea {
  width: 100%; box-sizing: border-box;
  font-family: inherit; font-size: clamp(.78rem, 2.3vw, .92rem);
  padding: clamp(.5rem, 1.8vw, .7rem) clamp(.6rem, 2vw, .9rem);
  border-radius: 12px; border: 1.5px solid var(--border-color);
  background: var(--bg-color); color: var(--text-color); outline: none;
  transition: border-color .15s ease;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary-color); }
.textarea { min-height: 90px; resize: vertical; white-space: normal; }
.field { margin-bottom: .9rem; }
.hint { font-size: clamp(.62rem, 1.9vw, .74rem); color: var(--muted-color); margin-top: .2rem; }
.check-row { display: flex; align-items: flex-start; gap: .55rem; font-size: clamp(.72rem, 2.2vw, .86rem); }
.check-row input { margin-top: .2rem; accent-color: var(--primary-color); width: 17px; height: 17px; }

/* ---------- Progress / timers ---------- */
.progress { height: 10px; border-radius: 999px; background: rgba(127,127,127,.18); overflow: hidden; }
.progress > div { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary-color), var(--secondary-color)); transition: width .4s ease; }
.progress.accent > div { background: linear-gradient(90deg, var(--accent-color), #f97316); }
.timer-big { font-size: clamp(1.9rem, 8vw, 2.8rem); font-weight: 700; }
.day-badge {
  font-weight: 700; font-size: clamp(.66rem, 2vw, .8rem);
  padding: .2rem .6rem; border-radius: 999px;
  background: color-mix(in srgb, var(--secondary-color) 15%, transparent); color: var(--secondary-color);
  white-space: nowrap;
}

/* ---------- Bottom-sheet modal (native app feel) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(2, 6, 23, .55);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .18s ease both;
}
.sheet {
  width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto;
  background: var(--card-surface); color: var(--text-color);
  border-radius: 24px 24px 0 0;
  padding: clamp(1rem, 4vw, 1.6rem) clamp(1rem, 4vw, 1.6rem) calc(1.2rem + var(--safe-b));
  animation: slideUp .28s cubic-bezier(.2, .9, .3, 1) both;
}
.sheet-grab { width: 42px; height: 5px; border-radius: 999px; background: rgba(127,127,127,.35); margin: 0 auto .8rem; }
@media (min-width: 768px) {
  .sheet-backdrop { align-items: center; padding: 1.5rem; }
  .sheet { border-radius: var(--card-radius); animation: popIn .2s ease both; }
}
@keyframes slideUp { from { transform: translateY(60%); opacity: .4; } to { transform: translateY(0); opacity: 1; } }
@keyframes popIn { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Toasts ---------- */
#toast-root { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--bottomnav-h) + var(--safe-b) + 14px); z-index: 120; display: flex; flex-direction: column; gap: .5rem; width: min(92vw, 420px); }
@media (min-width: 1024px) { #toast-root { bottom: 22px; } }
.toast {
  display: flex; align-items: center; gap: .6rem;
  background: var(--card-surface); color: var(--text-color);
  border: 1px solid var(--border-color); border-left: 4px solid var(--primary-color);
  border-radius: 14px; padding: .7rem .9rem; font-size: clamp(.72rem, 2.2vw, .86rem); font-weight: 600;
  box-shadow: var(--shadow-2); animation: slideUp .25s ease both;
}
.toast.success { border-left-color: var(--success-color); }
.toast.error { border-left-color: var(--danger-color); }
.toast.warn { border-left-color: var(--accent-color); }

/* ---------- Misc ---------- */
.skeleton { border-radius: 12px; background: linear-gradient(90deg, rgba(127,127,127,.12) 25%, rgba(127,127,127,.22) 50%, rgba(127,127,127,.12) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; min-height: 84px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.empty-state { text-align: center; padding: 2.2rem 1rem; color: var(--muted-color); }
.empty-state svg, .empty-state i { width: 42px; height: 42px; opacity: .45; }
.muted { color: var(--muted-color); }
.hidden { display: none !important; }
.center { display: flex; align-items: center; justify-content: center; }
.between { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.icon-btn { background: transparent; border: none; cursor: pointer; color: var(--muted-color); padding: .35rem; border-radius: 10px; display: inline-flex; }
.icon-btn:hover { background: rgba(127,127,127,.12); color: var(--text-color); }
.icon-btn svg, .icon-btn i { width: 20px; height: 20px; }
.app-icon { width: clamp(46px, 12vw, 58px); height: clamp(46px, 12vw, 58px); border-radius: 15px; object-fit: cover; border: 1px solid var(--border-color); background: rgba(127,127,127,.12); }
.table-wrap { overflow-x: auto; border-radius: var(--card-radius); border: 1px solid var(--border-color); background: var(--card-surface); }
table.dt { width: 100%; border-collapse: collapse; font-size: clamp(.68rem, 1.9vw, .82rem); min-width: 640px; }
table.dt th { text-align: left; padding: .6rem .7rem; font-weight: 700; color: var(--muted-color); border-bottom: 1.5px solid var(--border-color); white-space: nowrap; background: rgba(127,127,127,.05); }
table.dt td { padding: .55rem .7rem; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
table.dt tr:last-child td { border-bottom: none; }
.mono { font-family: 'IBM Plex Sans', monospace; font-size: .92em; }
.warn-banner { background: color-mix(in srgb, var(--danger-color) 12%, var(--card-surface)); border: 1px solid color-mix(in srgb, var(--danger-color) 45%, transparent); color: var(--text-color); border-radius: 14px; padding: .9rem 1rem; font-weight: 600; }
.pulse-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--success-color); box-shadow: 0 0 0 0 color-mix(in srgb, var(--success-color) 70%, transparent); animation: pulse 1.6s infinite; display: inline-block; }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
footer.site-footer { padding: 2.2rem 1rem calc(1.4rem + var(--safe-b)); border-top: 1px solid var(--border-color); margin-top: 2.5rem; }
html[lang="bn"] footer.site-footer, body.bn footer.site-footer { font-family: 'Anek Bangla', 'Baloo Da 2', sans-serif; }

/* radius presets switched by Admin (sharp / rounded / pill) */
html[data-radius="sharp"] { --card-radius: 4px; --btn-radius: 4px; }
html[data-radius="rounded"] { --card-radius: 18px; --btn-radius: 12px; }
html[data-radius="pill"] { --card-radius: 24px; --btn-radius: 999px; }

/* ---------- v3: feed tools ---------- */
.feed-tools { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.feed-tools .input { flex: 1; min-width: 180px; }
.feed-tools .select { flex: 0 0 auto; }
.feed-count { margin: 0 0 .6rem; }

/* ---------- v3: ledger ---------- */
.ledger-delta { font-weight: 700; white-space: nowrap; }
.ledger-delta.pos { color: var(--success-color); }
.ledger-delta.neg { color: var(--danger-color); }
.kind-chip { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 600; background: rgba(127,127,127,.12); white-space: nowrap; }

/* ---------- v3: leaderboard ---------- */
.lb-row { display: grid; grid-template-columns: 3rem 1fr auto; gap: .6rem; align-items: center; padding: .65rem .8rem; }
.lb-rank { font-weight: 800; font-size: 1.05rem; text-align: center; }
.lb-rank.medal-1 { color: #d4a017; } .lb-rank.medal-2 { color: #9aa4b2; } .lb-rank.medal-3 { color: #b06a3b; }
.lb-row.me { outline: 2px solid var(--primary-color); border-radius: 12px; }
.lb-avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border-color); }
.lb-fallback { width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; background: color-mix(in srgb, var(--primary-color) 18%, transparent); flex-shrink: 0; }

/* ---------- v3: legal / faq prose ---------- */
.legal-body { max-width: 76ch; }
.legal-body h2 { font-size: clamp(1rem, 3vw, 1.15rem); font-weight: 700; margin: 1.5rem 0 .5rem; }
.legal-body p, .legal-body li { font-size: clamp(.85rem, 2.4vw, .95rem); line-height: 1.65; color: var(--text-color); }
.legal-body ul { padding-left: 1.3rem; margin: .5rem 0; }
.legal-body li { margin: .3rem 0; }
.legal-updated { font-size: .78rem; color: var(--muted-color); margin-bottom: 1.2rem; }
.faq-item { border: 1px solid var(--border-color); border-radius: 14px; margin-bottom: .7rem; overflow: hidden; background: var(--card-surface); }
.faq-item summary { padding: .85rem 1rem; font-weight: 700; cursor: pointer; list-style: none; display: flex; gap: .5rem; align-items: center; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: '+'; margin-left: auto; font-weight: 800; color: var(--muted-color); font-size: 1.1rem; }
.faq-item[open] summary::after { content: '\2212'; }
.faq-item .faq-a { padding: 0 1rem .9rem; color: var(--muted-color); font-size: clamp(.85rem, 2.4vw, .95rem); line-height: 1.6; }
html[lang="bn"] .legal-body p, html[lang="bn"] .legal-body li, html[lang="bn"] .faq-item .faq-a { line-height: 1.85; }

/* ---------- v3: not-found ---------- */
.nf-wrap { text-align: center; padding: clamp(3rem, 12vw, 6rem) 1rem; }
.nf-code { font-size: clamp(4rem, 18vw, 7rem); font-weight: 800; line-height: 1; color: color-mix(in srgb, var(--primary-color) 75%, var(--text-color)); }

/* ---------- v3: admin analytics charts ---------- */
.chart-card { position: relative; }
.tp-chart { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: .5rem; font-size: .75rem; color: var(--muted-color); }
.chart-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.chart-legend i.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.app-action-btns { display: flex; gap: .3rem; flex-wrap: wrap; }
.pending-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-color); display: inline-block; animation: pulse 1.6s infinite; }
