/* =============================================================================
   Onetech UPI QR Generator — styles
   Layout: form on the left, preview on the right (stacks on mobile).
   ========================================================================== */

:root {
  --brand:          #1d4ed8;
  --brand-dark:     #1e3a8a;
  --brand-light:    #eff6ff;
  --accent:         #0ea5e9;
  --ink:            #0f172a;
  --ink-soft:       #475569;
  --ink-faint:      #94a3b8;
  --line:           #e2e8f0;
  --surface:        #ffffff;
  --bg:             #f1f5f9;
  --share:          #059669;
  --share-dark:     #047857;
  --danger:         #dc2626;
  --danger-soft:    #fef2f2;
  --warn:           #b45309;
  --warn-soft:      #fffbeb;
  --ok:             #059669;

  --radius:         12px;
  --radius-lg:      18px;
  --shadow-sm:      0 1px 2px rgba(15, 23, 42, .06);
  --shadow:         0 6px 24px rgba(15, 23, 42, .08);
  --font:           system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono:           ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must win over any display rule below — canvases carry
   `display: block`, which would otherwise keep them visible when hidden. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------- header --- */

.app-header {
  background: linear-gradient(135deg, var(--brand-dark), var(--brand) 60%, var(--accent));
  color: #fff;
  padding: 22px 20px;
}

.app-header__inner,
.layout,
.notice,
.app-footer p {
  max-width: 1180px;
  margin-inline: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .28);
  font-size: 24px;
  font-weight: 700;
  flex: none;
}

.brand__name {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 650;
  letter-spacing: -.01em;
}

.brand__tagline {
  margin: 2px 0 0;
  font-size: .85rem;
  opacity: .85;
}

/* ------------------------------------------------------------------ lock --- */

/* While locked, the app is not just covered — it is not rendered at all. */
.is-locked { overflow: hidden; }

.is-locked .app-header,
.is-locked .layout,
.is-locked .app-footer,
.is-locked .notice {
  display: none;
}

.lock {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(170deg, #12346f 0%, #0b1a33 55%, #060f22 100%);
}

.lock__box {
  width: 100%;
  max-width: 330px;
  background: #fff;
  border-radius: 18px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(2, 8, 23, .45);
}

.lock__logo {
  display: block;
  width: 100%;
  max-width: 210px;
  height: auto;
  margin: 0 auto 18px;
}

.lock__title {
  margin: 0 0 14px;
  font-size: .95rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.lock__input {
  width: 100%;
  padding: 12px;
  font: inherit;
  font-size: 1.5rem;
  letter-spacing: .4em;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.lock__input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, .12);
}

.lock__error {
  margin: 10px 0 0;
  min-height: 1em;
  font-size: .8rem;
  color: var(--danger);
}

.lock__submit {
  width: 100%;
  margin-top: 12px;
}

/* ---------------------------------------------------------------- notice --- */

.notice {
  margin-top: 18px;
  margin-bottom: -6px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .88rem;
  width: calc(100% - 40px);
}

.notice--warn {
  background: var(--warn-soft);
  border: 1px solid #fcd34d;
  color: var(--warn);
}

.notice code {
  font-family: var(--mono);
  background: rgba(180, 83, 9, .1);
  padding: 1px 6px;
  border-radius: 5px;
}

/* ---------------------------------------------------------------- layout --- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  padding: 24px 20px 40px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}

.panel--preview {
  position: sticky;
  top: 20px;
}

.panel__title {
  margin: 0 0 18px;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: .01em;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

/* ----------------------------------------------------------------- form --- */

.field { margin-bottom: 16px; }
.field--nested { margin-bottom: 4px; }

.field__labelrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.field__label {
  display: block;
  margin-bottom: 6px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.field__labelrow .field__label { margin-bottom: 0; }

.req   { color: var(--danger); }
.opt   { color: var(--ink-faint); font-weight: 400; }

.field__hint {
  margin: 6px 0 0;
  font-size: .76rem;
  color: var(--ink-faint);
}

.field__msg {
  margin: 6px 0 0;
  font-size: .78rem;
  color: var(--danger);
  min-height: 0;
}

.field__msg:empty { display: none; }

.field__msg--warn { color: var(--warn); }

.field__row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.field__row .input { flex: 1 1 auto; }

.input {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-size: .92rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}

.input::placeholder { color: #cbd5e1; }

.input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, .12);
}

.input--invalid,
.input--invalid:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .1);
}

/* The client payment link gets its own tinted block — it is the thing you send */
.field--highlight {
  padding: 14px;
  margin-bottom: 18px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: var(--radius);
}

.badge {
  font-size: .68rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #fff;
  background: var(--share);
  border-radius: 20px;
  padding: 3px 9px;
}

.link-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

/* WhatsApp row inside the link block */
.wa {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed #a7f3d0;
}

.wa__row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex-wrap: wrap;
}

.wa__cc {
  display: grid;
  place-items: center;
  padding: 0 11px;
  font-size: .86rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: #fff;
  border: 1px solid #a7f3d0;
  border-radius: var(--radius);
}

.wa__input {
  flex: 1 1 130px;
  min-width: 0;
  background: #fff;
  border-color: #a7f3d0;
}

.wa__input:focus {
  border-color: var(--share);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, .14);
}

.btn--wa {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: #25d366;
  border-color: #25d366;
  color: #06301a;
}

.btn--wa:hover { background: #1fbe5b; border-color: #1fbe5b; }

.input--link {
  background: #fff;
  border-color: #a7f3d0;
  color: var(--share-dark);
}

.input--link:focus {
  border-color: var(--share);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, .14);
}

.input--uri {
  font-family: var(--mono);
  font-size: .78rem;
  line-height: 1.45;
  background: var(--brand-light);
  border-color: #dbeafe;
  color: var(--brand-dark);
  resize: vertical;
  word-break: break-all;
}

/* UPI ID dropdown + the "Other" box that appears under it */
select.input {
  appearance: none;
  cursor: pointer;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%2394a3b8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 11px;
}

.upi-custom {
  margin-top: 8px;
}

/* Amount field with a rupee prefix */
.input-prefix { position: relative; }

.input-prefix__symbol {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-faint);
  font-size: .92rem;
  pointer-events: none;
}

.input--prefixed { padding-left: 28px; }

.counter {
  font-size: .72rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
  background: var(--bg);
  border-radius: 20px;
  padding: 2px 9px;
  white-space: nowrap;
}

.counter--near { color: var(--warn); background: var(--warn-soft); }
.counter--over { color: var(--danger); background: var(--danger-soft); }

/* ------------------------------------------------------------- advanced --- */

.advanced {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 14px;
  margin-bottom: 16px;
  background: #fbfdff;
}

.advanced__summary {
  cursor: pointer;
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 9px 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.advanced__summary::-webkit-details-marker { display: none; }

.advanced__summary::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid var(--ink-faint);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform .15s;
}

.advanced[open] .advanced__summary::before { transform: rotate(90deg); }

/* -------------------------------------------------------------- buttons --- */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.btn {
  appearance: none;
  font: inherit;
  font-size: .86rem;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
  white-space: nowrap;
}

.btn:hover  { background: var(--bg); border-color: #cbd5e1; }
.btn:active { transform: translateY(1px); }

.btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.btn[disabled] {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}

.btn--primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn--primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

.btn--accent {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.btn--accent:hover { background: #1e293b; border-color: #1e293b; }

.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--brand);
}
.btn--ghost:hover { background: var(--brand-light); border-color: transparent; }

.btn--danger-ghost { color: var(--danger); }
.btn--danger-ghost:hover { background: var(--danger-soft); border-color: #fecaca; }

.btn--small { padding: 6px 12px; font-size: .78rem; }

/* The one-tap action: payment card + link in a single message */
.btn--send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--share), #0f766e);
  border-color: var(--share-dark);
  color: #fff;
  box-shadow: 0 4px 12px rgba(5, 150, 105, .28);
}

.btn--send:hover {
  background: linear-gradient(135deg, var(--share-dark), #115e59);
  border-color: var(--share-dark);
}

.send-note {
  margin: 10px 0 0;
  font-size: .78rem;
  color: var(--ink-faint);
}

.send-note:empty { display: none; }

.send-note--warn {
  color: var(--warn);
  background: var(--warn-soft);
  border: 1px solid #fcd34d;
  border-radius: var(--radius);
  padding: 8px 11px;
}

/* Share buttons (Web Share API — opens the phone/desktop share sheet) */
.btn--share {
  background: var(--share);
  border-color: var(--share);
  color: #fff;
}
.btn--share:hover { background: var(--share-dark); border-color: var(--share-dark); }

.btn--share-ghost {
  color: var(--share-dark);
  border-color: #a7f3d0;
  background: #ecfdf5;
}
.btn--share-ghost:hover { background: #d1fae5; border-color: #6ee7b7; }

/* Buttons that carry an icon */
.btn--share,
.btn--share-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.btn__icon {
  width: 15px;
  height: 15px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* -------------------------------------------------------------- preview --- */

.preview {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.preview__label {
  margin: 0 0 8px;
  font-size: .74rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-faint);
}

.card-frame,
.qr-frame {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  display: grid;
  place-items: center;
  min-height: 120px;
}

.card-canvas,
.qr-canvas {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.card-canvas { box-shadow: var(--shadow); }

.qr-frame { background: #fff; }

.card-frame__msg {
  margin: 0;
  padding: 18px 12px;
  font-size: .8rem;
  color: var(--ink-faint);
  text-align: center;
}

.qr-meta {
  margin: 8px 0 0;
  font-size: .72rem;
  color: var(--ink-faint);
  text-align: center;
}

/* -------------------------------------------------------------- summary --- */

.summary {
  margin: 20px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
}

.summary__row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 12px;
  font-size: .84rem;
}

.summary dt {
  color: var(--ink-faint);
  font-size: .78rem;
  padding-top: 1px;
}

.summary dd {
  margin: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.summary dd.is-empty { color: var(--ink-faint); }

/* --------------------------------------------------------------- footer --- */

.app-footer {
  padding: 0 20px 32px;
  text-align: center;
}

.app-footer p {
  margin: 0;
  font-size: .78rem;
  color: var(--ink-faint);
}

.app-footer__credit {
  margin-top: 6px !important;
  font-size: .76rem;
}

.app-footer__credit a {
  color: var(--brand);
  font-weight: 600;
  text-decoration: none;
}

.app-footer__credit a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- toast --- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  font-size: .84rem;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 50;
  animation: toast-in .18s ease-out;
}

.toast--error { background: var(--danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* --------------------------------------------------------------- mobile --- */

@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .panel--preview {
    position: static;
  }
  .preview {
    grid-template-columns: minmax(0, 1fr);
  }
  /* width first, then the cap — so the canvas can never outgrow its frame */
  .card-canvas { width: 100%; max-width: 340px; }
  .qr-canvas   { width: 100%; max-width: 240px; }
}

@media (max-width: 520px) {
  .actions .btn { flex: 1 1 auto; text-align: center; }
  .summary__row { grid-template-columns: 92px minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Partner branding in the generator footer */
.app-footer__partner {
  margin-top: 8px !important;
  font-size: .78rem;
  line-height: 1.6;
  color: var(--ink-soft);
}

.app-footer__partner a {
  color: var(--brand);
  font-weight: 600;
  text-decoration: none;
}

.app-footer__partner a:hover { text-decoration: underline; }
