/* ═══════════════════════════════════════════════════════════════════════════
 * style.css — Dhimahi design system
 * ───────────────────────────────────────────────────────────────────────────
 * One file. No preprocessor. No utility framework. Every shared visual
 * concern lives in here so a designer (or an agent) can rebrand the entire
 * app by editing the :root tokens at the top.
 *
 * SECTIONS (in order below)
 *   :root            CSS variables — colors, radius, shadow, max-width
 *   resets           box-sizing, margins, font stack, type scale, links
 *   nav.top          Sticky top nav + brand wordmark styling (.dn = Devanagari)
 *   main / layout    Centered max-width container + section spacing
 *   .row / .gap-*    Simple flex helpers
 *   .card            The single most-used component. Hover variant lifts.
 *   .btn             Buttons: default + .secondary + .ghost + .danger + .small
 *   form / label     Stacked label+input with focus ring
 *   table            Sortable-looking tables (no JS sort yet)
 *   .pill            Tiny status badges inside tables
 *   .tabs            The admin-page tab strip
 *   #toast           Bottom-right notification, JS-controlled
 *   .hero            Landing-page hero with gradient background
 *   helpers          .muted, .flex.between, .kv, .empty, .divider, etc.
 *
 * BRAND
 *   Primary indigo (#6366f1) → violet gradient (#8b5cf6) in the hero.
 *   Devanagari script uses Noto Sans Devanagari → falls back to Mangal
 *   (Windows) and Sanskrit Text (Mac) before the system serif. The brand
 *   mark is half-and-half: <span class="dn">धी</span>mahi.
 *
 * RESPONSIVE
 *   Currently minimal — .row uses flex-wrap so cards stack on narrow screens.
 *   Mobile-specific tweaks needed before launch; budget ~1 day for polish.
 * ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* Greys (warm) — paper-ish background, white surface, hairline borders */
  --bg:        #fafaf9;   /* page background — slightly warm off-white */
  --surface:   #ffffff;   /* cards, nav, modals */
  --surface-2: #f4f4f5;   /* hover state, table-header bg, secondary surface */
  --border:    #e4e4e7;   /* 1px hairlines */

  /* Text — three levels of emphasis */
  --text:    #18181b;     /* headings, body */
  --text-2:  #52525b;     /* secondary text, labels, inactive nav links */
  --text-3:  #a1a1aa;     /* tertiary text, empty states, "—" placeholders */

  /* Brand — indigo */
  --primary:   #6366f1;   /* links, buttons, brand mark Devanagari */
  --primary-d: #4f46e5;   /* hover */
  --primary-l: #eef2ff;   /* very light tint — focus ring, nav active bg */

  /* Semantic colors — pills + buttons */
  --success: #10b981;
  --warn:    #f59e0b;
  --danger:  #ef4444;

  /* Shape */
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04);  /* layered soft shadow */
  --max:    1100px;       /* page content max-width */
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 2.2rem; font-weight: 700; }
h2 { font-size: 1.5rem; font-weight: 600; }
h3 { font-size: 1.15rem; font-weight: 600; }
p  { margin: 0 0 .8em; color: var(--text-2); }

code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}
pre {
  background: var(--surface-2);
  padding: 12px 14px;
  border-radius: 8px;
  overflow-x: auto;
}

/* ── Top nav ───────────────────────────────────────────────────────────── */
nav.top {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
nav.top .inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
/* Brand wordmark — half-and-half (Devanagari "धी" + Latin "mahi").
 * The 1px gap keeps both halves visually joined — it reads as ONE word, not two tokens.
 * Devanagari renders smaller-per-em than Latin, so the .dn span gets a bump
 * (1.5rem vs 1.2rem) to balance the optical sizes. See memory/project_brand_wordmark.md. */
nav.top .brand {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text);
  letter-spacing: -.02em;
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
}
nav.top .brand .dn {
  color: var(--primary);
  font-size: 1.5rem;       /* bumped vs Latin half to optically match */
  font-weight: 600;
  font-family: "Noto Sans Devanagari", "Mangal", "Sanskrit Text", serif;
  line-height: 1;
}
nav.top .links {
  display: flex; gap: 6px; flex: 1;
}
nav.top .links a {
  color: var(--text-2);
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 14px;
}
nav.top .links a:hover { background: var(--surface-2); text-decoration: none; }
nav.top .links a.active { color: var(--primary); background: var(--primary-l); }
nav.top .who {
  font-size: 13px;
  color: var(--text-3);
}
nav.top .who strong { color: var(--text-2); }
nav.top .badge-admin {
  background: var(--primary);
  color: white;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-left: 6px;
}

/* ── Layout ────────────────────────────────────────────────────────────── */
main {
  max-width: var(--max);
  margin: 32px auto;
  padding: 0 24px;
}
section { margin-bottom: 48px; }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 240px; }

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card.hover {
  transition: transform .15s, box-shadow .15s;
  cursor: pointer;
}
.card.hover:hover {
  transform: translateY(-2px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.08);
}
.card .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-3);
  font-weight: 600;
  margin-bottom: 6px;
}
.card .num { font-size: 1.8rem; font-weight: 700; color: var(--text); }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary);
  color: white;
  border: none;
  font-family: inherit;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s;
}
.btn:hover { background: var(--primary-d); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.secondary:hover { background: var(--surface-2); }

.btn.ghost {
  background: transparent;
  color: var(--primary);
}
.btn.ghost:hover { background: var(--primary-l); }

.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #dc2626; }

.btn.small { padding: 5px 10px; font-size: 12px; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
form { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-2); font-weight: 500; }
input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-l);
}

/* ── Tables ────────────────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table th, table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
table th {
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-3);
  background: var(--surface-2);
}
table tr:hover td { background: var(--surface-2); }

/* ── Badges + status pills ─────────────────────────────────────────────── */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.pill.active   { background: #d1fae5; color: #065f46; }
.pill.draft    { background: #fef3c7; color: #92400e; }
.pill.archived { background: var(--surface-2); color: var(--text-3); }
.pill.paid     { background: #d1fae5; color: #065f46; }
.pill.created  { background: #fef3c7; color: #92400e; }
.pill.cancelled, .pill.failed, .pill.suspended { background: #fee2e2; color: #991b1b; }

/* ── Tabs ──────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.tabs button {
  background: none;
  border: none;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Toasts ────────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--text);
  color: white;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  max-width: 360px;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.error { background: var(--danger); }
#toast.success { background: var(--success); }

/* ── Hero ──────────────────────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 64px 24px 24px;
  background: linear-gradient(180deg, var(--primary-l) 0%, var(--bg) 100%);
  margin: -32px -24px 48px;
}
.hero-sanskrit {
  font-family: "Noto Sans Devanagari", "Mangal", "Sanskrit Text", serif;
  font-size: 2.6rem;
  font-weight: 500;
  color: var(--primary);
  margin-bottom: 4px;
  line-height: 1;
  letter-spacing: .02em;
}
.hero h1 {
  font-size: 3rem;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 14px;
}
.hero p {
  font-size: 1.1rem;
  max-width: 600px;
  margin: 0 auto 24px;
}
.hero .meta { color: var(--text-3); font-size: 13px; }

/* ── Misc helpers ──────────────────────────────────────────────────────── */
.muted { color: var(--text-3); }
.center { text-align: center; }
.mt-4 { margin-top: 24px; }
.mb-4 { margin-bottom: 24px; }
.gap-4 { gap: 16px; }
.flex { display: flex; align-items: center; }
.between { justify-content: space-between; }
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-3);
  font-size: 14px;
}
.empty svg { width: 48px; height: 48px; opacity: .3; margin-bottom: 12px; }
.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}
.kv {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px 16px;
  font-size: 14px;
}
.kv dt { color: var(--text-3); font-weight: 500; }
.kv dd { margin: 0; color: var(--text); }
