/* ============================================================
   BechDe PWA — Design System & Micro-interactions
   Premium mobile-first UI: glassmorphism, soft shadows,
   satisfying feedback. Tailwind handles layout; this file
   handles the "soul" of the app.
   ============================================================ */

:root {
  /* Brand */
  --brand-1: #6d28d9;   /* violet-700 */
  --brand-2: #8b5cf6;   /* violet-500 */
  --brand-3: #c026d3;   /* fuchsia-600 */
  --accent:  #f59e0b;   /* saffron / amber */
  --money:   #059669;   /* emerald */
  --danger:  #e11d48;   /* rose */

  --ink:     #1e1b2e;
  --ink-soft:#5b5670;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --stroke:  rgba(255, 255, 255, 0.65);
  --shadow-soft: 0 10px 30px -12px rgba(76, 29, 149, 0.28);
  --shadow-lift: 0 22px 50px -18px rgba(76, 29, 149, 0.45);

  --nav-h: 78px;
}

/* ---------- Base ---------- */
* { -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Poppins', 'Noto Sans Devanagari', system-ui, sans-serif;
  color: var(--ink);
  background: #f4f1ff;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

/* Devanagari deserves a touch more line-height */
:lang(hi), .lang-hi { line-height: 1.5; }

/* Animated aurora background blobs */
.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(120% 120% at 50% -10%, #efeaff 0%, #f6f3ff 40%, #fdf7ff 100%);
}
.aurora::before,
.aurora::after {
  content: "";
  position: absolute;
  width: 60vw;
  height: 60vw;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.5;
  animation: float 18s ease-in-out infinite;
}
.aurora::before {
  top: -12%; left: -18%;
  background: radial-gradient(circle, #c4b5fd, transparent 65%);
}
.aurora::after {
  bottom: -18%; right: -18%;
  background: radial-gradient(circle, #fbcfe8, transparent 65%);
  animation-delay: -8s;
}
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(4%, 6%) scale(1.12); }
}

/* ---------- Glassmorphism ---------- */
.glass {
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow-soft);
}
.glass-strong {
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.7);
}

/* ---------- Tap feedback ---------- */
.tap { transition: transform .14s cubic-bezier(.34,1.56,.64,1), box-shadow .2s ease, filter .2s ease; }
.tap:active { transform: scale(.955); }

.press:active { transform: scale(.92); }

/* Ripple */
.ripple { position: relative; overflow: hidden; }
.ripple > span.rp {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  background: rgba(255,255,255,0.55);
  animation: ripple .6s ease-out;
  pointer-events: none;
}
@keyframes ripple { to { transform: scale(3.4); opacity: 0; } }

/* ---------- Screens / transitions ---------- */
.screen { display: none; animation: screenIn .42s cubic-bezier(.22,1,.36,1); }
.screen.active { display: block; }
@keyframes screenIn {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Staggered card entrance */
.stagger > * { opacity: 0; animation: rise .5s cubic-bezier(.22,1,.36,1) forwards; }
.stagger > *:nth-child(1){animation-delay:.04s}
.stagger > *:nth-child(2){animation-delay:.10s}
.stagger > *:nth-child(3){animation-delay:.16s}
.stagger > *:nth-child(4){animation-delay:.22s}
.stagger > *:nth-child(5){animation-delay:.28s}
.stagger > *:nth-child(6){animation-delay:.34s}
.stagger > *:nth-child(7){animation-delay:.40s}
@keyframes rise { to { opacity: 1; transform: none; } }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 50;
}
.nav-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 600;
  transition: color .25s ease, transform .2s ease;
}
.nav-item i { font-size: 20px; transition: transform .3s cubic-bezier(.34,1.56,.64,1); }
.nav-item.active { color: var(--brand-1); }
.nav-item.active i { transform: translateY(-2px) scale(1.14); }
.nav-item.active::before {
  content: "";
  position: absolute;
  top: -9px;
  width: 34px; height: 4px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--brand-2), var(--brand-3));
  box-shadow: 0 4px 12px rgba(139,92,246,.6);
}

/* Center FAB in nav */
.nav-fab {
  width: 60px; height: 60px;
  margin-top: -26px;
  border-radius: 22px;
  display: grid; place-items: center;
  color: #fff; font-size: 24px;
  background: linear-gradient(135deg, var(--brand-2), var(--brand-3));
  box-shadow: 0 12px 26px -6px rgba(192,38,211,.65);
}

/* ---------- Language toggle ---------- */
.lang-toggle {
  position: relative;
  width: 96px; height: 40px;
  border-radius: 99px;
  padding: 4px;
  display: flex;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.lang-toggle .knob {
  position: absolute;
  top: 4px; left: 4px;
  width: 44px; height: 32px;
  border-radius: 99px;
  background: linear-gradient(135deg, var(--brand-2), var(--brand-3));
  box-shadow: 0 6px 14px -3px rgba(139,92,246,.7);
  transition: transform .32s cubic-bezier(.34,1.56,.64,1);
}
.lang-toggle.hi .knob { transform: translateX(44px); }
.lang-toggle span {
  flex: 1;
  display: grid; place-items: center;
  z-index: 1;
  transition: color .3s ease;
  color: var(--ink-soft);
}
.lang-toggle:not(.hi) span.en,
.lang-toggle.hi span.hi { color: #fff; }

/* ---------- Inputs ---------- */
.field {
  width: 100%;
  padding: 15px 16px;
  border-radius: 16px;
  border: 1.5px solid rgba(109,40,217,.12);
  background: rgba(255,255,255,.85);
  font-size: 16px;         /* >=16px stops iOS zoom */
  font-weight: 500;
  color: var(--ink);
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
  outline: none;
}
.field::placeholder { color: #a8a2bd; font-weight: 500; }
.field:focus {
  border-color: var(--brand-2);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(139,92,246,.14);
}
select.field { appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none' stroke='%236d28d9' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 44px;
}
/* Kill number spinners — keypad only */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .3px;
  color: var(--ink-soft);
  margin: 0 0 7px 4px;
  text-transform: uppercase;
}

/* ---------- Buttons ---------- */
.btn-primary {
  background: linear-gradient(135deg, var(--brand-1), var(--brand-3));
  color: #fff;
  font-weight: 700;
  border-radius: 18px;
  box-shadow: 0 14px 30px -10px rgba(139,92,246,.75);
}
.btn-accent {
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #fff; font-weight: 700; border-radius: 18px;
  box-shadow: 0 14px 30px -10px rgba(245,158,11,.7);
}
.btn-ghost {
  background: rgba(109,40,217,.08);
  color: var(--brand-1);
  font-weight: 700;
  border-radius: 16px;
}

/* ---------- Metric / gradient cards ---------- */
.metric {
  border-radius: 24px;
  padding: 18px;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lift);
}
.metric::after {
  content: "";
  position: absolute;
  top: -40%; right: -20%;
  width: 160px; height: 160px;
  border-radius: 50%;
  background: rgba(255,255,255,.16);
}
.metric .m-icon {
  width: 42px; height: 42px;
  border-radius: 14px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.22);
  font-size: 18px;
}
.grad-cash   { background: linear-gradient(135deg, #059669, #10b981 60%, #34d399); }
.grad-profit { background: linear-gradient(135deg, #7c3aed, #a855f7 55%, #d946ef); }
.grad-stock  { background: linear-gradient(135deg, #0284c7, #0ea5e9 55%, #38bdf8); }

/* ---------- Chips / pills ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px;
  border-radius: 99px;
  font-size: 13px; font-weight: 600;
  background: rgba(109,40,217,.08);
  color: var(--brand-1);
  transition: all .2s ease;
}
.chip.active {
  background: linear-gradient(135deg, var(--brand-1), var(--brand-3));
  color: #fff;
  box-shadow: 0 8px 18px -6px rgba(139,92,246,.6);
}

/* ---------- Toggle switch ---------- */
.switch { position: relative; width: 56px; height: 32px; flex: none; cursor: pointer; }
.switch input { display: none; }
.switch .track {
  position: absolute; inset: 0;
  border-radius: 99px;
  background: #d9d3ea;
  transition: background .3s ease;
}
.switch .thumb {
  position: absolute; top: 3px; left: 3px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,.2);
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
}
.switch input:checked + .track { background: linear-gradient(135deg, #22c55e, #16a34a); }
.switch input:checked + .track + .thumb { transform: translateX(24px); }

/* ---------- Success checkmark ---------- */
.success-overlay {
  position: fixed; inset: 0;
  z-index: 90;
  display: none;
  place-items: center;
  background: rgba(30,27,46,.4);
  backdrop-filter: blur(6px);
}
.success-overlay.show { display: grid; animation: fadeIn .25s ease; }
.success-card {
  background: #fff;
  border-radius: 28px;
  padding: 34px 40px;
  text-align: center;
  box-shadow: var(--shadow-lift);
  animation: pop .45s cubic-bezier(.34,1.56,.64,1);
}
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.checkmark {
  width: 96px; height: 96px; border-radius: 50%;
  display: block; margin: 0 auto;
  stroke-width: 5; stroke: #fff; stroke-miterlimit: 10;
  box-shadow: inset 0 0 0 #22c55e;
  animation: fillGreen .5s ease-in-out .35s forwards, scaleUp .3s ease-in-out .8s both;
}
.checkmark-circle {
  stroke-dasharray: 166; stroke-dashoffset: 166;
  stroke-width: 5; stroke: #22c55e; fill: none;
  animation: stroke .55s cubic-bezier(.65,0,.45,1) forwards;
}
.checkmark-check {
  transform-origin: 50% 50%;
  stroke-dasharray: 48; stroke-dashoffset: 48;
  animation: stroke .35s cubic-bezier(.65,0,.45,1) .7s forwards;
}
@keyframes stroke { to { stroke-dashoffset: 0; } }
@keyframes scaleUp { 0%,100%{transform:none} 50%{transform:scale(1.08)} }
@keyframes fillGreen { to { box-shadow: inset 0 0 0 52px #22c55e; } }

/* ---------- Confirm dialog ---------- */
.confirm-overlay {
  position: fixed; inset: 0;
  z-index: 96;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(30,27,46,.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.confirm-overlay.show { display: grid; animation: fadeIn .2s ease; }
.confirm-card {
  background: #fff;
  border-radius: 26px;
  padding: 28px 24px;
  text-align: center;
  width: min(92%, 360px);
  box-shadow: var(--shadow-lift);
  animation: pop .4s cubic-bezier(.34,1.56,.64,1);
}
.confirm-icon {
  width: 64px; height: 64px;
  border-radius: 20px;
  display: grid; place-items: center;
  margin: 0 auto 14px;
  font-size: 26px;
  color: var(--danger);
  background: rgba(225,29,72,.12);
}
.btn-danger {
  background: linear-gradient(135deg, #e11d48, #f43f5e);
  color: #fff; font-weight: 700; border-radius: 16px;
  box-shadow: 0 14px 30px -10px rgba(225,29,72,.6);
}

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed;
  left: 50%; bottom: calc(var(--nav-h) + 18px);
  transform: translateX(-50%);
  z-index: 95;
  width: min(92%, 420px);
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow-lift);
  animation: toastIn .45s cubic-bezier(.22,1,.36,1), toastOut .4s ease forwards 3.2s;
}
.toast.whatsapp { background: linear-gradient(135deg, #25D366, #128C7E); }
.toast.info     { background: linear-gradient(135deg, var(--brand-1), var(--brand-3)); }
.toast.warn     { background: linear-gradient(135deg, #f59e0b, #ea580c); }
.toast .t-ic { width: 34px; height: 34px; border-radius: 12px; display:grid; place-items:center; background: rgba(255,255,255,.22); font-size: 16px; flex: none; }
@keyframes toastIn { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastOut { to { transform: translateY(30px); opacity: 0; } }

/* ---------- Lists ---------- */
.list-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px;
  border-radius: 18px;
}
.avatar {
  width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center;
  font-weight: 800; color: #fff;
  flex: none;
}

/* Horizontal scroll rows */
.hscroll { display: flex; gap: 14px; overflow-x: auto; padding: 4px 0 8px; scroll-snap-type: x mandatory; }
.hscroll > * { scroll-snap-align: start; }
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { scrollbar-width: none; -ms-overflow-style: none; }

/* Autocomplete dropdown */
.ac-list {
  position: absolute;
  left: 0; right: 0; top: calc(100% + 8px);
  z-index: 30;
  border-radius: 18px;
  overflow: hidden;
  max-height: 260px; overflow-y: auto;
}
.ac-item { padding: 13px 16px; display:flex; justify-content:space-between; align-items:center; cursor: pointer; transition: background .15s ease; }
.ac-item:active, .ac-item.hi { background: rgba(139,92,246,.12); }

/* Coming soon / disabled */
.locked { position: relative; filter: grayscale(.7); opacity: .7; }
.locked::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  background: repeating-linear-gradient(45deg, rgba(0,0,0,.02) 0 12px, rgba(0,0,0,.05) 12px 24px);
}

/* PIN dots */
.pin-box {
  width: 52px; height: 58px;
  border-radius: 16px;
  border: 2px solid rgba(109,40,217,.15);
  background: #fff;
  text-align: center;
  font-size: 24px; font-weight: 800;
  color: var(--brand-1);
}
.pin-box:focus { border-color: var(--brand-2); box-shadow: 0 0 0 4px rgba(139,92,246,.14); outline: none; }

/* Segmented control */
.segment { display: flex; padding: 5px; border-radius: 16px; gap: 4px; }
.segment button {
  flex: 1; padding: 10px; border-radius: 12px;
  font-weight: 700; font-size: 13px; color: var(--ink-soft);
  transition: all .25s ease;
}
.segment button.active {
  background: #fff; color: var(--brand-1);
  box-shadow: 0 6px 14px -6px rgba(109,40,217,.4);
}

/* Count-up flip feel */
.metric-value { font-variant-numeric: tabular-nums; letter-spacing: -.5px; }

/* Scrollbar for dropdowns */
.thin-scroll::-webkit-scrollbar { width: 6px; }
.thin-scroll::-webkit-scrollbar-thumb { background: rgba(109,40,217,.2); border-radius: 10px; }

/* Empty-state */
.empty {
  text-align: center; padding: 40px 20px; color: var(--ink-soft);
}
.empty i { font-size: 34px; opacity: .35; }

/* Cart quantity stepper */
.qty-stepper {
  display: flex; align-items: center; gap: 2px;
  background: rgba(109,40,217,.08);
  border-radius: 12px;
  padding: 3px;
  flex: none;
}
.qty-stepper button {
  width: 30px; height: 30px;
  border-radius: 9px;
  font-size: 19px; font-weight: 800; line-height: 1;
  color: var(--brand-1);
  display: grid; place-items: center;
  transition: background .15s ease;
}
.qty-stepper button:active { background: rgba(109,40,217,.18); transform: scale(.9); }
.qty-stepper span { min-width: 26px; text-align: center; font-weight: 800; font-size: 15px; color: var(--ink); }

/* Sub-view swap (stock list <-> form) */
.swap-in { animation: screenIn .34s cubic-bezier(.22,1,.36,1); }

/* Payment-mode selector */
.paymode {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 13px 6px;
  border-radius: 16px;
  border: 1.5px solid rgba(109,40,217,.12);
  background: rgba(255,255,255,.75);
  font-weight: 700; font-size: 13px;
  color: var(--ink-soft);
  transition: transform .14s cubic-bezier(.34,1.56,.64,1), box-shadow .2s ease, background .2s ease, color .2s ease, border-color .2s ease;
}
.paymode i { font-size: 19px; }
.paymode.active { color: #fff; border-color: transparent; }
.paymode.active.pm-cash   { background: linear-gradient(135deg,#059669,#10b981); box-shadow: 0 10px 22px -8px rgba(5,150,105,.6); }
.paymode.active.pm-online { background: linear-gradient(135deg,#6d28d9,#8b5cf6); box-shadow: 0 10px 22px -8px rgba(139,92,246,.6); }
.paymode.active.pm-card   { background: linear-gradient(135deg,#0284c7,#0ea5e9); box-shadow: 0 10px 22px -8px rgba(2,132,199,.6); }

/* Pulse for live dot */
.pulse-dot { position: relative; }
.pulse-dot::before {
  content:""; position:absolute; inset:-4px; border-radius:50%;
  background: currentColor; opacity:.4; animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse { 0%{transform:scale(.6);opacity:.5} 100%{transform:scale(1.8);opacity:0} }
