/* Payments (P1–P4) and the parts the admin site shares: stat cards, tables, status labels,
   summary rows, info notices and modals. Load after /assets/auth/auth.css. */

.page { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-32); width: 100%; max-width: 1200px; }
.page__title { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-16); width: 100%; }
.page__title .t-body-lg { max-width: 800px; }
.t-h2 { font: var(--text-heading-h2); letter-spacing: var(--tracking-heading-h2); }
.t-strong { font-weight: 600; color: var(--content-primary); }

.badge--inverse { background: var(--surface-inverse); color: var(--content-accent-on-inverse); }
.badge--warning { background: var(--surface-warning-subtle); color: var(--content-warning); }
.badge--error { background: var(--surface-error-subtle); color: var(--content-error); }

.btn--auto { width: auto; }
.btn--fill { flex: 1 1 0; min-width: 0; }
.btn--lg .icon { width: 24px; height: 24px; }
.btn--ghost[aria-disabled="true"] { color: var(--content-disabled); cursor: default; background: transparent; }
.btn--secondary:disabled { border-color: var(--border-disabled); color: var(--content-disabled); background: var(--surface-panel); cursor: default; }
.btn--destructive { background: var(--surface-error); color: var(--content-on-inverse); }
.btn--destructive:hover { background: var(--surface-error-hover); }
.btn--destructive:disabled { background: var(--surface-disabled); color: var(--content-disabled); cursor: default; }
[data-theme="dark"] .btn--destructive { color: var(--content-on-accent); }

.icon--lock, .icon--calendar { -webkit-mask-size: 83.333% 91.667%; mask-size: 83.333% 91.667%; }
.icon--16 { width: 16px; height: 16px; }
.icon--32 { width: 32px; height: 32px; }

/* ---------- Notice: Info ---------- */
.notice--info { background: var(--surface-muted); border-color: var(--border-subtle); color: var(--content-primary); }
.notice--warning { background: var(--surface-warning-subtle); border-color: var(--border-warning); }
.notice--warning .icon, .notice--warning .notice__title { color: var(--content-warning); }
.notice--error .notice__body { color: var(--content-primary); }

/* ---------- SummaryRow ---------- */
.summary { display: flex; flex-direction: column; gap: var(--space-12); }
.summary-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-16); }
.summary-row > :first-child { color: var(--content-secondary); }
.summary-row > :last-child { font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.summary-row--total > * { color: var(--content-primary) !important; font-weight: 600; }
.summary-row--total > :last-child { font: var(--text-heading-h4); letter-spacing: var(--tracking-heading-h4); }

.secure { display: flex; align-items: flex-start; gap: var(--space-8); color: var(--content-secondary); }
.secure .icon { margin-top: .5px; }
.secure--inline { align-items: center; }

/* ---------- P1 Choose a plan ---------- */
.plans { display: flex; align-items: stretch; gap: var(--space-24); width: 100%; }
.plan-cards { display: contents; }
.plan-card {
  position: relative;
  flex: 0 0 384px;
  display: flex;
  flex-direction: column;
  gap: var(--space-20);
  padding: var(--space-24);
  background: var(--surface-panel);
  border: var(--stroke-default) solid var(--border-subtle);
  border-radius: var(--radius-card);
  cursor: pointer;
  transition: background-color .15s, border-color .15s, box-shadow .15s;
}
.plan-card:hover { border-color: var(--border-strong); }
.plan-card:has(input:checked) {
  background: var(--surface-accent-subtle);
  border-color: var(--border-focus);
  box-shadow: 0 12px 16px 0 var(--effect-shadow);
}
.plan-card:has(input:focus-visible) { box-shadow: var(--focus-ring); }
.plan-card input { position: absolute; opacity: 0; pointer-events: none; }
.plan-card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-12); }
.plan-card__name { display: flex; align-items: center; gap: var(--space-12); }
.radio {
  flex: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-full);
  background: var(--surface-panel);
}
input:checked + .radio, .plan-card:has(input:checked) .radio { border: 5px solid var(--border-focus); }
.plan-card__price { display: flex; flex-direction: column; gap: var(--space-4); }
.plan-card__amount { display: flex; align-items: baseline; gap: var(--space-12); }
.plan-card__amount strong { font: var(--text-heading-h1); letter-spacing: var(--tracking-heading-h1); }
.plan-card__amount s { font: var(--text-body-lg); color: var(--content-secondary); text-decoration: none; }
.features { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-12); font: var(--text-body-sm); }
.features li { display: flex; align-items: center; gap: var(--space-12); }
.plan-card__saving { font: var(--text-label-sm); color: var(--content-accent); }

.rules {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-16);
  padding: var(--space-24);
  background: var(--surface-panel);
  border: var(--stroke-default) solid var(--border-subtle);
  border-radius: var(--radius-card);
}
.rules ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-16); }
.rules li { display: flex; align-items: flex-start; gap: var(--space-12); font: var(--text-body-sm); }
.plans-notice { width: 100%; max-width: calc(384px * 2 + var(--space-24)); }
.buy-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-24); }

/* ---------- P2 Review and pay ---------- */
.checkout { display: flex; justify-content: center; align-items: flex-start; gap: 120px; width: 100%; }
.checkout__order { flex: 0 1 520px; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-24); }
.checkout__order > :not(.btn) { width: 100%; }
.box {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
  padding: var(--space-24);
  background: var(--surface-panel);
  border: var(--stroke-default) solid var(--border-subtle);
  border-radius: var(--radius-card);
}
.pay-card {
  flex: 0 0 440px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-16);
  padding: var(--space-32);
  background: var(--surface-panel);
  border: var(--stroke-default) solid var(--border-subtle);
  border-radius: var(--radius-card);
  box-shadow: 0 12px 16px 0 var(--effect-shadow);
}
.pay-card form { display: flex; flex-direction: column; gap: var(--space-16); }
.pay-card__title { display: flex; flex-direction: column; gap: var(--space-8); }
.option { position: relative; display: flex; align-items: flex-start; gap: var(--space-12); cursor: pointer; }
.option .checkbox__box { margin: 3px; }
.option input { position: absolute; width: 24px; height: 24px; margin: 0; opacity: 0; cursor: pointer; }
.option input:checked + .checkbox__box { background: var(--surface-accent); border-color: var(--border-focus); }
.option input:checked + .checkbox__box .icon { visibility: visible; }
.option input:focus-visible + .checkbox__box { box-shadow: var(--focus-ring); }
.option__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-4); }
.company-box { display: flex; flex-direction: column; gap: var(--space-16); padding: var(--space-16); border-radius: var(--radius-control); background: var(--surface-muted); }
.terms { padding-top: var(--space-16); border-top: var(--stroke-default) solid var(--border-subtle); }

/* P2.4 Transfer details */
.qr { display: flex; flex-direction: column; align-items: center; gap: var(--space-8); padding: var(--space-16); border-radius: var(--radius-control); background: var(--surface-muted); text-align: center; }
.qr__code { padding: 12px; background: #fff; }
.qr__code img { width: 160px; height: 160px; }
.transfer { display: flex; flex-direction: column; }
.transfer__row { display: flex; align-items: center; gap: var(--space-8); min-height: 44px; }
.transfer__row .summary-row { flex: 1; min-width: 0; }
.transfer__row .summary-row > :first-child { flex: none; white-space: nowrap; }
.transfer__row .btn--ghost { flex: none; width: 64px; padding: 0; }
.transfer__spacer { flex: none; width: 64px; }
html:lang(vi) .transfer__row .btn--ghost, html:lang(vi) .transfer__spacer { width: 72px; }
.summary-row--strong > * { color: var(--content-primary) !important; font-weight: 600; }
.summary-row--strong > :last-child { font: var(--text-heading-h4); letter-spacing: var(--tracking-heading-h4); }
/* The transfer note never wraps (Pay by country SPEC, 6 Nov): its label wraps instead, e.g. "Nội dung chuyển khoản". */
.transfer__row .summary-row--strong > :first-child { flex: 1 1 auto; white-space: normal; }
.transfer__row .summary-row--strong > :last-child { white-space: nowrap; }

/* P2.5 ProgressStep */
.steps { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-24); }
.step { display: flex; align-items: flex-start; gap: var(--space-16); }
.step__mark {
  flex: none;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: var(--stroke-default) solid var(--border-subtle);
  border-radius: 16px;
  background: var(--surface-panel);
  color: var(--content-secondary);
  font: var(--text-label-sm);
}
.step__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-4); padding-top: 4px; }
.step__title { font: var(--text-label-md); color: var(--content-secondary); }
.step--done .step__mark { background: var(--surface-inverse); border-color: var(--surface-inverse); color: var(--content-on-inverse); }
[data-theme="dark"] .step--done .step__mark { border-color: var(--border-strong); }
.step--current .step__mark { background: var(--surface-accent); border-color: var(--border-strong); color: var(--content-on-accent); }
.step--done .step__title, .step--current .step__title { color: var(--content-primary); }
.divider-line { height: 1px; background: var(--border-subtle); }

/* ---------- P3 Payment approved ---------- */
.done-card {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: var(--space-24);
  padding: var(--space-40);
  background: var(--surface-panel);
  border: var(--stroke-default) solid var(--border-subtle);
  border-radius: var(--radius-card);
  box-shadow: 0 12px 16px 0 var(--effect-shadow);
}
.done-mark {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: var(--stroke-default) solid var(--border-strong);
  border-radius: 32px;
  background: var(--surface-accent);
  color: var(--content-on-accent);
}
.done-card__title { display: flex; flex-direction: column; gap: var(--space-8); }
.done-card__title .t-body-md { color: var(--content-secondary); }
.receipt { display: flex; flex-direction: column; gap: var(--space-12); padding: var(--space-20); border-radius: var(--radius-control); background: var(--surface-muted); }
.receipt__head { display: flex; align-items: center; gap: var(--space-8); font-weight: 600; }
.receipt .summary-row > :first-child { white-space: nowrap; }
.mail-note { display: flex; align-items: center; gap: var(--space-8); color: var(--content-secondary); }
.done-actions { display: flex; flex-direction: column; gap: var(--space-12); }
.downloads { display: flex; gap: var(--space-12); }
.downloads .btn { flex: 1 1 0; min-width: 0; }
.center { display: flex; justify-content: center; }

/* ---------- P4 Billing and days ---------- */
.stats { display: flex; align-items: stretch; gap: var(--space-24); width: 100%; }
.stat {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-8);
  padding: var(--space-24);
  background: var(--surface-panel);
  border: var(--stroke-default) solid var(--border-subtle);
  border-radius: var(--radius-card);
}
.stat__value { font: var(--text-heading-h1); letter-spacing: var(--tracking-heading-h1); overflow-wrap: anywhere; }
.stat .btn { margin-top: var(--space-16); }

.section { display: flex; flex-direction: column; gap: var(--space-16); width: 100%; }
.section__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-16); }

/* Tables: header row on muted, one line per row; wide tables scroll inside their card. */
.table {
  width: 100%;
  background: var(--surface-panel);
  border: var(--stroke-default) solid var(--border-subtle);
  border-radius: var(--radius-card);
  overflow-x: auto;
}
.table__inner { min-width: 100%; width: max-content; }
.table__row {
  display: flex;
  align-items: center;
  gap: var(--space-16);
  min-height: 34px;
  padding: 6px var(--space-20);
  border-bottom: var(--stroke-default) solid var(--border-subtle);
  font: var(--text-body-sm);
}
.table__row:last-child { border-bottom: 0; }
.table__row--head { background: var(--surface-muted); color: var(--content-secondary); font: var(--text-label-sm); }
.table__row > * { flex: none; min-width: 0; overflow-wrap: anywhere; }
.table__row > .grow { flex: 1 1 0; }
/* Payments table columns. Vietnamese labels run longer, so the space moves to them and each row stays on one line. */
.col-date { width: 170px; }
.col-plan { width: 110px; }
.col-method { width: 220px; }
.col-amount { width: 140px; white-space: nowrap; }  /* fits "1,850,000 VND" on one line */
.col-docs { width: 240px; }
html:lang(vi) .col-date { width: 130px; }
html:lang(vi) .col-plan { width: 90px; }
html:lang(vi) .col-method { width: 232px; }
html:lang(vi) .col-amount { width: 110px; }
html:lang(vi) .col-docs { width: 260px; }
.cell-strong { font-weight: 600; }
.cell-sub { display: block; font: var(--text-caption); color: var(--content-secondary); }

.status { display: inline-flex; align-items: center; gap: var(--space-8); font: var(--text-label-sm); white-space: nowrap; }
.status--success { color: var(--content-success); }
.status--warning { color: var(--content-warning); }
.status--error { color: var(--content-error); }
.status--neutral { color: var(--content-secondary); }

.doc-links { display: flex; align-items: center; gap: var(--space-16); }
.doc-link { display: inline-flex; white-space: nowrap; align-items: center; gap: var(--space-8); font: var(--text-label-sm); color: var(--content-primary); text-decoration: none; border-radius: 4px; }
.doc-link:hover { text-decoration: underline; text-underline-offset: 2px; }
.doc-link:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.periods { display: flex; flex-direction: column; gap: var(--space-16); padding: var(--space-24); background: var(--surface-panel); border: var(--stroke-default) solid var(--border-subtle); border-radius: var(--radius-card); }
.periods .summary-row > :first-child { overflow-wrap: anywhere; }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-8);
  padding: var(--space-24);
  background: var(--surface-panel);
  border: var(--stroke-default) solid var(--border-subtle);
  border-radius: var(--radius-card);
  text-align: center;
}
.empty .icon { color: var(--content-secondary); margin-bottom: var(--space-8); }

/* ---------- Modal ---------- */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-16);
  background: rgba(13, 25, 35, .45);
}
.modal {
  width: 100%;
  max-width: 440px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
  padding: var(--space-24);
  background: var(--surface-panel);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-lg);
}
.modal--wide { max-width: 520px; gap: var(--space-20); }
.modal__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-12); padding-top: var(--space-12); }
.modal--wide .modal__actions { padding-top: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1240px) {
  .plans { flex-wrap: wrap; }
  .plan-card { flex: 1 1 320px; }
  .rules { flex: 1 1 100%; }
  .checkout { gap: var(--space-48); }
}

@media (max-width: 960px) {
  .checkout { flex-direction: column; align-items: center; }
  .checkout__order, .pay-card { flex: none; width: 100%; max-width: 560px; }
  .stats { flex-direction: column; }
}

@media (max-width: 640px) {
  .page { gap: var(--space-24); }
  .t-h2 { font-size: 32px; line-height: 40px; }
  .stat__value, .plan-card__amount strong { font-size: 36px; line-height: 44px; }
  .pay-card, .done-card { padding: var(--space-24); }
  .downloads { flex-direction: column; }
  .buy-actions .btn--lg { width: 100%; }
  /* Long labels wrap instead of running out of the button on small phones. */
  .pay-card .btn--lg, .done-actions .btn--lg { white-space: normal; height: auto; min-height: 56px; padding-block: var(--space-8); text-align: center; }
}

/* ---------- Monthly plan (Profile-Flow prototype, 12 Nov 2026) ---------- */
.plan-card--single { flex: 0 0 384px; cursor: default; }
.plan-card--single:hover { border-color: var(--border-subtle); }
.buy-actions .btn--secondary { width: auto; }
.step__mark .icon { width: 16px; height: 16px; }
.spinner {
  flex: none;
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-subtle);
  border-top-color: var(--surface-accent);
  border-radius: 50%;
  animation: spin 2.4s linear infinite;
}
/* "The spinner turns three times over 2.4 s, linear." */
@keyframes spin { to { transform: rotate(1080deg); } }
.checking-head { display: flex; align-items: flex-start; gap: var(--space-16); }
.stat__actions { display: flex; flex-wrap: wrap; gap: var(--space-12); margin-top: var(--space-16); }
.stat__actions .btn, .stat .btn { margin-top: 0; }
.stat .stat__actions { margin-top: var(--space-16); }
.stat__hint { font: var(--text-caption); color: var(--content-secondary); }
.page-notice { width: 100%; }

/* Toast with a title and a line of text: top centre on desktop, bottom centre on phones (fixed while scrolling). */
.toast-slot { position: fixed; left: 0; right: 0; top: var(--space-24); z-index: 20; display: flex; justify-content: center; padding: 0 var(--space-16); pointer-events: none; }
.toast--notice {
  position: static;
  transform: none;
  width: 420px;
  max-width: 100%;
  align-items: flex-start;
  padding: var(--space-16);
  border: var(--stroke-default) solid var(--border-success);
  background: var(--surface-success-subtle);
  color: var(--content-primary);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: rise .45s cubic-bezier(.45, 1.45, .8, 1) both;
  --rise: -24px;
}
.toast--notice .icon { flex: none; color: var(--content-success); margin-top: 2px; }
.toast--notice .toast__text { display: flex; flex-direction: column; gap: var(--space-4); }
.toast--notice .toast__title { font-weight: 600; }
.toast--notice .toast__body { font: var(--text-body-sm); color: var(--content-secondary); }

/* ---------- Motion (prototype timings; 2 s timelines in Figma) ----------
   Page entrance: pieces fade in and rise (12/16/24/32 px) one after another, ease out.
   Notices slide down 24 px with a slight overshoot; an error notice then shakes once.
   Reduced motion keeps the fades and drops movement, scale and shake. */
@keyframes rise { from { opacity: 0; transform: translateY(var(--rise, 24px)); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  16% { transform: translateX(-10px); }
  33% { transform: translateX(10px); }
  50% { transform: translateX(-7px); }
  66% { transform: translateX(7px); }
  83% { transform: translateX(-3px); }
}
@keyframes pop {
  0% { opacity: 0; transform: scale(var(--from, .8)); }
  62% { opacity: 1; transform: scale(1.08); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes pulse { 0%, 100% { transform: scale(1); } 45% { transform: scale(1.06); } }
@keyframes settle { from { transform: scale(.96); } to { transform: scale(1); } }
@keyframes dialog-in { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: scale(1); } }

.m-rise { animation: rise var(--dur, .45s) var(--ease, ease-out) var(--delay, 0s) both; }
.m-rise--8 { --rise: 8px; }
.m-rise--12 { --rise: 12px; }
.m-rise--16 { --rise: 16px; }
.m-rise--20 { --rise: 20px; }
.m-rise--32 { --rise: 32px; }
.m-fade { animation: fade var(--dur, .3s) ease-out var(--delay, 0s) both; }
.m-word { display: inline-block; --rise: 16px; animation: rise var(--dur, .18s) cubic-bezier(0, 0, .58, 1) var(--delay, 0s) both; }
.m-drop { --rise: -24px; animation: rise .4s cubic-bezier(.45, 1.45, .8, 1) var(--delay, 0s) both; }
.m-shake { animation: fade .25s ease-out both, shake .45s ease-in-out .25s both; }
.m-drop-shake { --rise: -24px; animation: rise .4s cubic-bezier(.45, 1.45, .8, 1) var(--delay, 0s) both, shake .45s ease-in-out calc(var(--delay, 0s) + .4s) both; }
.m-pop { animation: pop .45s ease-out var(--delay, 0s) both; }
.m-pop--mark { --from: .4; }
.m-pulse { animation: pulse .35s ease-in-out var(--delay, .9s) both; }
.m-settle { transform-origin: center; animation: settle .3s cubic-bezier(.45, 1.45, .8, 1) both; }
.scrim { animation: fade .2s ease-out both; }
.modal { animation: dialog-in .25s ease-out .05s both; }

@media (max-width: 640px) {
  .toast-slot { top: auto; bottom: var(--space-24); }
  .toast--notice { --rise: 24px; }
  .plan-card--single { flex: 1 1 100%; }
  .buy-actions .btn--secondary { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .m-rise, .m-word, .m-drop, .m-pop, .modal, .toast--notice { animation-name: fade; animation-timing-function: ease-out; }
  .m-shake, .m-drop-shake { animation: fade .25s ease-out both; }
  .m-pulse, .m-settle { animation: none; }
}
