/* Payment JS SDK Demo — 公共样式 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, "BlinkMacSystemFont", "Segoe UI", "Open Sans", sans-serif;
  background-color: #f5f7fa;
  color: #161616;
}

/* ── Page header ─────────────────────────────────────────────── */
.page-header {
  height: 57px;
  background-color: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-header a.back-link {
  color: #009d8a;
  text-decoration: none;
  font-size: 14px;
}

.page-header a.back-link:hover {
  text-decoration: underline;
}

.page-header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #161616;
}

/* ── Payment card ────────────────────────────────────────────── */
.payment-card {
  margin: 40px auto;
  padding: 32px;
  width: 100%;
  max-width: 520px;
  background-color: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.payment-card h2 {
  margin: 0 0 24px;
  font-size: 20px;
  font-weight: 600;
  color: #161616;
}

/* ── Form fields ─────────────────────────────────────────────── */
.field {
  margin-bottom: 20px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #4b5563;
}

/* Container into which the SDK renders an iframe */
.input-wrap {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid #d1d1d1;
  border-radius: 6px;
  transition: border-color 0.2s ease-in-out;
}

.input-wrap:focus-within {
  border-color: #009d8a;
  outline: none;
}

/* Two-column row for expiry / CVV */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}

/* ── Pay button ──────────────────────────────────────────────── */
button#submit {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 44px;
  margin-top: 8px;
  border: none;
  border-radius: 6px;
  background-color: #009d8a;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease-in-out;
}

button#submit:hover {
  background-color: #007d6e;
}

button#submit:active {
  background-color: #006b5e;
}

/* ── Error message ───────────────────────────────────────────── */
.error-banner {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 6px;
  background-color: #fff1f0;
  border: 1px solid #ffa39e;
  color: #cf1322;
  font-size: 14px;
  display: none;
}

.error-banner.visible {
  display: block;
}

/* ── Init error (full-page) ──────────────────────────────────── */
.init-error {
  margin: 40px auto;
  max-width: 520px;
  padding: 24px;
  border-radius: 8px;
  background-color: #fff1f0;
  border: 1px solid #ffa39e;
  color: #cf1322;
  font-size: 14px;
}

/* ── Success state ───────────────────────────────────────────── */
.success-banner {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 6px;
  background-color: #f6ffed;
  border: 1px solid #b7eb8f;
  color: #389e0d;
  font-size: 14px;
  display: none;
}

.success-banner.visible {
  display: block;
}

/* ── Index page cards ────────────────────────────────────────── */
.index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  margin: 40px auto;
  max-width: 900px;
  padding: 0 24px;
}

.demo-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 24px;
  background-color: #fff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.demo-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  border-color: #009d8a;
}

.demo-card .card-icon {
  font-size: 28px;
}

.demo-card .card-title {
  font-size: 16px;
  font-weight: 600;
  color: #161616;
}

.demo-card .card-desc {
  font-size: 13px;
  color: #6b7280;
  line-height: 1.5;
}

/* ── Environment badge ───────────────────────────────────────── */
.env-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background-color: #fff7e6;
  color: #d46b08;
  border: 1px solid #ffd591;
}

/* ══════════════════════════════════════════════════════════════
   左右分栏布局（demo 页面专用）
   ══════════════════════════════════════════════════════════════ */

.demo-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: calc(100vh - 57px);
  overflow: hidden;
}

/* ── 左侧：交互区 ─────────────────────────────────────────────── */
.demo-panel {
  background-color: #f5f7fa;
  overflow-y: auto;
  padding: 40px 32px;
}

.demo-panel .payment-card {
  margin: 0 auto;
}

/* ── 右侧：代码区 ─────────────────────────────────────────────── */
.code-panel {
  display: flex;
  flex-direction: column;
  background-color: #0d1117;
  overflow: hidden;
  border-left: 1px solid #21262d;
}

/* 标签栏 */
.code-tabs {
  display: flex;
  align-items: center;
  background-color: #010409;
  border-bottom: 1px solid #21262d;
  padding: 0 16px;
  flex-shrink: 0;
  height: 44px;
}

.code-tab {
  padding: 0 16px;
  height: 100%;
  font-size: 13px;
  font-weight: 500;
  color: #8b949e;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-family: -apple-system, "BlinkMacSystemFont", sans-serif;
  transition: color 0.15s;
}

.code-tab:hover {
  color: #c9d1d9;
}

.code-tab.active {
  color: #f0f6fc;
  border-bottom-color: #009d8a;
}

/* 代码内容区 */
.code-body {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #30363d transparent;
}

.code-body::-webkit-scrollbar {
  width: 6px;
}

.code-body::-webkit-scrollbar-thumb {
  background-color: #30363d;
  border-radius: 3px;
}

.code-body pre {
  margin: 0;
  min-height: 100%;
}

/* 覆盖 highlight.js 默认背景，与面板保持一致 */
.code-body pre code.hljs {
  background: #0d1117 !important;
  padding: 24px 28px !important;
  font-size: 13px;
  line-height: 1.65;
  font-family: "SF Mono", "Fira Code", "JetBrains Mono", "Consolas", monospace;
}

/* ── 响应式：窄屏纵向堆叠 ─────────────────────────────────────── */
@media (max-width: 900px) {
  html, body {
    height: auto;
  }

  .demo-layout {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .code-panel {
    height: 520px;
  }
}
