/* v2.css — Direction-A look (design_v2), P0 Foundation.
 *
 * SCOPE: every rule is prefixed with [data-design="v2"] (shell.js stamps this on
 * <html> only for a flagged shop). With the flag OFF the attribute is absent, so NONE
 * of this applies and the app renders v1 byte-for-byte. Rollback = flag off, no deploy.
 *
 * P0 is FOUNDATION ONLY: design tokens + the left hub rail (≥1024px) + the hub tab
 * strip. No per-screen component restyles (those are P1–P3), no markup/id/handler
 * changes, and print / thermal / PNG / WhatsApp output CSS is untouched (locked).
 *
 * Tokens (DESIGN_WAVE_PLAN §6): Inter · ground #f4f5f1 · surface #fff · ink #121412 ·
 * green #0f6b43 (single accent) · red #b42318 · amber #9a5b00 on #fff1e2 · chips
 * #e6f2ec / #eef0ea · radius 18/22 cards, 12 inputs · tabular numerals on money.
 */

/* ---------- 1. Tokens: re-point the base CSS variables ----------
   The whole app reads var(--bg)/var(--ink)/var(--brand)/… so swapping the tokens here
   re-skins surfaces at the foundation level without touching any component rule. v2 is
   a light look; it intentionally overrides dark tokens too (loads after base.css). */
:root[data-design="v2"],
:root[data-design="v2"][data-theme="dark"] {
  --ink: #121412;
  --ink-2: #3a3f3b;
  --muted: #5f6b63;
  --brand: #0f6b43;
  --brand-2: #0f6b43;
  --brand-soft: #e6f2ec;
  --amber: #9a5b00;
  --amber-soft: #fff1e2;
  --red: #b42318;
  --red-soft: #fdeceb;
  --bg: #f4f5f1;
  --card: #ffffff;
  --surface: #ffffff;
  --soft: #eef0ea;
  --line: #e4e7e0;
  --panel: #121412;
  --on-panel: #f2f3ef;
  --radius: 18px;
  --radius-field: 12px;
  --shadow: 0 1px 2px rgba(18, 20, 18, .04), 0 10px 30px rgba(18, 20, 18, .06);
}

/* ---------- 2. Typeface ---------- */
:root[data-design="v2"] body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  letter-spacing: -0.006em;
}

/* Money always reads as aligned figures (base money markup uses .num). */
:root[data-design="v2"] .num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* Larger card corners per the token set; inputs/buttons keep the field radius via --radius-field. */
:root[data-design="v2"] .card { border-radius: 22px; }

/* ---------- 3. Hub tab strip (top of content, all widths) ---------- */
:root[data-design="v2"] .hubbar {
  margin: 0 0 20px;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--line);
}
:root[data-design="v2"] .hubbar-name {
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.01em;
}
:root[data-design="v2"] .hubbar .subnav { gap: 4px; }
:root[data-design="v2"] .hubbar .subnav a,
:root[data-design="v2"] .hubbar .subnav button {
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  transition: background .14s ease, color .14s ease;
}
:root[data-design="v2"] .hubbar .subnav a:hover,
:root[data-design="v2"] .hubbar .subnav button:hover { color: var(--ink); background: var(--soft); }
:root[data-design="v2"] .hubbar .subnav a.active,
:root[data-design="v2"] .hubbar .subnav .active {
  color: var(--brand);
  background: var(--brand-soft);
}

/* ---------- 4. Left hub rail (≥1024px) ----------
   The existing .sidebar already becomes a left column on desktop and, under
   body.hubnav, shows the hub links (#navListHub) with the static list hidden — i.e.
   it is ALREADY hubs-only. v2 restyles it into the Direction-A rail; no markup change. */
@media (min-width: 1024px) {
  :root[data-design="v2"] .sidebar {
    background: var(--bg);
    border-right: 1px solid var(--line);
    box-shadow: none;
    padding: 18px 14px;
  }
  :root[data-design="v2"] .sidebar .brand-mark { color: var(--ink); font-weight: 800; letter-spacing: -0.02em; }
  :root[data-design="v2"] .sidebar .brand-shop { color: var(--muted); }

  :root[data-design="v2"] .nav-list-hub { gap: 2px; }
  :root[data-design="v2"] .hub-link {
    display: flex;
    align-items: baseline;
    gap: 8px;
    border-radius: 12px;
    padding: 10px 12px;
    color: var(--ink-2);
    font-weight: 600;
    transition: background .14s ease, color .14s ease;
  }
  :root[data-design="v2"] .hub-link .ur { color: var(--muted); font-weight: 500; }
  :root[data-design="v2"] .hub-link:hover { background: var(--soft); color: var(--ink); }
  :root[data-design="v2"] .hub-link.active {
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 700;
  }
  :root[data-design="v2"] .hub-link.active .ur { color: var(--brand); }
}

/* ---------- 5. Commit button: ink-black with the amount pushed right ----------
   Foundation treatment only (base commit buttons carry .btn-commit); P1 wires the
   amount slot per screen. Kept token-level so no screen markup changes in P0. */
:root[data-design="v2"] .btn-commit,
:root[data-design="v2"] .btn-primary.commit {
  background: var(--panel);
  color: var(--on-panel);
  border-radius: var(--radius-field);
  justify-content: space-between;
}

/* Bilingual nav: the Urdu echo stays (Mujaddad ruling) as a quiet secondary under the
   Roman label — in the tab strip and mobile tabs, matching the rail treatment above. */
:root[data-design="v2"] .hubbar .ur,
:root[data-design="v2"] .tab .ur,
:root[data-design="v2"] .subnav .ur { color: var(--muted); font-weight: 500; }

@media (prefers-reduced-motion: reduce) {
  :root[data-design="v2"] .hubbar .subnav a,
  :root[data-design="v2"] .hubbar .subnav button,
  :root[data-design="v2"] .hub-link { transition: none; }
}

/* ======================================================================
 * P1 — Counter + Sell + Khata component layer (CSS only; classes added
 * nowhere, markup/ids/handlers unchanged — logic-diff stays 11/11).
 * Tokens from §1 do the colour/radius/type; these rules add Direction-A
 * hierarchy, rhythm and interaction to the three screens shops live in.
 * ==================================================================== */

/* ---------- Counter: action tiles ---------- */
:root[data-design="v2"] .ctr-tiles { gap: 12px; }
:root[data-design="v2"] .ctr-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease;
}
:root[data-design="v2"] .ctr-tile:hover {
  transform: translateY(-2px);
  border-color: var(--brand);
  box-shadow: var(--shadow);
}
:root[data-design="v2"] .ctr-tile .ctr-ico { color: var(--brand); }

/* ---------- Counter: KPI / position cards + section heads ---------- */
:root[data-design="v2"] .ctr-group,
:root[data-design="v2"] .ctr-kpi,
:root[data-design="v2"] .ctr-strip { border-radius: 18px; }
:root[data-design="v2"] .ctr-money,
:root[data-design="v2"] .ctr-v,
:root[data-design="v2"] .ctr-dual-v,
:root[data-design="v2"] .ctr-bankrow-v,
:root[data-design="v2"] .ctr-jz-v { font-variant-numeric: tabular-nums; }
:root[data-design="v2"] .ctr-sidehead,
:root[data-design="v2"] .ctr-group-h { letter-spacing: -0.01em; color: var(--ink); }

/* ---------- Counter: search field ---------- */
:root[data-design="v2"] .ctr-search {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  transition: border-color .14s ease, box-shadow .14s ease;
}
:root[data-design="v2"] .ctr-search:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

/* ---------- Counter: cart panel + feed ---------- */
:root[data-design="v2"] .ctr-cart { border-radius: 18px; border: 1px solid var(--line); }
:root[data-design="v2"] .ctr-cart-total { font-variant-numeric: tabular-nums; color: var(--ink); }
:root[data-design="v2"] .ctr-feed .ctr-fr { border-radius: 12px; transition: background .14s ease; }
:root[data-design="v2"] .ctr-feed .ctr-fr:hover { background: var(--soft); }
:root[data-design="v2"] .ctr-fdot { color: var(--brand); }

/* ---------- Sell: cards, fields, payment ---------- */
:root[data-design="v2"] .sell-grid .card,
:root[data-design="v2"] .sell-row .card { border-radius: 22px; }
:root[data-design="v2"] .callout {
  border-radius: 14px;
  background: var(--brand-soft);
  border: 1px solid transparent;
}
:root[data-design="v2"] .pay-row { gap: 10px; }
:root[data-design="v2"] .field input,
:root[data-design="v2"] .field select { border-radius: var(--radius-field); }
:root[data-design="v2"] .field input:focus,
:root[data-design="v2"] .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

/* ---------- Khata: list band + rows ---------- */
:root[data-design="v2"] .khata-band { border-radius: 18px; }
:root[data-design="v2"] .khata-stat-value { font-variant-numeric: tabular-nums; color: var(--ink); }
:root[data-design="v2"] .cust-row {
  border-radius: 14px;
  transition: background .14s ease, border-color .14s ease;
}
:root[data-design="v2"] .cust-row:hover { background: var(--soft); }
:root[data-design="v2"] .cust-ava { background: var(--brand-soft); color: var(--brand); }

/* ---------- Khata detail: hero balance card ---------- */
:root[data-design="v2"] .cust-hero {
  border-radius: 22px;
  border: 1px solid var(--line);
}
:root[data-design="v2"] .cust-bal-big {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: -0.02em;
}
:root[data-design="v2"] .cust-hero-chips .chip,
:root[data-design="v2"] .cust-hero-chips > * { border-radius: 999px; }

@media (prefers-reduced-motion: reduce) {
  :root[data-design="v2"] .ctr-tile,
  :root[data-design="v2"] .ctr-search,
  :root[data-design="v2"] .ctr-feed .ctr-fr,
  :root[data-design="v2"] .cust-row { transition: none; }
  :root[data-design="v2"] .ctr-tile:hover { transform: none; }
}

/* ======================================================================
 * P2 — Stock + Khareedein + Register, LAYOUT to match the A boards
 * (DesktopStock / DesktopBuy / DesktopRegister). The grids these boards
 * use already exist in the app (Counter .ctr-grid 2-col, stat tiles
 * .grid.g3/.g4 + .stat-value, cards radius 22 via tokens), so this is the
 * title treatment, the ink-black commit button and figure alignment —
 * CSS only + the class-only .btn-commit marker (stripped by logic-diff,
 * inert in v1).
 * ==================================================================== */

/* ---------- Page title: big, with the muted sub-line ABOVE it ---------- */
:root[data-design="v2"] .page-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
:root[data-design="v2"] .page-head p { order: -1; margin: 0; font-weight: 500; }
:root[data-design="v2"] .page-head h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
@media (min-width: 1024px) {
  :root[data-design="v2"] .page-head h1 { font-size: 36px; letter-spacing: -0.03em; }
}

/* ---------- Commit button: ink-black, label left / amount right ----------
   .btn-commit tags the big form submits (Sale mukammal, Add to stock,
   Register band, Bulk sale). space-between right-aligns an amount span when
   one is present; label-only buttons centre as before. */
:root[data-design="v2"] .btn-commit {
  background: var(--panel);
  color: var(--on-panel);
  border: 0;
  border-radius: 16px;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-left: 20px;
  padding-right: 20px;
}
:root[data-design="v2"] .btn-commit:hover { filter: brightness(1.12); }
:root[data-design="v2"] .btn-commit .num { font-variant-numeric: tabular-nums; font-weight: 800; }

/* ---------- Stat tiles (Register Aaj, Counter position): figures ---------- */
:root[data-design="v2"] .stat-value { font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
:root[data-design="v2"] .grid.g3 > .card,
:root[data-design="v2"] .grid.g4 > .card { border-radius: 18px; }

/* ---------- Stock / ledger tables: aligned figures + quiet header ------- */
:root[data-design="v2"] .table-wrap table .num,
:root[data-design="v2"] table td.num,
:root[data-design="v2"] table th { font-variant-numeric: tabular-nums; }
:root[data-design="v2"] .table-wrap { border-radius: 18px; }

@media (prefers-reduced-motion: reduce) {
  :root[data-design="v2"] .btn-commit:hover { filter: none; }
}
