/* ============================================================
   Checkout Intermediate Page - Stylesheet
   Design principles: clean, secure, trustworthy, mobile-first
   ============================================================ */

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --c-primary: #07c160;       /* WeChat green */
  --c-primary-dark: #06ad56;
  --c-primary-light: #e8f8f0;
  --c-danger: #fa5151;
  --c-danger-light: #fef0f0;
  --c-warning: #ff976a;
  --c-text: #1a1a1a;
  --c-text-secondary: #888;
  --c-text-tertiary: #bbb;
  --c-bg: #f5f6f8;
  --c-card: #ffffff;
  --c-border: #ececec;
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.06);
  --shadow-btn: 0 4px 12px rgba(7, 193, 96, 0.3);
  --radius: 16px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Helvetica, Arial, sans-serif;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- App Container ---------- */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- Top Brand Bar ---------- */
.topbar {
  background: var(--c-card);
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: 480px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-lock {
  display: inline-flex;
  color: var(--c-primary);
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--c-text);
}

/* ---------- Main Area ---------- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 16px;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
}

/* ---------- View Switching ---------- */
.view {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hidden {
  display: none !important;
}

/* ---------- Card ---------- */
.card {
  width: 100%;
  background: var(--c-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.center-card {
  padding: 60px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---------- Loading State ---------- */
.spinner-wrap {
  margin-bottom: 20px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--c-primary-light);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 15px;
  color: var(--c-text-secondary);
}

/* ---------- Select Payment Method ---------- */
.select-card {
  padding: 28px 24px 24px;
}

.select-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--c-text);
  margin-bottom: 20px;
}

.method-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 28px;
}

.method-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 14px;
  background: #fafafa;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
}

.method-item.selected {
  border-color: var(--c-primary);
  background: var(--c-primary-light);
}

.method-item input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.method-radio {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #d0d0d0;
  flex-shrink: 0;
  position: relative;
  transition: border-color 0.2s;
}

.method-item.selected .method-radio {
  border-color: var(--c-primary);
}

.method-item.selected .method-radio::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c-primary);
}

.method-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.method-icon.wechat {
  color: var(--c-primary);
}

.method-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.method-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--c-text);
}

.method-desc {
  font-size: 12px;
  color: var(--c-text-secondary);
}

/* ---------- Block Button ---------- */
.btn-block {
  width: 100%;
  display: block;
}

/* ---------- Pay Card ---------- */
.pay-card {
  padding: 28px 24px 20px;
}

.amount-section {
  text-align: center;
  margin-bottom: 20px;
}

.pay-hint {
  font-size: 13px;
  color: var(--c-text-secondary);
  margin-bottom: 6px;
}

.amount {
  font-size: 36px;
  font-weight: 700;
  color: var(--c-text);
  letter-spacing: -0.5px;
}

/* ---------- Product Info ---------- */
.product-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: #fafafa;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}

.product-label {
  font-size: 13px;
  color: var(--c-text-secondary);
  flex-shrink: 0;
}

.product-name {
  font-size: 14px;
  color: var(--c-text);
  font-weight: 500;
  text-align: right;
  max-width: 70%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Divider ---------- */
.divider {
  height: 1px;
  background: linear-gradient(to right, transparent, var(--c-border), transparent);
  margin: 0 -24px 20px;
}

/* ---------- QR Code Area ---------- */
.qrcode-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
}

.qrcode-box {
  width: 220px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 10px;
  position: relative;
  overflow: hidden;
}

.qrcode-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* QR code scan animation line */
.qrcode-box::after {
  content: '';
  position: absolute;
  left: 10px;
  right: 10px;
  top: 10px;
  height: 2px;
  background: linear-gradient(to right, transparent, var(--c-primary), transparent);
  border-radius: 2px;
  animation: scan 2s ease-in-out infinite;
  opacity: 0.7;
}

@keyframes scan {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(190px); }
}

/* Payment channel label */
.pay-channel {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
}

.channel-icon {
  display: inline-flex;
}

.channel-icon.wechat {
  color: var(--c-primary);
}

.channel-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--c-text);
}

/* ---------- Status Indicator ---------- */
.status-section {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-warning);
}

.status-dot.pulse {
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.3); }
}

.status-text {
  font-size: 14px;
  color: var(--c-text-secondary);
}

/* ---------- Countdown ---------- */
.countdown-section {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  background: #fff8f0;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.countdown-label {
  font-size: 13px;
  color: var(--c-warning);
}

.countdown {
  font-size: 16px;
  font-weight: 700;
  color: var(--c-warning);
  font-variant-numeric: tabular-nums;
}

/* ---------- Order No. ---------- */
.orderno-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--c-border);
}

.orderno-label {
  font-size: 13px;
  color: var(--c-text-tertiary);
}

.orderno-value {
  font-size: 13px;
  color: var(--c-text-secondary);
  font-family: 'SF Mono', 'Menlo', monospace;
  user-select: all;
}

/* ---------- Security Tips ---------- */
.security-tips {
  text-align: center;
  margin-top: 20px;
  padding: 0 12px;
}

.security-tips p {
  font-size: 13px;
  color: var(--c-text-secondary);
  line-height: 1.8;
}

.security-tips .tip-sub {
  font-size: 12px;
  color: var(--c-text-tertiary);
}

/* ---------- Result Card ---------- */
.result-card {
  padding: 48px 24px 36px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.result-icon {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.success-icon {
  color: var(--c-primary);
}

.success-circle {
  stroke-dasharray: 160;
  stroke-dashoffset: 160;
  animation: draw-circle 0.6s ease forwards;
}

.success-check {
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  animation: draw-check 0.4s 0.5s ease forwards;
}

@keyframes draw-circle {
  to { stroke-dashoffset: 0; }
}

@keyframes draw-check {
  to { stroke-dashoffset: 0; }
}

.fail-icon {
  color: var(--c-danger);
}

.error-icon {
  color: var(--c-warning);
}

.result-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
}

.result-amount {
  font-size: 32px;
  font-weight: 700;
  color: var(--c-text);
  margin-bottom: 24px;
}

.result-message {
  font-size: 14px;
  color: var(--c-text-secondary);
  margin-bottom: 28px;
  line-height: 1.6;
}

.result-hint {
  font-size: 13px;
  color: var(--c-text-tertiary);
  margin-top: 8px;
}

.result-detail {
  width: 100%;
  margin-bottom: 24px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--c-border);
}

.detail-label {
  font-size: 13px;
  color: var(--c-text-tertiary);
}

.detail-value {
  font-size: 13px;
  color: var(--c-text-secondary);
  font-family: 'SF Mono', 'Menlo', monospace;
}

/* ---------- Button ---------- */
.btn {
  display: inline-block;
  padding: 12px 40px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  -webkit-appearance: none;
  font-family: var(--font);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--c-primary);
  color: #fff;
  box-shadow: var(--shadow-btn);
}

.btn-primary:hover {
  background: var(--c-primary-dark);
}

/* ---------- Footer ---------- */
.footer {
  padding: 20px 16px 28px;
  text-align: center;
}

.footer-secure {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--c-text-tertiary);
}

/* ---------- State Container Styles ---------- */
#app[data-state="success"] .footer {
  display: none;
}

/* ---------- Responsive ---------- */
@media (max-width: 360px) {
  .amount {
    font-size: 30px;
  }
  .qrcode-box {
    width: 190px;
    height: 190px;
  }
  @keyframes scan {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(160px); }
  }
}

@media (min-width: 481px) {
  body {
    background: #f0f2f5;
  }
  .main {
    padding-top: 40px;
  }
  .card {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  }
}
