/* Simple & Clean - UPI QR Maker - Dark + Micro Animations */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #3B82F6;
  --primary-dark: #2563EB;
  --bg: #0F172A;
  --bg-soft: #131E33;
  --card: #1E293B;
  --card-soft: #27354F;
  --text: #F1F5F9;
  --muted: #94A3B8;
  --border: #334155;
  --border-strong: #475569;
  --success: #22C55E;
  --error: #F87171;
  --radius: 16px;
  --radius-sm: 10px;
}
/* Light theme overrides */
[data-theme="light"] {
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --bg: #F1F5F9;
  --bg-soft: #E2E8F0;
  --card: #FFFFFF;
  --card-soft: #F8FAFC;
  --text: #0F172A;
  --muted: #64748B;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --success: #059669;
  --error: #DC2626;
}

/* --- Micro Animation Keyframes --- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes scaleSpring {
  0% { opacity: 0; transform: scale(0.96) translateY(6px); }
  60% { opacity: 1; transform: scale(1.01) translateY(0); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes pop {
  from { opacity:0; transform: translateY(8px) scale(.97); }
  to { opacity:1; transform: none; }
}
@keyframes pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(0.9); }
}
@keyframes float {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}
@keyframes ripple {
  to { transform: scale(2.5); opacity: 0; }
}
@keyframes qrGlow {
  0%,100% { box-shadow: 0 0 0 0 rgba(59,130,246,0.0); }
  50% { box-shadow: 0 0 0 6px rgba(59,130,246,0.12); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

html {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
/* Fast scroll & GPU */
* { -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
  content-visibility: auto;
  contain: paint;
}
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 24px;
  contain: layout style;
}
/* Header with subtle entrance - GPU accelerated */
.header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  animation: fadeInUp 0.4s ease both;
  backdrop-filter: blur(8px);
  will-change: transform;
  transform: translateZ(0);
  contain: layout paint;
}
.header-inner {
  max-width: 480px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon {
  width: 40px; height: 40px;
  background: var(--primary);
  color: white;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 20px; font-weight: 800;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: float 4s ease-in-out infinite;
}
.logo:hover .logo-icon { transform: scale(1.05) rotate(3deg); box-shadow: 0 4px 12px rgba(59,130,246,0.3); }
.logo h1 { font-size: 18px; font-weight: 700; line-height: 1; }
.logo p { font-size: 12px; color: var(--muted); font-weight: 500; }
.icon-btn {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  background: var(--card-soft);
  border-radius: 10px;
  display: grid; place-items: center;
  cursor: pointer; color: var(--muted);
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  touch-action: manipulation;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--text); transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,0.2); }
.icon-btn:active { transform: scale(0.92); }

.main { padding: 16px; display: flex; flex-direction: column; gap: 16px; }

/* Cards with stagger entrance - isolated for fast paint */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  animation: fadeInUp 0.5s cubic-bezier(0.2,0.8,0.2,1) both;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  contain: layout paint style;
  content-visibility: auto;
  contain-intrinsic-size: 200px;
}
.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.12s; }
.card:nth-child(3) { animation-delay: 0.18s; }
.card:hover { border-color: var(--border-strong); }
.card h2 { font-size: 18px; font-weight: 700; }
.card-icon {
  width: 28px; height: 28px;
  background: rgba(59,130,246,0.15);
  color: var(--primary);
  border: 1px solid rgba(59,130,246,0.25);
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 800;
  margin-bottom: 10px;
  transition: transform 0.2s ease;
}
.card:hover .card-icon { transform: scale(1.08); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 6px; display: block; }
.center { text-align: center; }
.req { color: var(--error); }
.optional { color: var(--muted); font-weight: 400; font-size: 13px; }
.error-text { color: var(--error); font-size: 12px; margin-top: 4px; display: block; min-height: 16px; }
.error-text:not(:empty) { animation: shake 0.35s ease; }

/* Inputs with micro interactions */
label { font-size: 13px; font-weight: 600; display: block; margin-bottom: 6px; margin-top: 4px; }
input {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  background: var(--card);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease, background 0.2s ease;
}
input:hover { border-color: var(--border-strong); }
input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.25); transform: translateY(-1px); background: var(--card); }
input::placeholder { color: #64748B; transition: opacity 0.2s; }
input:focus::placeholder { opacity: 0.6; }
input.shake { animation: shake 0.35s ease; }

/* Amount */
.amount-wrap { position: relative; }
.amount-wrap .rupee {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-size: 18px; font-weight: 800; color: var(--text);
  transition: transform 0.2s ease, color 0.2s ease;
  pointer-events: none;
}
.amount-wrap:focus-within .rupee { transform: translateY(-50%) scale(1.08); color: var(--primary); }
.amount-wrap input {
  padding-left: 30px;
  font-size: 22px; font-weight: 700;
  letter-spacing: -0.5px;
}
.quick-amounts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.chip {
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--card-soft);
  color: var(--text);
  border-radius: 999px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.2,0.8,0.2,1);
  position: relative;
  overflow: hidden;
}
.chip:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); border-color: var(--border-strong); }
.chip:active { transform: scale(0.96); }
.chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(59,130,246,0.35);
  animation: scaleSpring 0.35s ease;
}

/* Buttons with ripple and press - fast tap */
.btn {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px; font-weight: 700;
  border: 1.5px solid transparent;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: all 0.2s cubic-bezier(0.2,0.8,0.2,1);
  position: relative;
  overflow: hidden;
  user-select: none;
  touch-action: manipulation;
  will-change: transform;
}
.btn::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 12px; height: 12px;
  background: rgba(255,255,255,0.35);
  border-radius: 50%;
  transform: translate(-50%,-50%) scale(0);
  opacity: 0;
  pointer-events: none;
}
.btn:active::after { animation: ripple 0.5s ease-out; }
.btn.full { width: 100%; }
.btn.primary { background: var(--primary); color: white; box-shadow: 0 2px 10px rgba(59,130,246,0.25); }
.btn.primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(59,130,246,0.35); }
.btn.primary:active { transform: scale(0.97); box-shadow: 0 2px 8px rgba(59,130,246,0.25); }
.btn.outline { background: var(--card-soft); border-color: var(--border-strong); color: var(--text); }
.btn.outline:hover { background: var(--bg-soft); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.btn.outline:active { transform: scale(0.97); }
.btn.small { padding: 7px 12px; font-size: 12px; border-radius: 999px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); font-weight: 600; }
.btn.ghost:hover { background: var(--bg-soft); color: var(--error); transform: translateY(-1px); }

/* Saved UPI bar with slide */
.saved-upi {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  animation: slideIn 0.4s ease both;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.saved-upi:hover { transform: translateY(-1px); border-color: var(--border-strong); }
.saved-upi-left { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.badge {
  font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--success); background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.25);
  padding: 2px 6px; border-radius: 6px; width: fit-content;
  animation: pulse 2.5s ease infinite;
}
#displayUpi { font-size: 14px; word-break: break-all; }
.divider { height: 1px; background: var(--border); margin: 16px 0; position: relative; overflow: hidden; }
.divider::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(59,130,246,0.25), transparent);
  background-size: 200% 100%;
  animation: shimmer 2.5s linear infinite;
  opacity: 0.6;
}

/* QR Area with spring */
.qr-area {
  margin-top: 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  text-align: center;
  animation: scaleSpring 0.45s cubic-bezier(0.2,0.8,0.2,1) both;
}
.qr-area.qr-pulse { animation: qrGlow 1.2s ease; }
.qr-label {
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-bottom: 12px;
}
.qr-label .dot { width:8px; height:8px; background: var(--success); border-radius:50%; display:inline-block; animation: pulse 1.5s infinite; box-shadow: 0 0 0 4px rgba(34,197,94,0.15); }
.qr-box {
  background: white;
  border-radius: 12px;
  padding: 14px;
  display: inline-block;
  border: 1px solid var(--border);
  line-height: 0;
  transition: transform 0.3s cubic-bezier(0.2,0.8,0.2,1), box-shadow 0.3s ease;
  animation: scaleSpring 0.5s 0.15s both;
}
.qr-box:hover { transform: scale(1.02); box-shadow: 0 8px 24px rgba(0,0,0,0.2); }
.qr-box img, .qr-box canvas { width: 200px !important; height: 200px !important; display: block; }
.amount-display {
  margin-top: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex; align-items: center; justify-content: space-between;
  transition: transform 0.2s ease, border-color 0.2s ease;
  animation: fadeInUp 0.4s 0.2s both;
}
.amount-display:hover { transform: translateY(-1px); border-color: var(--border-strong); }
.amount-display span { font-size: 12px; color: var(--muted); font-weight: 600; }
.amount-display strong { font-size: 18px; transition: transform 0.2s ease; }
.amount-display:hover strong { transform: scale(1.05); }
.qr-upi-text { font-size: 11px; color: var(--muted); margin-top: 8px; word-break: break-all; opacity: 0.8; font-family: ui-monospace, monospace; }
.qr-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.qr-actions .btn { animation: fadeInUp 0.4s both; }
.qr-actions .btn:nth-child(1) { animation-delay: 0.25s; }
.qr-actions .btn:nth-child(2) { animation-delay: 0.32s; }
.empty-hint {
  margin-top: 14px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  color: var(--muted);
  background: var(--bg-soft);
  transition: all 0.2s ease;
  animation: fadeInUp 0.4s 0.1s both;
}
.empty-hint:hover { border-color: var(--primary); background: rgba(59,130,246,0.06); transform: translateY(-1px); }
.empty-hint .empty-icon { font-size: 28px; margin-bottom: 6px; opacity:.5; transition: transform 0.3s ease; }
.empty-hint:hover .empty-icon { transform: scale(1.1) rotate(5deg); opacity: 0.8; }
.empty-hint p { font-size: 13px; font-weight: 600; line-height: 1.4; }

/* History with stagger */
.history-head { display: flex; align-items: center; justify-content: space-between; }
.history-list { display: flex; flex-direction: column; gap: 8px; content-visibility: auto; contain-intrinsic-size: 300px; }
.history-item {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--card-soft);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.2,0.8,0.2,1);
  animation: fadeInUp 0.35s both;
  position: relative;
  overflow: hidden;
}
.history-item::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--primary);
  transform: scaleY(0); transition: transform 0.2s ease;
}
.history-item:hover { border-color: var(--border-strong); background: var(--bg-soft); transform: translateY(-2px) translateX(2px); box-shadow: 0 6px 16px rgba(0,0,0,0.2); }
.history-item:hover::before { transform: scaleY(1); }
.history-item:active { transform: scale(0.98); }
.history-item:nth-child(1) { animation-delay: 0.02s; }
.history-item:nth-child(2) { animation-delay: 0.06s; }
.history-item:nth-child(3) { animation-delay: 0.10s; }
.history-item:nth-child(4) { animation-delay: 0.14s; }
.history-item:nth-child(5) { animation-delay: 0.18s; }
.hist-amount { font-size: 15px; font-weight: 800; transition: transform 0.2s ease; }
.history-item:hover .hist-amount { transform: translateX(2px); color: var(--primary); }
.hist-meta { font-size: 12px; color: var(--muted); }
.hist-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.hist-date { font-size: 11px; color: var(--muted); text-align: right; line-height: 1.2; }
.hist-del {
  width: 28px; height: 28px;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--card); color: var(--muted);
  display: grid; place-items: center; cursor: pointer;
  transition: all 0.2s cubic-bezier(0.2,0.8,0.2,1);
}
.hist-del:hover { color: var(--error); border-color: rgba(248,113,113,0.4); background: rgba(248,113,113,0.12); transform: scale(1.08) rotate(5deg); }
.hist-del:active { transform: scale(0.92); }
.history-empty {
  text-align: center; padding: 20px 16px;
  border: 1px dashed var(--border-strong); border-radius: 12px; background: var(--bg-soft);
  animation: fadeInUp 0.4s both;
  transition: all 0.2s ease;
}
.history-empty:hover { border-color: var(--border-strong); }
.history-empty p { font-weight: 700; font-size: 14px; }
.footer-note { text-align: center; font-size: 11px; color: var(--muted); padding: 8px 12px 2px; line-height: 1.4; animation: fadeInUp 0.4s 0.3s both; }
.footer-credit { text-align: center; font-size: 12px; color: var(--muted); padding: 2px 12px 8px; line-height: 1.4; animation: fadeInUp 0.4s 0.35s both; letter-spacing: 0.2px; }
.footer-credit strong { color: var(--text); font-weight: 800; letter-spacing: 0.6px; }

/* Modal with spring */
.modal { position: fixed; inset: 0; display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(2,6,23,0.7); backdrop-filter: blur(6px); animation: fadeInUp 0.25s ease both; }
.modal-box {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  width: 100%; max-width: 400px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
  animation: scaleSpring 0.4s cubic-bezier(0.2,0.8,0.2,1) both;
}
.modal-box h3 { font-size: 16px; margin-bottom: 12px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
#qrModal .modal-box { max-height: 92vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* Toast with spring */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: #F1F5F9; color: #0F172A;
  padding: 10px 16px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 60;
  transition: all 0.35s cubic-bezier(0.2,0.8,0.2,1);
  max-width: 90vw;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.hidden { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(16px) scale(0.96); }
.toast:not(.hidden) { animation: scaleSpring 0.4s ease; }

/* Helpers */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.shake { animation: shake 0.35s ease !important; }
.removing { animation: fadeInUp 0.25s reverse forwards !important; opacity: 0; transform: scale(0.96); }

/* Success tick micro animation */
@keyframes tick {
  0% { transform: scale(0) rotate(-10deg); opacity: 0; }
  60% { transform: scale(1.15) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.success-tick { display: inline-block; animation: tick 0.4s cubic-bezier(0.2,0.8,0.2,1) both; }

/* Low-end Android: reduce blur & heavy shadows */
@media (max-width: 380px), (max-height: 640px) {
  .header { backdrop-filter: none; }
  .card { box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
  .btn.primary { box-shadow: none; }
}
/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Desktop tweak */
@media (min-width: 500px) {
  .main { padding: 20px; }
}
