/* v1 has no surface/text variables; derive them from the template's --twc-* palette
   (its default-* scale flips in dark mode) so the rules below read like the other themes. */
.ap-page {
    --bg-surface: #ffffff;
    --bg-elevated: hsl(var(--twc-default-100));
    --bg-surface-hover: hsl(var(--twc-default-100));
    --text-primary: hsl(var(--twc-default-900));
    --text-secondary: hsl(var(--twc-default-600));
    --text-muted: hsl(var(--twc-default-400));
    --border-subtle: hsl(var(--twc-default-200));
    --border-default: hsl(var(--twc-default-300));
    --primary: hsl(var(--twc-primary));
    --primary-solid: hsl(241 72% 62%);
    --primary-solid-hover: hsl(241 60% 55%);
    --primary-600: hsl(241 62% 58%);
    --primary-700: hsl(241 52% 50%);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .03), 0 6px 20px rgba(0, 0, 0, .04);
}
.dark .ap-page {
    --bg-surface: hsl(var(--twc-default-100));
    --bg-elevated: hsl(var(--twc-default-200));
    --bg-surface-hover: hsl(var(--twc-default-200));
    --border-subtle: hsl(var(--twc-default-200));
    --border-default: hsl(var(--twc-default-300));
    --text-muted: hsl(var(--twc-default-500));
    --primary-600: hsl(241 100% 82%);
    --primary-700: hsl(241 100% 85%);
    --shadow-card: none;
}
/* customer/api.php (v1) — colors from theme.css variables (swap in dark mode).
   Class names used by pages/api.js stay as they are: .api-section, .tab-api,
   .endpoint-collapse/.endpoint-body(.collapsed), .sub-tab(-content), .code-*,
   .test-*, .btn-test, .badge-action. */
.ap-page { display: flex; flex-direction: column; gap: 20px; }

.ap-card, .api-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    box-shadow: var(--shadow-card);
}
.ap-card { padding: 24px; }

/* Intro: key + base URL */
.ap-intro-head { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.ap-chip { width: 44px; height: 44px; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; background: rgba(132, 129, 255, .12); color: var(--primary-600); font-size: 22px; }
.ap-intro-text { flex: 1; min-width: 220px; }
.ap-intro-text h1 { margin: 0; font-size: 22px; font-weight: 700; color: var(--text-primary); }
.ap-intro-text p { margin: 4px 0 0; font-size: 14px; color: var(--text-secondary); }
.ap-fields { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin-top: 20px; }
@media (min-width: 1024px) { .ap-fields { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } }
.ap-field label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 600; color: var(--text-primary); }
.ap-secret { display: flex; gap: 8px; }
.ap-input {
    flex: 1; min-width: 0;
    height: 46px; padding: 0 14px;
    display: flex; align-items: center;
    border-radius: 12px; border: 1px solid var(--border-default);
    background: var(--bg-elevated); color: var(--text-primary);
    font-size: 15px;
}
.ap-input:disabled { opacity: 1; }
.ap-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; }
.ap-base { height: auto; min-height: 46px; padding-top: 10px; padding-bottom: 10px; white-space: normal; overflow-wrap: anywhere; }
.ap-intro-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border-subtle); }
.ap-intro-foot form { margin: 0; }
.ap-muted { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); }
.ap-muted i { color: #d97706; font-size: 16px; }

/* Buttons */
.ap-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 46px; padding: 0 18px;
    border-radius: 12px; border: 1px solid transparent;
    font-size: 15px; font-weight: 600; white-space: nowrap; text-decoration: none; cursor: pointer;
    transition: background-color .15s, color .15s, border-color .15s;
}
.ap-btn--primary { background: var(--primary-solid); color: #fff; }
.ap-btn--primary:hover { background: var(--primary-solid-hover); color: #fff; }
.ap-btn--ghost { height: 40px; background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border-subtle); }
.ap-btn--ghost:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.ap-btn--danger { height: 40px; background: transparent; border-color: rgba(239, 68, 68, .5); color: #dc2626; }
.ap-btn--danger:hover { background: #ef4444; border-color: #ef4444; color: #fff; }
.dark .ap-btn--danger { color: #f87171; }
.ap-icon-btn {
    width: 46px; height: 46px; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 12px; border: 1px solid var(--border-default);
    background: var(--bg-surface); color: var(--text-secondary); font-size: 18px; cursor: pointer;
}
.ap-icon-btn:hover { color: var(--text-primary); background: var(--bg-surface-hover); }
.ap-btn:focus-visible, .ap-icon-btn:focus-visible, .tab-api:focus-visible, .sub-tab:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Version switch: segmented control */
.ap-versions { display: inline-flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--bg-surface); border: 1px solid var(--border-subtle); align-self: flex-start; max-width: 100%; overflow-x: auto; }
.tab-api {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 16px; border-radius: 10px; border: 0;
    background: transparent; color: var(--text-secondary);
    font-size: 15px; font-weight: 600; white-space: nowrap; cursor: pointer;
    transition: background-color .15s, color .15s;
}
.tab-api span { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.tab-api:hover { color: var(--text-primary); }
.tab-api.active { background: rgba(132, 129, 255, .12); color: var(--primary-700); }
.tab-api.active span { color: inherit; opacity: .75; }

.api-section { display: none; }
.api-section.active { display: flex; flex-direction: column; gap: 12px; }
.api-section > * + * { margin-top: 0 !important; }

/* Notes / info blocks */
.api-card.p-5, .api-card.p-6 { padding: 20px 24px !important; }
.api-card code { font-size: 13px; }
.response-block { padding: 14px 16px; border-radius: 12px; background: var(--bg-elevated); }

/* Endpoint rows: collapsed by default, so the list reads as an index */
.endpoint-collapse {
    display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px;
    padding: 16px 20px !important;
    cursor: pointer; user-select: none;
    border-bottom: 1px solid var(--border-subtle);
    transition: background-color .15s;
}
.endpoint-collapse:hover { background: var(--bg-surface-hover); }
.endpoint-collapse.collapsed { border-bottom-color: transparent; }
.endpoint-collapse code { font-size: 14px !important; overflow-wrap: anywhere; color: var(--text-primary) !important; }
.endpoint-collapse > span:last-child { font-size: 14px !important; font-weight: 600; color: var(--text-secondary) !important; }
.endpoint-collapse .collapse-icon { color: var(--text-muted) !important; transition: transform .2s ease; }
.endpoint-collapse.collapsed .collapse-icon { transform: rotate(-90deg); }
.endpoint-copy-btn { background: transparent !important; border: 1px solid var(--border-subtle); color: var(--text-secondary) !important; }
.endpoint-copy-btn:hover { color: var(--primary-600) !important; border-color: var(--border-default); }
.endpoint-body { padding: 16px 20px 20px !important; }
.endpoint-body.collapsed { display: none; }

.method-badge { padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.method-post { background: rgba(59, 130, 246, .12); color: #2563eb; }
.dark .method-post { color: #60a5fa; }
.badge-action { padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; background: rgba(139, 92, 246, .12); color: #7c3aed; }
.dark .badge-action { color: #a78bfa; }

/* Sub tabs inside an endpoint: underline style */
.endpoint-body > .flex:first-child { gap: 4px !important; border-bottom: 1px solid var(--border-default); margin-bottom: 16px !important; flex-wrap: nowrap !important; overflow-x: auto; }
.sub-tab {
    position: relative;
    padding: 8px 12px 10px; border: 0; background: none;
    font-size: 14px; font-weight: 600; color: var(--text-secondary);
    white-space: nowrap; cursor: pointer; transition: color .15s;
}
.sub-tab:hover { color: var(--text-primary); }
.sub-tab.active { color: var(--primary-600); }
.sub-tab.active::after { content: ''; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--primary); }
.sub-tab-content { display: none; }
.sub-tab-content.active { display: block; }

/* Parameter table */
.sub-tab-content[data-tab="params"] { overflow-x: auto; }
.param-table { width: 100%; border-collapse: collapse; min-width: 520px; }
.param-table th {
    padding: 10px 12px; text-align: left;
    font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    color: var(--text-secondary); background: var(--bg-elevated);
}
.param-table th:first-child { border-radius: 8px 0 0 8px; }
.param-table th:last-child { border-radius: 0 8px 8px 0; }
.param-table td { padding: 10px 12px; border-bottom: 1px solid var(--border-subtle); font-size: 14px; color: var(--text-primary); }
.param-table tr:last-child td { border-bottom: 0; }
.param-name { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; color: var(--text-primary); }
.param-type { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.type-string { background: rgba(59, 130, 246, .1); color: #2563eb; }
.type-int { background: rgba(139, 92, 246, .1); color: #7c3aed; }
.type-required { background: rgba(239, 68, 68, .1); color: #dc2626; }
.type-optional { background: var(--bg-elevated); color: var(--text-secondary); }
.dark .type-string { color: #60a5fa; }
.dark .type-int { color: #a78bfa; }
.dark .type-required { color: #f87171; }

/* Status legend */
.status-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status-pending { background: rgba(245, 158, 11, .14); color: #b45309; }
.status-done { background: rgba(132, 129, 255, .12); color: #15803d; }
.status-cancel { background: rgba(239, 68, 68, .12); color: #dc2626; }
.status-refund { background: rgba(59, 130, 246, .12); color: #2563eb; }
.status-waitrefund { background: rgba(139, 92, 246, .12); color: #7c3aed; }
.dark .status-pending { color: #fbbf24; }
.dark .status-done { color: #4ade80; }
.dark .status-cancel { color: #f87171; }
.dark .status-refund { color: #60a5fa; }
.dark .status-waitrefund { color: #a78bfa; }

/* Code blocks stay dark in both modes (editor look) */
.code-preview-v1 { background: #0f172a; border: 1px solid #1e293b; border-radius: 12px; overflow: hidden; }
.code-header { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: #111827; border-bottom: 1px solid #1e293b; }
.code-dot { width: 10px; height: 10px; border-radius: 50%; }
.code-content { padding: 16px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.7; color: #e2e8f0; overflow-x: auto; }
.syntax-key { color: #4ade80; }
.syntax-value { color: #fbbf24; }
.syntax-string { color: #93c5fd; }
.syntax-comment { color: #64748b; }
.code-lang-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; margin-bottom: 0 !important; background: #0f172a; border: 1px solid #1e293b; border-bottom: 0; border-radius: 12px 12px 0 0; }
.code-lang-tab { padding: 6px 12px; border: 0; border-radius: 8px; background: transparent; color: #94a3b8; font-size: 12px; font-weight: 600; cursor: pointer; }
.code-lang-tab:hover { background: #1e293b; color: #e2e8f0; }
.code-lang-tab.active { background: rgba(132, 129, 255, .22); color: #c7c6ff; }
.code-lang-content { display: none; }
.code-lang-content.active { display: block; }
.code-lang-content .code-preview-v1 { border-radius: 0 0 12px 12px; }

/* Try it */
.test-label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--text-primary); }
.test-input {
    width: 100%; height: 42px; padding: 0 12px;
    border-radius: 10px; border: 1px solid var(--border-default);
    background: var(--bg-surface); color: var(--text-primary); font-size: 14px;
}
.test-input:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(132, 129, 255, .15); }
.test-input::placeholder { color: var(--text-muted); }
.apikey-toggle { border: 1px solid var(--border-default) !important; background: var(--bg-surface) !important; color: var(--text-secondary) !important; }
.btn-test {
    display: inline-flex; align-items: center; gap: 6px;
    height: 42px; padding: 0 18px;
    border: 0; border-radius: 10px;
    background: var(--primary-solid); color: #fff;
    font-size: 14px; font-weight: 600; cursor: pointer;
    transition: background-color .15s;
}
.btn-test:hover { background: var(--primary-solid-hover); }
.btn-test:disabled { opacity: .5; cursor: not-allowed; }
.test-result {
    padding: 14px; border-radius: 12px;
    background: var(--bg-elevated); border: 1px solid var(--border-subtle);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
    color: var(--text-primary); max-height: 320px; overflow: auto;
    white-space: pre-wrap; word-break: break-all;
}

@media (max-width: 767px) {
    .ap-card { padding: 18px; }
    .ap-secret { flex-wrap: wrap; }
    .ap-secret .ap-input { flex-basis: calc(100% - 54px); }
    .ap-secret .ap-btn { width: 100%; }
    .ap-intro-head .ap-btn { width: 100%; }
    .endpoint-collapse { padding: 14px 16px !important; }
    .endpoint-collapse > span:last-child { margin-left: 0 !important; width: 100%; }
    .endpoint-body { padding: 14px 16px 16px !important; }
}
.code-lang-tabs + .code-lang-content, .code-lang-content { margin-top: 0 !important; }

/* v1: the V2 action badge uses template utilities; keep it compact */
.endpoint-collapse [class*="bg-purple"] { margin-left: 0 !important; }
.api-card code { font-size: 13px; }

/* v1 geometry: smaller control radius than the other themes */
.ap-input, .ap-btn, .ap-icon-btn, .test-input, .btn-test, .tab-api { border-radius: 8px; }

/* Template text utilities used inside the unchanged endpoint/notes markup:
   map the default-* scale to theme tokens so both modes stay readable. */
.api-card .text-default-900, .api-card .text-default-800, .api-card .text-default-700 { color: var(--text-primary); }
.api-card .text-default-600, .api-card .text-default-500 { color: var(--text-secondary); }
.api-card .text-default-400 { color: var(--text-muted); }
.api-card code { background: var(--bg-elevated); color: var(--primary-700); padding: 2px 8px; border-radius: 6px; font-size: 13px; }
.dark .api-card code { color: #c7c6ff; }
.api-card .bg-gray-100, .api-card .dark\:bg-gray-800 { background: var(--bg-elevated); }
.api-card ul, .api-card li, .api-card p { color: var(--text-secondary); }
.api-card h3, .api-card h4 { color: var(--text-primary); }
