/* ===== Stripe-style checkout ===== */
:root {
  --ink: #30313d;
  --ink-soft: #4f566b;
  --muted: #6a7383;
  --line: #e6e6e6;
  --line-strong: #d5d8dd;
  --bg: #ffffff;
  --bg-soft: #fafbfc;
  --accent: #635bff;
  --accent-hover: #514dcc;
  --accent-ring: rgba(99, 91, 255, 0.25);
  --radius: 8px;
  --shadow-input: 0 1px 1px rgba(0, 0, 0, 0.03);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Ubuntu, "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.checkout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}

/* ---------- left : summary ---------- */
.summary {
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
}
.summary__inner {
  width: 100%;
  max-width: 420px;
  padding: 40px 44px 28px;
  display: flex;
  flex-direction: column;
}

.brandbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 44px;
}
.back {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--ink-soft);
  text-decoration: none;
  transition: background 0.15s ease;
}
.back:hover { background: rgba(0, 0, 0, 0.05); }
.merchant { display: flex; align-items: center; gap: 10px; }
.merchant__logo {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: linear-gradient(135deg, #7b6cff, #b46cff);
  color: #fff;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.5px;
  display: grid;
  place-items: center;
}
.merchant__name { font-weight: 600; font-size: 0.98rem; color: var(--ink); }

.summary__amount-label { font-size: 0.95rem; color: var(--muted); margin-bottom: 6px; }
.summary__amount {
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--ink);
  margin-bottom: 30px;
}

.line-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.line-item__media {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  flex: none;
}
.line-item__body { flex: 1; min-width: 0; }
.line-item__name { font-weight: 600; font-size: 0.92rem; line-height: 1.3; }
.line-item__desc { font-size: 0.82rem; color: var(--muted); margin-top: 2px; }
.line-item__price { font-weight: 600; font-size: 0.92rem; white-space: nowrap; }

.totals { margin-top: 6px; border-top: 1px solid var(--line); padding-top: 14px; }
.totals__row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--ink-soft);
  padding: 7px 0;
}
.totals__row--grand {
  color: var(--ink);
  font-weight: 600;
  font-size: 1rem;
  border-top: 1px solid var(--line);
  margin-top: 6px;
  padding-top: 14px;
}

.summary__foot {
  margin-top: auto;
  padding-top: 34px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--muted);
}
.summary__foot b { color: var(--ink-soft); }
.summary__foot a { color: var(--muted); text-decoration: none; }
.summary__foot a:hover { color: var(--ink-soft); }
.summary__foot .dot { opacity: 0.6; }

/* ---------- right : payment ---------- */
.pay { display: flex; justify-content: flex-start; }
.pay__inner {
  width: 100%;
  max-width: 420px;
  padding: 40px 44px 48px;
}

.field { margin-bottom: 14px; }
.field > label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.field .hint { color: var(--muted); font-weight: 400; }

input,
select {
  width: 100%;
  font-family: var(--font);
  font-size: 0.95rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 11px 12px;
  outline: none;
  box-shadow: var(--shadow-input);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder { color: #9aa0ac; }
input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.select-wrap { position: relative; }
select { appearance: none; cursor: pointer; padding-right: 34px; }
.select-caret {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

/* combined card element (the signature Stripe field) */
.card-group {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-input);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  overflow: hidden;
}
.card-group.is-focused {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.card-group input {
  border: none;
  border-radius: 0;
  box-shadow: none;
}
.card-group input:focus { box-shadow: none; }
.card-cell { position: relative; }
.card-cell--number input { padding-right: 130px; }
.card-brands {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 4px;
  pointer-events: none;
}
.brand { width: 26px; height: 17px; border-radius: 3px; }
.card-cell-row { display: flex; border-top: 1px solid var(--line); }
.card-cell-row .card-cell { flex: 1; }
.card-cell--exp { border-right: 1px solid var(--line); }
.card-cell--cvc input { padding-right: 40px; }
.cvc-icon { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }

.form-error {
  margin: 4px 0 12px;
  color: #b3261e;
  background: #fff0ef;
  border: 1px solid #f3c9c5;
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 0.85rem;
}

.pay-btn {
  width: 100%;
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}
.pay-btn:hover { background: var(--accent-hover); }
.pay-btn:active { transform: translateY(1px); }
.pay-btn:disabled { opacity: 0.7; cursor: default; }
.pay-btn__icon { display: inline-flex; opacity: 0.9; }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.secure {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
  font-size: 0.78rem;
  color: var(--muted);
}

/* ---------- processing ---------- */
.proc {
  position: fixed;
  inset: 0;
  z-index: 30;
  place-items: center;
  padding: 22px;
  background: rgba(20, 22, 34, 0.55);
  backdrop-filter: blur(4px);
}
.proc[hidden] { display: none; }
.proc:not([hidden]) { display: grid; }

/* phase switching */
.proc .pcard,
.proc .acs { display: none; animation: proc-in 0.35s ease both; }
.proc[data-phase="stripe"] .pcard { display: block; }
.proc[data-phase="bank"] .acs { display: block; }
@keyframes proc-in {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.mini-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(99, 91, 255, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex: none;
}

/* phase 1 : stripe */
.pcard--stripe {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 60px -18px rgba(10, 12, 24, 0.55);
}
.pbar { height: 3px; background: #eef0f4; }
.pbar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
  transition: width 0.5s ease;
}
.pcard__body { padding: 24px 26px 20px; }
.phead { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.phead__lock {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: #f1f0ff;
  color: var(--accent);
  flex: none;
}
.phead__title { font-weight: 600; font-size: 0.98rem; color: var(--ink); }
.phead__amount { font-size: 0.85rem; color: var(--muted); margin-top: 1px; }
.pstatus {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 0.92rem;
  color: var(--ink);
  padding: 4px 0 6px;
}
.pfoot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 0.76rem;
  color: var(--muted);
}
.pfoot b { color: var(--ink-soft); }

/* phase 2 : bank 3-D Secure (ACS) */
.acs {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 24px 60px -18px rgba(10, 12, 24, 0.6);
  font-family: var(--font);
}
.acs__top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid #ececec;
}
.sg-logo { display: inline-flex; flex: none; }
.sg-logo svg { display: block; }
.acs__bank {
  font-weight: 700;
  font-size: 0.86rem;
  letter-spacing: 0.6px;
  color: #1d1d1b;
}
.acs__3ds {
  margin-left: auto;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: #6a7383;
  background: #f3f4f7;
  border: 1px solid #e6e6e6;
  border-radius: 5px;
  padding: 3px 7px;
}

.acs__body { padding: 22px 24px 18px; }
.acs__title {
  margin: 0 0 16px;
  font-size: 1.02rem;
  font-weight: 600;
  color: #1d1d1b;
}
.acs__rows { margin: 0 0 18px; }
.acs__rows > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid #f0f0f2;
  font-size: 0.9rem;
}
.acs__rows dt { margin: 0; color: #6a7383; }
.acs__rows dd { margin: 0; font-weight: 600; color: #1d1d1b; }

.acs__push { text-align: center; padding: 8px 0 4px; }
.acs__phone {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 12px;
  color: #e9041e;
}
.acs__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid #e9041e;
  opacity: 0;
  animation: acs-pulse 1.8s ease-out infinite;
}
@keyframes acs-pulse {
  0% { transform: scale(0.6); opacity: 0.55; }
  100% { transform: scale(1.5); opacity: 0; }
}
.acs__instr {
  margin: 0 auto 16px;
  max-width: 320px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #4f566b;
}
.acs__instr b { color: #1d1d1b; }
.acs__wait {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #1d1d1b;
}
.acs__wait.is-ok { color: #1c8a4e; }
.acs__wait.is-ko { color: #b3261e; }
.acs__wait.is-ok .mini-spinner,
.acs__wait.is-ko .mini-spinner { display: none; }

.acs__foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid #ececec;
  background: #fafbfc;
}
.acs__scheme {
  font-style: italic;
  font-weight: 700;
  font-size: 0.74rem;
  color: #1a1f71;
}
.acs__scheme span { font-weight: 400; margin-left: 3px; }
.acs__scheme--mc { color: #eb6100; font-style: normal; }
.acs__by { margin-left: auto; font-size: 0.72rem; color: #8a909c; }

/* ---------- success ---------- */
.success {
  position: fixed;
  inset: 0;
  z-index: 20;
  place-items: center;
  padding: 22px;
  background: rgba(247, 248, 250, 0.92);
  backdrop-filter: blur(3px);
}
.success[hidden] { display: none; }
.success:not([hidden]) { display: grid; }
.success__card {
  text-align: center;
  max-width: 400px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 40px 32px;
  box-shadow: 0 16px 50px -16px rgba(48, 49, 61, 0.3);
}
.success__check { margin-bottom: 14px; }
.success__card h2 { margin: 0 0 10px; font-size: 1.45rem; color: var(--ink); }
.success__card p { margin: 0 0 24px; color: var(--muted); font-size: 0.95rem; line-height: 1.5; }
.success__btn {
  display: inline-block;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  color: #fff;
  background: var(--accent);
  border-radius: var(--radius);
  padding: 11px 22px;
  transition: background 0.15s ease;
}
.success__btn:hover { background: var(--accent-hover); }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .checkout { grid-template-columns: 1fr; min-height: 0; }
  .summary { border-right: none; border-bottom: 1px solid var(--line); justify-content: center; }
  .pay { justify-content: center; }
  .summary__inner { max-width: 480px; padding: 30px 24px 24px; }
  .pay__inner { max-width: 480px; padding: 28px 24px 40px; }
  .brandbar { margin-bottom: 30px; }
  .summary__foot { padding-top: 26px; }
}
