/* ============================================
   Payment Gateway API Docs Styles
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

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

:root {
  --primary: #1565C0;
  --primary-light: #42A5F5;
  --primary-dark: #0D47A1;
  --primary-bg: #E3F2FD;
  --accent: #FF6F00;
  --success: #2E7D32;
  --success-bg: #E8F5E9;
  --warning: #F57F17;
  --warning-bg: #FFF8E1;
  --danger: #C62828;
  --danger-bg: #FFEBEE;
  --info: #0277BD;
  --info-bg: #E1F5FE;
  --text: #212121;
  --text-secondary: #616161;
  --text-light: #9E9E9E;
  --bg: #FAFAFA;
  --card-bg: #FFFFFF;
  --border: #E0E0E0;
  --code-bg: #1E1E2E;
  --code-fg: #CDD6F4;
  --code-comment: #6C7086;
  --code-string: #A6E3A1;
  --code-keyword: #F38BA8;
  --code-number: #FAB387;
  --code-property: #89DCEB;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-width: 280px;
  --font-thai: 'Sarabun', 'Noto Sans Thai', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
}

html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  font-family: var(--font-thai);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ---- Bilingual switching ---- */
[data-lang] { display: none; }
html[lang="en"] [data-lang="en"],
html[lang="th"] [data-lang="th"] { display: revert; }
/* For inline elements that should be `inline` not `block` */
html[lang="en"] span[data-lang="en"],
html[lang="th"] span[data-lang="th"] { display: inline; }
/* Lang-toggle buttons use data-lang to SET the language; they must always be visible */
.lang-toggle button[data-lang] { display: inline-block; }

/* --- Layout --- */
.tutorial-layout { display: flex; min-height: 100vh; }

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: white;
}
.sidebar-header h2 { font-size: 17px; font-weight: 700; margin-bottom: 2px; }
.sidebar-header .subtitle { font-size: 12px; opacity: 0.8; }
.sidebar-header a { color: white; text-decoration: none; }

.sidebar-section-label {
  padding: 14px 24px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-light);
}
.sidebar-section-label:first-of-type { padding-top: 12px; }

.sidebar-nav { padding-bottom: 20px; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 24px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover { background: var(--primary-bg); color: var(--primary); }
.sidebar-nav a.active {
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 600;
  border-left-color: var(--primary);
}
.sidebar-nav .method-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.4px;
}
.method-tag.method-post { background: #E0F2F1; color: #00695C; }
.method-tag.method-get  { background: #E3F2FD; color: #1565C0; }

/* --- Main content --- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
}

.page-header {
  padding: 28px 48px 20px;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
}
.page-header h1 { font-size: 28px; font-weight: 700; margin-bottom: 4px; line-height: 1.3; }
.page-header .subtitle { font-size: 15px; opacity: 0.85; }

/* Endpoint title block (verb + path) */
.endpoint-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.endpoint-title .method-badge {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: 0.5px;
  background: rgba(255,255,255,0.2);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
}
.endpoint-title .endpoint-path {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  color: white;
  word-break: break-all;
}

/* --- Lang toggle --- */
.lang-toggle {
  display: inline-flex;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 6px;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}
.lang-toggle button {
  background: transparent;
  border: none;
  color: white;
  padding: 6px 14px;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: background 0.15s;
}
.lang-toggle button:hover { background: rgba(255,255,255,0.1); }
.lang-toggle button.active { background: white; color: var(--primary-dark); }

/* --- Content body --- */
.content-body { padding: 36px 48px 64px; max-width: 1100px; }

.tutorial-section {
  margin-bottom: 44px;
  scroll-margin-top: 80px;
}
.tutorial-section h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary-bg);
}
.tutorial-section h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin: 24px 0 10px;
}
.tutorial-section h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 16px 0 8px;
}
.tutorial-section p,
.tutorial-section li {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 10px;
}
.tutorial-section ul,
.tutorial-section ol { padding-left: 24px; margin: 8px 0 16px; }
.tutorial-section li::marker { color: var(--primary); }
.tutorial-section a {
  color: var(--primary);
  text-decoration: none;
  border-bottom: 1px dashed var(--primary-light);
}
.tutorial-section a:hover { border-bottom-style: solid; }

.tutorial-section strong { color: var(--text); font-weight: 600; }

.tutorial-section code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 2px 7px;
  background: var(--primary-bg);
  color: var(--primary-dark);
  border-radius: 4px;
  border: 1px solid #BBDEFB;
  white-space: nowrap;
}

/* --- Callout boxes --- */
.callout {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  border-left: 4px solid;
  margin: 16px 0;
  font-size: 14px;
}
.callout > p { margin-bottom: 6px; font-size: 14px; }
.callout > p:last-child { margin-bottom: 0; }
.callout-title {
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 14px;
  /* No `display: flex` here — would clobber the bilingual hide rule
     (`[data-lang] { display: none }`). Emoji + text already lays out
     inline naturally. */
}
.callout.info     { background: var(--info-bg);    border-color: var(--info); }
.callout.info .callout-title    { color: var(--info); }
.callout.warning  { background: var(--warning-bg); border-color: var(--warning); }
.callout.warning .callout-title { color: var(--warning); }
.callout.success  { background: var(--success-bg); border-color: var(--success); }
.callout.success .callout-title { color: var(--success); }
.callout.danger   { background: var(--danger-bg);  border-color: var(--danger); }
.callout.danger .callout-title  { color: var(--danger); }

/* --- Parameter table --- */
.param-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 20px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-size: 14px;
}
.param-table th {
  background: var(--primary-bg);
  color: var(--primary-dark);
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.param-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--text-secondary);
}
.param-table tr:last-child td { border-bottom: none; }
.param-table .param-name {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--primary-dark);
  font-weight: 600;
  white-space: nowrap;
}
.param-table .param-type {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  white-space: nowrap;
}
.param-table .param-required {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 1px 6px;
  border-radius: 3px;
  text-transform: uppercase;
}
.param-required.required { background: var(--danger-bg); color: var(--danger); }
.param-required.optional { background: #ECEFF1; color: #546E7A; }
.param-table code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: #F5F5F5;
  padding: 1px 5px;
  border-radius: 3px;
  border: none;
  color: var(--text);
  white-space: nowrap;
}

/* --- Code blocks --- */
.code-block {
  position: relative;
  background: var(--code-bg);
  border-radius: var(--radius-sm);
  margin: 12px 0 20px;
  overflow: hidden;
}
.code-block .code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: rgba(0,0,0,0.25);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.code-block .code-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #A6ADC8;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.code-block pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--code-fg);
}
.code-block pre code {
  font-family: inherit;
  background: transparent;
  border: none;
  padding: 0;
  color: inherit;
  white-space: pre;
  display: block;
}

/* Copy button */
.copy-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: #CDD6F4;
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.4px;
}
.copy-btn:hover { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.2); }
.copy-btn.copied { background: var(--success); border-color: var(--success); color: white; }

/* --- Code tabs --- */
.code-tabs {
  background: var(--code-bg);
  border-radius: var(--radius-sm);
  margin: 12px 0 20px;
  overflow: hidden;
}
.code-tabs .tab-headers {
  display: flex;
  background: rgba(0,0,0,0.3);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  align-items: center;
  padding-right: 10px;
}
.code-tabs .tab-btn {
  background: transparent;
  border: none;
  color: #A6ADC8;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  padding: 10px 18px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  letter-spacing: 0.3px;
}
.code-tabs .tab-btn:hover { color: var(--code-fg); }
.code-tabs .tab-btn.active {
  color: var(--code-fg);
  border-bottom-color: var(--primary-light);
  font-weight: 600;
}
.code-tabs .tab-content { display: none; }
.code-tabs .tab-content.active { display: block; }
.code-tabs .copy-btn { margin-left: auto; }
.code-tabs pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  color: var(--code-fg);
  background: transparent;
}
.code-tabs pre code {
  font-family: inherit;
  background: transparent;
  border: none;
  padding: 0;
  color: inherit;
  white-space: pre;
  display: block;
}

/* Token highlighting (very lightweight, manual) */
.tok-c   { color: var(--code-comment); font-style: italic; }
.tok-s   { color: var(--code-string); }
.tok-k   { color: var(--code-keyword); }
.tok-n   { color: var(--code-number); }
.tok-p   { color: var(--code-property); }
.tok-fn  { color: #F5C2E7; }
.tok-var { color: #F9E2AF; }

/* --- Endpoint summary card --- */
.endpoint-summary {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  margin-bottom: 24px;
}
.endpoint-summary .endpoint-line {
  font-family: var(--font-mono);
  font-size: 14px;
  margin-bottom: 6px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.endpoint-summary .verb {
  background: var(--success-bg);
  color: var(--success);
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 4px;
  font-size: 12px;
  letter-spacing: 0.5px;
}
.endpoint-summary .verb.get { background: var(--info-bg); color: var(--info); }
.endpoint-summary .path { color: var(--text); font-weight: 500; word-break: break-all; }
.endpoint-summary .endpoint-desc { font-size: 14px; color: var(--text-secondary); margin: 6px 0 0; }

/* --- Step list / flow diagram ---
   <ol.flow-steps>: numbered circles (use when steps must run in strict order)
   <ul.flow-steps>: arrow markers (use when items are a checklist of merchant
                     actions whose ordering shouldn't be confused with sequence
                     numbers in an accompanying diagram) */
.flow-steps {
  list-style: none;
  padding: 0;
  margin: 16px 0 24px;
}
.flow-steps > li {
  position: relative;
  padding: 12px 16px 12px 56px;
  margin-bottom: 10px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-secondary);
}
.flow-steps > li::before {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  font-family: var(--font-mono);
}
ol.flow-steps { counter-reset: step; }
ol.flow-steps > li { counter-increment: step; }
ol.flow-steps > li::before { content: counter(step); }
ul.flow-steps > li::before { content: "→"; font-size: 16px; }
.flow-steps strong { color: var(--text); }

/* ASCII / preformatted diagram block */
.ascii-diagram {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 22px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-secondary);
  white-space: pre;
  overflow-x: auto;
  margin: 12px 0 20px;
  line-height: 1.55;
}

/* Mermaid sequence diagram block */
.mermaid {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 24px 18px;
  margin: 12px 0 24px;
  text-align: center;
  overflow-x: auto;
  /* Pre-render: hide raw mermaid source so it doesn't flash before SVG injection */
  color: transparent;
}
.mermaid svg { max-width: 100%; height: auto; color: var(--text); }
.mermaid[data-processed="true"] { color: var(--text); }

/* --- Endpoint card grid (index page) --- */
.endpoint-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin: 18px 0 32px;
}
.endpoint-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: all 0.18s;
  border-left: 3px solid var(--primary-light);
}
.endpoint-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-left-color: var(--primary);
}
.endpoint-card .ec-method {
  display: inline-block;
  background: var(--success-bg);
  color: var(--success);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 3px;
  margin-right: 8px;
  letter-spacing: 0.5px;
}
.endpoint-card .ec-path {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}
.endpoint-card .ec-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary-dark);
  margin: 8px 0 4px;
}
.endpoint-card .ec-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* --- Hero (index page) --- */
.hero {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, #1976D2 100%);
  color: white;
  padding: 56px 48px 44px;
  position: relative;
}
.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.hero-badge {
  display: inline-block;
  padding: 4px 14px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5px;
}
.hero h1 { font-size: 32px; font-weight: 700; margin-bottom: 8px; line-height: 1.25; }
.hero .hero-subtitle { font-size: 17px; opacity: 0.92; font-weight: 400; margin-bottom: 16px; }
.hero .hero-desc { font-size: 14px; opacity: 0.85; max-width: 720px; line-height: 1.75; }

/* --- Page nav (prev/next) --- */
.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.page-nav a {
  flex: 1 1 0;
  min-width: 220px;
  padding: 14px 18px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  transition: all 0.15s;
}
.page-nav a:hover {
  border-color: var(--primary);
  background: var(--primary-bg);
}
.page-nav a.next { text-align: right; }
.page-nav .nav-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-light);
  font-weight: 600;
  margin-bottom: 4px;
}
.page-nav .nav-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
}

/* --- Mobile --- */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  background: var(--primary);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  font-size: 20px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}
.sidebar-overlay.open { display: block; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .mobile-toggle { display: flex; align-items: center; justify-content: center; }
  .page-header, .hero, .content-body { padding-left: 20px; padding-right: 20px; }
  .hero h1 { font-size: 26px; }
  .endpoint-title .endpoint-path { font-size: 15px; }
  .param-table { font-size: 13px; }
  .param-table th, .param-table td { padding: 8px 10px; }
}

/* Print */
@media print {
  .sidebar, .mobile-toggle, .page-nav, .copy-btn, .lang-toggle { display: none !important; }
  .main-content { margin-left: 0; }
  .code-block, .code-tabs { break-inside: avoid; }
}

/* === AI assistant download callout (index page) === */
.ai-callout {
  display: flex;
  gap: 16px;
  padding: 24px 28px;
  background: linear-gradient(135deg, #1e3a5f 0%, #2a4f7d 100%);
  color: #f0f6ff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid #3b5f8a;
}
.ai-callout-body { flex: 1; }
.ai-callout-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 10px;
  color: #ffffff;
}
.ai-callout p {
  margin: 0 0 16px 0;
  color: #d8e4f5;
  font-size: 15px;
  line-height: 1.7;
}
.ai-callout p a {
  color: #82c8ff;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.ai-callout p a:hover { color: #b0dcff; }
.ai-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: #ffffff;
  color: #1e3a5f;
  font-weight: 600;
  font-size: 14px;
  border-radius: 8px;
  text-decoration: none;
  transition: transform 0.1s ease, background 0.15s ease;
  font-family: var(--font-mono);
}
.ai-download-btn:hover {
  background: #f0f6ff;
  transform: translateY(-1px);
}
