/* ─── Shaadi Tracker styles ─── */

:root {
  --red: #b91c1c;
  --red-2: #dc2626;
  --gold: #d97706;
  --bg: #fdf8f3;
  --surface: #ffffff;
  --surface-2: #f3ede4;
  --text: #1f1918;
  --muted: #6b625f;
  --border: #e8ddcf;
  --primary: #b91c1c;
  --primary-ink: #ffffff;
  --success: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --radius: 14px;
  --radius-sm: 8px;
  --tab-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

:root:not([data-theme="light"]) {
  @media (prefers-color-scheme: dark) {
    --bg: #121010;
    --surface: #1c1917;
    --surface-2: #2a2524;
    --text: #f5f0ea;
    --muted: #a39a94;
    --border: #3a332e;
    --shadow: 0 2px 10px rgba(0,0,0,0.4);
  }
}
:root[data-theme="dark"] {
  --bg: #121010;
  --surface: #1c1917;
  --surface-2: #2a2524;
  --text: #f5f0ea;
  --muted: #a39a94;
  --border: #3a332e;
  --shadow: 0 2px 10px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, "Noto Sans Devanagari", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ─── Overlay / login ─── */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: linear-gradient(135deg, #b91c1c 0%, #d97706 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  padding: 32px 24px;
  border-radius: 20px;
  width: 100%; max-width: 360px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.logo { font-size: 56px; margin-bottom: 8px; }
.brand { margin: 0 0 4px; color: var(--primary); font-size: 24px; }
.muted { color: var(--muted); margin: 4px 0 20px; font-size: 14px; }
.err { color: var(--danger); font-size: 14px; margin-top: 10px; }
#pin {
  width: 100%; padding: 14px; font-size: 24px; text-align: center;
  letter-spacing: 8px; border: 2px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text);
}
#pin:focus { outline: none; border-color: var(--primary); }

/* ─── Buttons ─── */
.btn {
  padding: 12px 18px; border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius-sm); font-size: 15px; color: var(--text);
  cursor: pointer; font-weight: 500;
}
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.ghost   { background: transparent; }
.btn.danger  { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.wide    { width: 100%; margin-top: 14px; padding: 14px; font-size: 16px; }
.btn:active  { transform: translateY(1px); }

.icon-btn {
  width: 40px; height: 40px; border: none; background: transparent;
  color: var(--text); font-size: 20px; border-radius: 10px; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }

/* ─── Topbar ─── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
}
.brand-wrap { display: flex; align-items: center; gap: 8px; }
.logo-mini { font-size: 22px; }
.top-actions { display: flex; gap: 4px; }

/* ─── Main view ─── */
main#view {
  padding: 16px 14px calc(var(--tab-h) + var(--safe-bottom) + 20px);
  min-height: 100vh;
}

/* ─── Tab bar ─── */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: var(--surface); border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: var(--safe-bottom);
}
.tab {
  border: none; background: transparent; padding: 10px 4px;
  display: flex; flex-direction: column; align-items: center;
  gap: 2px; color: var(--muted); font-size: 11px; cursor: pointer;
}
.tab.active { color: var(--primary); }
.tab .ico { font-size: 20px; }
.tab.fab-tab { position: relative; }
.tab .fab {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; margin-top: -18px; box-shadow: var(--shadow);
}

/* ─── Cards & lists ─── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card.compact { padding: 12px; }
.card h3 { margin: 0 0 10px; font-size: 16px; }
.card h2 { margin: 0 0 12px; font-size: 18px; }

.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.col { flex: 1; }
.spacer { flex: 1; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text);
  font-size: 12px; font-weight: 500;
}
.chip.red   { background: #fee2e2; color: #991b1b; }
.chip.green { background: #dcfce7; color: #166534; }
.chip.gold  { background: #fef3c7; color: #92400e; }
.chip.muted { background: var(--surface-2); color: var(--muted); }
:root[data-theme="dark"] .chip.red   { background: #450a0a; color: #fecaca; }
:root[data-theme="dark"] .chip.green { background: #052e16; color: #bbf7d0; }
:root[data-theme="dark"] .chip.gold  { background: #451a03; color: #fed7aa; }

/* ─── Totals grid ─── */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat {
  background: var(--surface); padding: 14px; border-radius: var(--radius);
  border: 1px solid var(--border);
}
.stat .label { font-size: 12px; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.stat .value { font-size: 22px; font-weight: 700; }
.stat.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.stat.primary .label { color: rgba(255,255,255,0.8); }

/* ─── Progress bars ─── */
.bar {
  height: 8px; background: var(--surface-2); border-radius: 4px;
  overflow: hidden; margin-top: 6px;
}
.bar > span { display: block; height: 100%; background: var(--success); border-radius: 4px; }
.bar > span.over { background: var(--danger); }
.bar > span.warn { background: var(--warn); }

/* ─── Items list ─── */
.item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 10px; overflow: hidden;
  display: flex; gap: 12px; padding: 12px;
}
.item .thumb {
  width: 68px; height: 68px; border-radius: 10px; flex: none;
  background: var(--surface-2); display: flex; align-items: center; justify-content: center;
  font-size: 28px; overflow: hidden;
}
.item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.item .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.item .title { font-weight: 600; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.item .meta-row-2 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.item .cost { font-weight: 700; font-size: 15px; }
.item .pay-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-top: 2px;
}
.item .pay-amounts { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.item .btn-pay {
  background: var(--primary); color: #fff; border: none;
  border-radius: 999px; padding: 5px 12px; font-size: 12px;
  font-weight: 600; cursor: pointer; white-space: nowrap;
}
.item .btn-pay:active { transform: translateY(1px); }

/* Payer dots (initials) */
.payer-strip { display: flex; gap: -4px; margin-left: 4px; }
.payer-strip .payer-dot {
  width: 22px; height: 22px; border-radius: 50%; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; margin-left: -6px;
  border: 2px solid var(--surface); text-transform: uppercase;
}
.payer-strip .payer-dot:first-child { margin-left: 0; }

/* ─── Forms ─── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid .wide { grid-column: span 2; }
label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; font-weight: 500; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-size: 15px; font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); background: var(--surface);
}
textarea { resize: vertical; min-height: 70px; }

/* ─── Image gallery in detail ─── */
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.gallery .ph {
  aspect-ratio: 1; background: var(--surface-2); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative; cursor: pointer;
}
.gallery .ph img { width: 100%; height: 100%; object-fit: cover; }
.gallery .ph .kind {
  position: absolute; bottom: 4px; left: 4px;
  background: rgba(0,0,0,0.6); color: #fff;
  font-size: 10px; padding: 2px 6px; border-radius: 4px;
}
.gallery .ph .del {
  position: absolute; top: 4px; right: 4px;
  background: rgba(0,0,0,0.6); color: #fff; border: none;
  width: 22px; height: 22px; border-radius: 50%; cursor: pointer;
  font-size: 14px; line-height: 1;
}
.gallery .add {
  aspect-ratio: 1; border: 2px dashed var(--border); border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--muted); cursor: pointer; font-size: 11px; gap: 4px;
}
.gallery .add span { font-size: 26px; }

/* ─── Sheet / modal ─── */
.sheet-bg {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,0.5);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn 0.2s;
}
.sheet {
  background: var(--surface); width: 100%; max-width: 540px;
  max-height: 92vh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(32px + var(--safe-bottom));
  animation: slideUp 0.25s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet .handle {
  width: 40px; height: 4px; background: var(--border); border-radius: 2px;
  margin: 0 auto 14px;
}
.sheet h2 { margin: 0 0 16px; font-size: 20px; }

/* ─── Calendar ─── */
.cal-group { margin-bottom: 20px; }
.cal-group h3 {
  margin: 0 0 8px; font-size: 13px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.cal-item {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 6px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.cal-item.overdue { border-left-color: var(--danger); background: #fef2f2; }
:root[data-theme="dark"] .cal-item.overdue { background: #2a1515; }
.cal-item.done { opacity: 0.55; }
.cal-item .date { font-size: 11px; color: var(--muted); }
.cal-item input[type=checkbox] { width: auto; }

/* ─── Payments list ─── */
.pay-row {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 6px;
  display: flex; justify-content: space-between; align-items: center;
}
.pay-amt { font-weight: 700; color: var(--success); }
.pay-amt.red { color: var(--danger); }

/* ─── Toast / offline ─── */
.toast {
  position: fixed; bottom: calc(var(--tab-h) + var(--safe-bottom) + 12px);
  left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-size: 14px;
  z-index: 60; box-shadow: var(--shadow);
}
.offline-banner {
  position: fixed; top: 0; left: 0; right: 0;
  background: var(--warn); color: #fff; text-align: center;
  padding: 6px; font-size: 13px; z-index: 11;
}

/* ─── Filters bar ─── */
.filters {
  display: flex; gap: 6px; overflow-x: auto;
  padding-bottom: 8px; margin-bottom: 10px;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.filter-chip {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 13px;
  white-space: nowrap; cursor: pointer;
}
.filter-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ─── Settings sections ─── */
.settings-group { margin-bottom: 24px; }
.settings-group h3 { margin: 0 0 10px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* ─── Hindi font tweaks ─── */
html[lang="hi"] body { font-family: "Noto Sans Devanagari", -apple-system, sans-serif; }
html[lang="hi"] .brand, html[lang="hi"] .card h2, html[lang="hi"] .card h3 { line-height: 1.4; }

/* ─── Empty state ─── */
.empty {
  text-align: center; padding: 40px 20px; color: var(--muted);
}
.empty .big { font-size: 48px; margin-bottom: 8px; }
