/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary: #0c0f1a;
  --bg-secondary: #111525;
  --bg-card: #181d30;
  --bg-card-hover: #1e2438;
  --border: #252c44;
  --border-light: #2e3750;
  --gold: #d4a843;
  --gold-dim: #8a6e2f;
  --gold-glow: rgba(212, 168, 67, 0.15);
  --gold-light: #f0c96a;
  --text-primary: #e8dcc8;
  --text-secondary: #a09078;
  --text-muted: #555060;
  --green: #3d7a56;
  --green-light: #4da06e;
  --green-glow: rgba(61, 122, 86, 0.2);
  --red: #8c3a30;
  --font: 'Noto Sans Bengali', sans-serif;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Islamic geometric pattern background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(212,168,67,0.04) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(61,122,86,0.04) 0%, transparent 50%),
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23d4a843' stroke-width='0.3' opacity='0.15'%3E%3Cpolygon points='30,5 55,20 55,40 30,55 5,40 5,20'/%3E%3Cpolygon points='30,15 45,22.5 45,37.5 30,45 15,37.5 15,22.5'/%3E%3Cline x1='30' y1='5' x2='30' y2='15'/%3E%3Cline x1='55' y1='20' x2='45' y2='22.5'/%3E%3Cline x1='55' y1='40' x2='45' y2='37.5'/%3E%3Cline x1='30' y1='55' x2='30' y2='45'/%3E%3Cline x1='5' y1='40' x2='15' y2='37.5'/%3E%3Cline x1='5' y1='20' x2='15' y2='22.5'/%3E%3C/g%3E%3C/svg%3E");
  background-size: auto, auto, 60px 60px;
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
}

/* ===== HEADER ===== */
.header {
  background: linear-gradient(135deg, #0f1422 0%, #131828 100%);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 20px rgba(0,0,0,0.5);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.header-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.02em;
  line-height: 1;
}

.app-subtitle {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.streak-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(212,168,67,0.1);
  border: 1px solid var(--gold-dim);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gold);
}

.streak-icon { font-size: 0.9rem; }

/* Progress bar */
.progress-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
}

.progress-bar-track {
  flex: 1;
  height: 5px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  border-radius: 99px;
  transition: width 0.5s cubic-bezier(0.4,0,0.2,1);
  width: 0%;
}

.progress-label {
  font-size: 0.7rem;
  color: var(--gold);
  font-weight: 600;
  min-width: 32px;
  text-align: right;
}

/* ===== TAB NAV ===== */
.tab-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 81px;
  z-index: 99;
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.65rem;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
  border-bottom: 2px solid transparent;
  position: relative;
}

.tab-btn svg { transition: stroke 0.2s; }

.tab-btn.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
  background: rgba(212,168,67,0.05);
}

.tab-btn:hover:not(.active) {
  color: var(--text-secondary);
  background: rgba(255,255,255,0.03);
}

/* ===== MAIN CONTENT ===== */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 100px;
  overscroll-behavior: contain;
}

/* ===== SECTION CARDS ===== */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
  transition: border-color 0.3s;
}

.section-card.all-done {
  border-color: var(--green);
  box-shadow: 0 0 0 1px rgba(61,122,86,0.2);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  background: rgba(255,255,255,0.02);
}

.section-icon { font-size: 1rem; }

.section-title {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.section-progress {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.section-progress.done { color: var(--green-light); }

.section-chevron {
  color: var(--text-muted);
  transition: transform 0.25s;
  font-size: 0.75rem;
}
.section-card.collapsed .section-chevron { transform: rotate(-90deg); }
.section-card.collapsed .section-body { display: none; }

/* ===== HABIT ITEMS ===== */
.habit-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid rgba(37,44,68,0.6);
  transition: background 0.15s;
  cursor: pointer;
}

.habit-item:last-child { border-bottom: none; }
.habit-item:hover { background: rgba(255,255,255,0.025); }
.habit-item:active { background: rgba(255,255,255,0.05); }

.habit-icon {
  font-size: 1.1rem;
  min-width: 24px;
  text-align: center;
}

.habit-label {
  flex: 1;
  font-size: 0.88rem;
  color: var(--text-primary);
  font-weight: 400;
  line-height: 1.3;
}

.habit-item.checked .habit-label {
  color: var(--text-secondary);
  text-decoration: line-through;
  text-decoration-color: var(--green-light);
}

/* Custom Checkbox */
.custom-checkbox {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border-light);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
  background: transparent;
}

.habit-item.checked .custom-checkbox {
  background: var(--green);
  border-color: var(--green);
}

.check-icon {
  opacity: 0;
  transform: scale(0);
  transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
  color: white;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.habit-item.checked .check-icon {
  opacity: 1;
  transform: scale(1);
}

/* ===== NUMERIC INPUT ITEMS ===== */
.numeric-item {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(37,44,68,0.6);
}

.numeric-item:last-child { border-bottom: none; }

.numeric-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.numeric-icon { font-size: 1.1rem; min-width: 24px; text-align: center; }

.numeric-label {
  flex: 1;
  font-size: 0.88rem;
  color: var(--text-primary);
  font-weight: 400;
}

.numeric-goal {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.numeric-control {
  display: flex;
  align-items: center;
  gap: 0;
}

.num-btn {
  width: 38px;
  height: 38px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
  flex-shrink: 0;
}

.num-btn:first-child { border-radius: 8px 0 0 8px; }
.num-btn:last-child { border-radius: 0 8px 8px 0; }
.num-btn:hover { background: var(--border-light); color: var(--gold); }
.num-btn:active { background: var(--gold-dim); }

.num-input {
  width: 64px;
  height: 38px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-left: none;
  border-right: none;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

.num-input:focus { border-color: var(--gold-dim); }
.num-input::placeholder { color: var(--text-muted); font-size: 0.75rem; }

/* Progress ring / bar under numeric */
.numeric-progress-wrap {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.numeric-bar-track {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.numeric-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.4s ease;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  width: 0%;
}

.numeric-bar-fill.over { background: linear-gradient(90deg, var(--green), var(--green-light)); }

.numeric-val-label {
  font-size: 0.68rem;
  color: var(--text-secondary);
  min-width: 72px;
  text-align: right;
}

.numeric-val-label.met { color: var(--green-light); }

/* ===== WEEKLY / MONTHLY TAB ===== */
.page-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  padding: 0 2px;
}

/* ===== STATS TAB ===== */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-card.wide {
  grid-column: span 2;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
}

.stat-value.green { color: var(--green-light); }
.stat-value.red { color: #c46a5a; }

.stat-sub {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.stat-bar-wrap {
  margin-top: 4px;
}

.stat-bar-track {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 6px;
}

.stat-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  transition: width 0.6s ease;
}

.stat-bar-fill.green { background: linear-gradient(90deg, var(--green), var(--green-light)); }

/* Monthly checklist in stats */
.month-summary-title {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 14px 0 8px;
}

/* ===== DATE NAVIGATOR ===== */
.date-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 98;
}

.date-nav-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.date-nav-btn:hover { background: var(--border); color: var(--gold); border-color: var(--gold-dim); }
.date-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.date-nav-label {
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 500;
}

/* ===== DIVIDER ===== */
.divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state-text { font-size: 0.88rem; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card);
  border: 1px solid var(--green);
  color: var(--green-light);
  padding: 10px 20px;
  border-radius: 99px;
  font-size: 0.82rem;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s;
  z-index: 999;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 99px; }

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-card {
  animation: fadeInUp 0.3s ease backwards;
}

.section-card:nth-child(1) { animation-delay: 0.02s; }
.section-card:nth-child(2) { animation-delay: 0.06s; }
.section-card:nth-child(3) { animation-delay: 0.1s; }
.section-card:nth-child(4) { animation-delay: 0.14s; }
.section-card:nth-child(5) { animation-delay: 0.18s; }
.section-card:nth-child(6) { animation-delay: 0.22s; }
.section-card:nth-child(7) { animation-delay: 0.26s; }

/* ===== RESPONSIVE ===== */
@media (max-width: 360px) {
  .app-name { font-size: 1.25rem; }
  .tab-btn span { font-size: 0.6rem; }
  .habit-label { font-size: 0.82rem; }
}
