/* ==========================================================
   Truck Hisab — Design System (Driver-friendly)
   Tagline: आपका ट्रक, आपका हिसाब
   ========================================================== */

:root {
  /* ---------- Colors (locked from spec) ---------- */
  --bg:           #F5EFE3;   /* warm cream paper */
  --bg-2:         #EDE4D2;
  --board:        #FAF6EE;
  --ink:          #161310;
  --ink-2:        #3A332B;
  --muted:        #7A6E5E;
  --line:         #E1D6C0;
  --line-soft:    #EBE2D0;
  --paper:        #FFFFFF;
  --truck:        #E8541C;   /* saffron — actions, brand */
  --truck-deep:   #B33A0E;
  --truck-soft:   #FCE9DD;
  --money:        #0F6E4A;   /* deep green — income */
  --money-soft:   #E5F2EC;
  --spend:        #A52525;   /* deep red — expenses */
  --spend-soft:   #F8E8E8;
  --gold:         #C99211;   /* highlight, cash */
  --gold-soft:    #FAF1D6;
  --indigo:       #1F2B4A;

  /* ---------- Typography ---------- */
  --font-display: 'Bricolage Grotesque', sans-serif;
  --font-body:    'DM Sans', sans-serif;
  --font-hindi:   'Noto Sans Devanagari', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  /* multilingual fonts */
  --font-bengali: 'Noto Sans Bengali', sans-serif;
  --font-tamil:   'Noto Sans Tamil', sans-serif;
  --font-telugu:  'Noto Sans Telugu', sans-serif;
  --font-gujarati:'Noto Sans Gujarati', sans-serif;
  --font-kannada: 'Noto Sans Kannada', sans-serif;
  --font-malayalam:'Noto Sans Malayalam', sans-serif;
  --font-punjabi: 'Noto Sans Gurmukhi', sans-serif;
  --font-odia:    'Noto Sans Oriya', sans-serif;
  --font-urdu:    'Noto Nastaliq Urdu', serif;
  --font-assamese:'Noto Sans Bengali', sans-serif;

  /* ---------- Driver-friendly sizing (large touch targets) ---------- */
  --tap-target:    56px;     /* min button height — driver gloves friendly */
  --tap-target-lg: 64px;
  --radius-sm:     8px;
  --radius-md:     14px;
  --radius-lg:     18px;
  --radius-xl:     24px;
  --radius-pill:   30px;

  /* ---------- Shadows ---------- */
  --shadow-sm: 0 2px 8px -4px rgba(40,30,20,.15);
  --shadow-md: 0 6px 18px -8px rgba(40,30,20,.20);
  --shadow-lg: 0 14px 30px -10px rgba(40,30,20,.25);
  --shadow-truck: 0 14px 30px -10px rgba(232,84,28,.55);
}

/* ==========================================================
   Reset
   ========================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
html, body {
  background: var(--bg);
  font-family: var(--font-body);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
}
button { border: none; cursor: pointer; font-family: inherit; }
input { font-family: inherit; outline: none; border: none; }
a { color: inherit; text-decoration: none; }

/* ==========================================================
   App Frame (mobile-first, desktop shows phone-like preview)
   ========================================================== */
.app-frame {
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 5%, rgba(232,84,28,.06), transparent 40%),
    radial-gradient(circle at 95% 90%, rgba(15,110,74,.05), transparent 45%),
    var(--bg);
}
.app-screen {
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* desktop preview — phone-like */
@media (min-width: 768px) {
  .app-frame { padding: 40px 0; }
  .app-screen {
    max-width: 400px;
    min-height: 760px;
    border-radius: 32px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
  }
}

/* ==========================================================
   Top Bar (back + audio helper + madad)
   ========================================================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 8px;
  background: transparent;
}
.topbar .back-btn,
.topbar .audio-btn,
.topbar .madad-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  transition: transform .15s, background .15s;
}
.topbar .back-btn:active,
.topbar .audio-btn:active,
.topbar .madad-btn:active {
  transform: scale(.94);
  background: var(--line);
}
.topbar .audio-btn.playing {
  background: var(--truck);
  color: #fff;
  animation: pulse-btn 1.2s infinite;
}
.topbar .right-actions { display: flex; gap: 10px; }
.topbar .madad-btn {
  width: auto;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  background: var(--gold-soft);
  color: var(--gold);
  font-weight: 700;
  font-size: 13px;
  gap: 6px;
}
@keyframes pulse-btn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232,84,28,.6); }
  50% { box-shadow: 0 0 0 10px rgba(232,84,28,0); }
}

/* ==========================================================
   Brand Logo
   ========================================================== */
.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 24px 0;
}
.mini-logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F47A37, #B33A0E);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}
.mini-logo svg { width: 22px; height: 22px; color: #fff; }
.mini-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -.01em;
}

/* ==========================================================
   Headings
   ========================================================== */
.h-display {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -.025em;
  line-height: 1.05;
  color: var(--ink);
}
.h-display em {
  font-style: italic;
  font-weight: 300;
  color: var(--truck);
}
.h-display.lg  { font-size: 36px; }
.h-display.md  { font-size: 28px; }
.h-display.sm  { font-size: 22px; }

.h-hindi {
  font-family: var(--font-hindi);
  font-weight: 500;
  color: var(--muted);
  margin-top: 8px;
  font-size: 16px;
  line-height: 1.4;
}

/* ==========================================================
   Forms — Driver Friendly (BIG)
   ========================================================== */
.field-block { margin-top: 26px; padding: 0 24px; }
.field-block + .field-block { margin-top: 18px; }

.field-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
  letter-spacing: .03em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}
.field-label .ic { color: var(--truck); }

.input-shell {
  margin-top: 12px;
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap-target);
  transition: border-color .15s, background .15s;
}
.input-shell:focus-within {
  border-color: var(--truck);
  background: #fff;
}
.input-shell.filled {
  background: #fff;
  border-color: var(--ink);
}

.input-shell .country-code {
  background: var(--ink);
  color: #FAB060;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: .04em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.input-shell .country-code .flag { font-size: 16px; }

.input-shell input {
  flex: 1;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: .08em;
  color: var(--ink);
  width: 100%;
}
.input-shell input::placeholder {
  color: var(--muted);
  font-weight: 400;
  letter-spacing: .04em;
}

.input-helper {
  font-size: 13px;
  color: var(--muted);
  margin-top: 10px;
  line-height: 1.5;
  display: flex;
  align-items: center;
  gap: 6px;
}
.input-helper .ic { color: var(--money); flex-shrink: 0; }
.input-helper .hin { font-family: var(--font-hindi); color: var(--ink-2); }

/* example chip — "Jaise: 98765 43210" */
.example-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 8px 14px;
  background: var(--gold-soft);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  color: var(--gold);
}
.example-chip .ic { color: var(--gold); }
.example-chip .num {
  font-family: var(--font-mono);
  letter-spacing: .06em;
}

/* ==========================================================
   Buttons — Driver friendly, BIG
   ========================================================== */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: var(--tap-target-lg);
  padding: 18px 24px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -.005em;
  transition: transform .12s, box-shadow .15s, background .15s;
  width: 100%;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--ink);
  color: #fff;
}
.btn-primary:hover { background: #2a201a; }
.btn-primary .arr {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--truck);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-truck {
  background: var(--truck);
  color: #fff;
  box-shadow: var(--shadow-truck);
}
.btn-truck:hover { background: var(--truck-deep); }

.btn-ghost {
  background: var(--bg);
  color: var(--ink);
  border: 1.5px solid var(--line);
}

/* ==========================================================
   Sticky bottom action area
   ========================================================== */
.action-area {
  margin-top: auto;
  padding: 24px 24px 32px;
  background: linear-gradient(180deg, transparent 0%, var(--paper) 30%);
}
.action-terms {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}
.action-terms a {
  color: var(--truck);
  font-weight: 600;
}

/* ==========================================================
   Madad (Help) — floating, toll-free
   ========================================================== */
.madad-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #25D366; /* WhatsApp green */
  color: #fff;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px -6px rgba(37,211,102,.55);
  z-index: 50;
}
.madad-fab:active { transform: scale(.94); }

/* ==========================================================
   Splash screen specific
   ========================================================== */
.splash-screen {
  flex: 1;
  background:
    radial-gradient(circle at 80% 10%, rgba(232,84,28,.45), transparent 55%),
    radial-gradient(circle at 10% 90%, rgba(201,146,17,.30), transparent 55%),
    linear-gradient(160deg, #191512 0%, #2a1f17 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 60px 28px 40px;
  position: relative;
  overflow: hidden;
  min-height: 100vh;
}
.splash-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
}
.splash-brandmark {
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  position: relative;
  z-index: 2;
}
.splash-logo {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F47A37 0%, #E8541C 50%, #B33A0E 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 16px 40px -8px rgba(232,84,28,.55), inset 0 -2px 0 rgba(0,0,0,.15);
  position: relative;
}
.splash-logo::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  border: 1.5px dashed rgba(255,255,255,.35);
}
.splash-logo svg {
  width: 60px;
  height: 60px;
  color: #fff;
  position: relative;
  z-index: 2;
}
.splash-brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 46px;
  letter-spacing: -.03em;
  line-height: 1;
}
.splash-brand-name em {
  font-style: italic;
  font-weight: 300;
  color: #FAB060;
}
.splash-tag {
  font-size: 14px;
  color: rgba(255,255,255,.7);
  text-align: center;
  line-height: 1.5;
}
.splash-tag .hin {
  display: block;
  font-family: var(--font-hindi);
  font-weight: 500;
  color: #fff;
  font-size: 17px;
  margin-bottom: 8px;
}

/* ==========================================================
   Language Picker — driver friendly visual cards
   ========================================================== */
.lang-section {
  margin-top: 30px;
  position: relative;
  z-index: 2;
}
.lang-title {
  text-align: center;
  font-size: 13px;
  color: rgba(255,255,255,.6);
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 16px;
}
.lang-title .hin {
  display: block;
  font-family: var(--font-hindi);
  font-size: 16px;
  color: #fff;
  letter-spacing: 0;
  text-transform: none;
  margin-top: 4px;
  font-weight: 500;
}
.lang-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px 2px;
}
.lang-card {
  background: rgba(255,255,255,.08);
  border: 1.5px solid rgba(255,255,255,.12);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
  transition: all .15s;
  text-align: left;
  color: #fff;
}
.lang-card:active {
  transform: scale(.97);
  background: rgba(255,255,255,.14);
}
.lang-card.selected {
  background: var(--truck);
  border-color: #FAB060;
  box-shadow: 0 8px 20px -8px rgba(232,84,28,.6);
}
.lang-card .native {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.1;
}
.lang-card .english {
  font-size: 11px;
  color: rgba(255,255,255,.55);
  letter-spacing: .02em;
  font-weight: 500;
}
.lang-card.selected .english { color: rgba(255,255,255,.85); }

.lang-card[data-script="devanagari"] .native { font-family: var(--font-hindi); }
.lang-card[data-script="bengali"]    .native { font-family: var(--font-bengali); }
.lang-card[data-script="tamil"]      .native { font-family: var(--font-tamil); }
.lang-card[data-script="telugu"]     .native { font-family: var(--font-telugu); }
.lang-card[data-script="gujarati"]   .native { font-family: var(--font-gujarati); }
.lang-card[data-script="kannada"]    .native { font-family: var(--font-kannada); }
.lang-card[data-script="malayalam"]  .native { font-family: var(--font-malayalam); }
.lang-card[data-script="gurmukhi"]   .native { font-family: var(--font-punjabi); }
.lang-card[data-script="odia"]       .native { font-family: var(--font-odia); }
.lang-card[data-script="arabic"]     .native { font-family: var(--font-urdu); direction: rtl; font-size: 22px; }

/* show more languages button */
.lang-more {
  margin-top: 12px;
  text-align: center;
  font-size: 13px;
  color: #FAB060;
  font-weight: 600;
  cursor: pointer;
  padding: 8px;
}

/* CTA in splash */
.splash-cta {
  margin-top: 24px;
  background: #fff;
  color: var(--ink);
  padding: 18px 24px;
  border-radius: var(--radius-lg);
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 2;
  cursor: pointer;
  transition: transform .12s;
}
.splash-cta:active { transform: scale(.98); }
.splash-cta .arr {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--truck);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================
   OTP boxes — driver friendly, BIG
   ========================================================== */
.otp-grid {
  display: flex;
  gap: 8px;
  margin-top: 24px;
  padding: 0 22px;
  justify-content: center;
  align-items: center;
}
.otp-cell {
  width: 48px;
  height: 60px;
  flex: 0 0 48px;
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 26px;
  color: var(--ink);
  caret-color: var(--truck);
  transition: all .15s;
  outline: none;
  padding: 0;
}
.otp-cell:focus,
.otp-cell.active {
  border-color: var(--truck);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(232,84,28,.12);
}
.otp-cell.filled {
  background: #fff;
  border-color: var(--ink);
}
@media (min-width: 380px) {
  .otp-cell { width: 52px; height: 64px; flex: 0 0 52px; }
}

.otp-resend {
  margin-top: 22px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  padding: 0 24px;
}
.otp-resend strong {
  color: var(--ink);
  font-family: var(--font-mono);
  font-weight: 600;
}
.otp-resend .resend-btn {
  color: var(--truck);
  font-weight: 700;
  cursor: pointer;
  margin-left: 6px;
}
.otp-resend .resend-btn.disabled { color: var(--muted); cursor: not-allowed; }

/* sms auto-detect chip */
.sms-listening {
  margin: 22px 24px 0;
  background: var(--money-soft);
  border: 1px solid #BBE3CF;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--ink-2);
}
.sms-listening .pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--money);
  position: relative;
  flex-shrink: 0;
}
.sms-listening .pulse::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid var(--money);
  animation: pulse-ring 1.6s infinite;
}
.sms-listening .hin {
  font-family: var(--font-hindi);
  color: var(--ink);
  font-weight: 500;
}
@keyframes pulse-ring {
  0%   { transform: scale(1);   opacity: 1; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* ==========================================================
   Toast / Notifications
   ========================================================== */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--ink);
  color: #fff;
  padding: 14px 20px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all .25s;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.success { background: var(--money); }
.toast.error   { background: var(--spend); }

/* ==========================================================
   PWA Install Button (floating, driver-friendly)
   ========================================================== */
.pwa-install-btn {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 20px 12px 16px;
  border-radius: 30px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 14px 30px -10px rgba(40,30,20,.4), 0 0 0 4px rgba(232,84,28,.15);
  z-index: 80;
  cursor: pointer;
  border: none;
  animation: pwa-pulse 3s ease-in-out infinite;
}
.pwa-install-btn:active { transform: translateX(-50%) scale(.96); }
.pwa-install-btn svg { color: var(--truck); }

@keyframes pwa-pulse {
  0%, 100% { box-shadow: 0 14px 30px -10px rgba(40,30,20,.4), 0 0 0 4px rgba(232,84,28,.15); }
  50%      { box-shadow: 0 14px 30px -10px rgba(40,30,20,.4), 0 0 0 10px rgba(232,84,28,0); }
}

/* hide install button when running as installed PWA */
body.pwa-installed .pwa-install-btn { display: none !important; }

/* shift madad fab up when install button visible */
.pwa-install-btn ~ .madad-fab,
body:has(.pwa-install-btn) .madad-fab {
  bottom: 92px;
}

/* ==========================================================
   Loading spinner
   ========================================================== */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
