/* ============================================================
   KATALIST — billing.css
   On-site checkout view (#view-checkout). Web only.
   The card fields themselves are Stripe iframes; their look is
   set from these same theme variables in js/billing.js
   (_stripeAppearance), so keep the two in step.
   ============================================================ */

.checkout-layout {
  display: grid;
  grid-template-columns: minmax(240px, 340px) minmax(300px, 440px);
  gap: 24px;
  align-items: start;
  max-width: 820px;
}

.checkout-summary,
.checkout-pay,
.checkout-done {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 28px 24px;
}

/* Fire bar across the top of the summary — the one accent on the page */
.checkout-summary {
  position: relative;
  overflow: hidden;
  display: flex; flex-direction: column; gap: 6px;
}
.checkout-summary::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--waveform));
}

.checkout-eyebrow {
  font-size: 10px; font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text-muted);
  margin-bottom: 10px;
}

.checkout-plan-name {
  font-family: var(--font-display);
  font-size: 26px; font-weight: 700; letter-spacing: -0.4px;
  color: var(--text-primary); line-height: 1.1;
}
.checkout-plan-price {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 600; color: var(--text-accent);
}
.checkout-plan-period {
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 400; color: var(--text-muted);
  margin-left: 2px;
}

.checkout-features {
  list-style: none; margin: 18px 0 0; padding: 0;
  display: flex; flex-direction: column; gap: 9px;
  font-size: 12px; color: var(--text-secondary); line-height: 1.4;
}
.checkout-features li { display: flex; gap: 10px; align-items: baseline; }
.checkout-features li::before {
  content: ''; flex: 0 0 5px; height: 5px; border-radius: 50%;
  background: var(--accent); transform: translateY(-1px);
}

.checkout-totals {
  margin-top: 22px; padding-top: 18px;
  border-top: 1px solid var(--border-strong);
}
.checkout-total-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12px; color: var(--text-secondary);
}
.checkout-total-amount {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 700; color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.checkout-total-note {
  margin-top: 6px; font-size: 11px; color: var(--text-muted); line-height: 1.5;
}

/* Payment column */
.checkout-pay { display: flex; flex-direction: column; }

.checkout-element-wrap { position: relative; min-height: 190px; }

/* Placeholder bars shown until Stripe's fields have drawn */
.checkout-skeleton {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; gap: 14px;
  pointer-events: none;
}
.checkout-skeleton div {
  height: 44px; border-radius: var(--radius-md);
  background: var(--bg-elevated);
  animation: checkoutPulse 1.2s ease-in-out infinite;
}
.checkout-skeleton div:nth-child(2) { animation-delay: 0.15s; }
.checkout-skeleton div:nth-child(3) { animation-delay: 0.3s; width: 55%; }
@keyframes checkoutPulse {
  0%, 100% { opacity: 0.45; }
  50%      { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .checkout-skeleton div { animation: none; opacity: 0.7; }
}

.checkout-error {
  margin-top: 14px; padding: 10px 12px;
  font-size: 12px; line-height: 1.5; color: var(--text-primary);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  border-radius: var(--radius-sm);
}

.checkout-pay-btn {
  margin-top: 18px; width: 100%;
  padding: 13px 16px; font-size: 13px;
}

.checkout-fineprint {
  margin-top: 12px; font-size: 10px; line-height: 1.5;
  color: var(--text-muted); text-align: center;
}

/* Success panel replaces both columns */
.checkout-layout.is-done { grid-template-columns: minmax(280px, 440px); }
.checkout-layout.is-done .checkout-summary,
.checkout-layout.is-done .checkout-pay { display: none; }

.checkout-done {
  display: flex; flex-direction: column; align-items: flex-start; gap: 12px;
}
.checkout-done-mark {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--waveform));
  box-shadow: 0 4px 24px var(--accent-glow);
}
.checkout-done-title {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 700; letter-spacing: -0.4px;
  color: var(--text-primary);
}
.checkout-done-text {
  font-size: 12px; line-height: 1.6; color: var(--text-secondary);
  margin-bottom: 8px;
}

@media (max-width: 760px) {
  .checkout-layout { grid-template-columns: 1fr; gap: 14px; }
  .checkout-summary, .checkout-pay, .checkout-done { padding: 22px 18px; }
  .checkout-features { margin-top: 14px; }
}

/* ============================================================
   Billing view (#view-billing): subscription, card, invoices.
   Built on the settings-card / settings-row pieces from
   settings.css; only what differs lives here.
   ============================================================ */

/* Width is capped on an inner wrapper, not on .view-body, so the view's
   scrollbar stays at the window edge instead of mid-screen. */
.billing-wrap { max-width: 620px; }

/* Past-due notice at the top of the view */
.billing-alert {
  margin-bottom: 22px; padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--warning) 45%, transparent);
  background: color-mix(in srgb, var(--warning) 10%, transparent);
}
.billing-alert-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.billing-alert-text  { font-size: 11px; color: var(--text-secondary); margin-top: 4px; line-height: 1.5; }

/* Status word with a signal dot, like a channel meter */
.billing-status {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-secondary);
}
.billing-status::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-muted);
}
.billing-status.is-active::before  { background: var(--success); box-shadow: 0 0 8px var(--success); }
.billing-status.is-warning::before { background: var(--warning); box-shadow: 0 0 8px var(--warning); }
.billing-status.is-warning { color: var(--text-primary); }

/* Button row at the foot of the subscription card */
.billing-actions { justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.billing-actions:empty { display: none; }
.btn-billing-danger { color: var(--text-secondary); }
.btn-billing-danger:hover {
  color: var(--text-primary);
  border-color: color-mix(in srgb, var(--danger) 60%, transparent);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}

/* "Update card" form, opened in place under the card row */
.billing-card-form {
  padding: 18px; border-top: 1px solid var(--border);
  background: var(--bg-base);
}
.billing-card-form-actions {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px;
}

/* Invoice rows: date · number · amount · status · PDF */
.billing-invoice {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(0, 1.2fr) auto auto auto;
  align-items: center; gap: 16px;
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  font-size: 12px; color: var(--text-secondary);
}
.billing-invoice:last-child { border-bottom: none; }
.billing-invoice-date   { color: var(--text-primary); }
.billing-invoice-number { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.billing-invoice-amount { color: var(--text-primary); font-variant-numeric: tabular-nums; text-align: right; }
.billing-invoice-status {
  font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 20px;
  border: 1px solid var(--border-strong); color: var(--text-muted);
}
.billing-invoice-status.is-paid { color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.billing-invoice-status.is-open { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 45%, transparent); }
.billing-invoice-pdf { color: var(--text-accent); text-decoration: none; font-size: 11px; }
.billing-invoice-pdf:hover { text-decoration: underline; }
.billing-empty { padding: 16px 18px; font-size: 12px; color: var(--text-muted); }

@media (max-width: 760px) {
  .billing-invoice { grid-template-columns: 1fr auto auto; gap: 10px; }
  .billing-invoice-number { display: none; }
  .billing-invoice-status { display: none; }
  .billing-actions { justify-content: flex-start; }
}

/* Native companion app: nothing that invites a purchase is shown. */
html.native-app .billing-cta { display: none !important; }
