* { box-sizing: border-box; }

:root {
  --docs-topbar-h: 52px;
  --docs-fill-h: calc(100vh - var(--docs-topbar-h));
  --docs-pad-x: clamp(12px, 4vw, 36px);
  --docs-content-pad-y: clamp(20px, 4vw, 34px);
}

@supports (height: 100dvh) {
  :root {
    --docs-fill-h: calc(100dvh - var(--docs-topbar-h));
  }
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--docs-topbar-h) + 12px);
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  height: 100%;
  display: flex;
  flex-direction: column;
  font-family: Arial, Helvetica, sans-serif;
  color: #333;
  background: #f6f7f9;
  font-size: clamp(13px, 1.5vw + 10px, 15px);
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
  overflow-x: clip;
}

/* ——— Top bar ——— */
.topbar {
  height: var(--docs-topbar-h);
  min-height: var(--docs-topbar-h);
  flex-shrink: 0;
  background: #fff;
  border-bottom: 1px solid #ddd;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(8px, 2vw, 16px);
  padding: 0 clamp(10px, 3vw, 20px) 0 clamp(10px, 2vw, 16px);
  position: sticky;
  top: 0;
  z-index: 20;
  overflow-x: auto;
  overflow-y: hidden;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
}

.topbar-logo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  text-decoration: none;
}

.topbar-logo img {
  display: block;
  height: clamp(22px, 4vw, 28px);
  width: auto;
  max-width: min(120px, 32vw);
  object-fit: contain;
}

.website-btn {
  flex-shrink: 0;
  height: 32px;
  min-height: 32px;
  border: 1px solid #d8d8d8;
  background: #fff;
  border-radius: 4px;
  padding: 0 clamp(8px, 2vw, 12px);
  color: #555;
  font-weight: 700;
  font-size: clamp(11px, 1vw + 10px, 13px);
  cursor: pointer;
  touch-action: manipulation;
}

.website-btn:focus-visible {
  outline: 2px solid #ff5c36;
  outline-offset: 2px;
}

/* ——— Layout grid ——— */
.app {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) minmax(260px, clamp(280px, 38vw, 560px));
  min-height: var(--docs-fill-h);
  min-width: 0;
}

.app.overview-mode {
  grid-template-columns: 250px minmax(0, 1fr);
}

.app.overview-mode .right-panel {
  display: none;
}

/* ——— Sidebar ——— */
.sidebar {
  background: #f7f8fa;
  border-right: 1px solid #ddd;
  align-self: start;
  position: sticky;
  top: var(--docs-topbar-h);
  height: var(--docs-fill-h);
  max-height: var(--docs-fill-h);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 10px max(24px, env(safe-area-inset-bottom)) 10px;
  -webkit-overflow-scrolling: touch;
  min-width: 0;
}

.sidebar-section-title {
  padding: 0 6px;
  margin: 16px 0 10px;
  font-size: clamp(10px, 1vw + 8px, 11px);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #999;
  font-weight: 800;
}

.sidebar > .sidebar-section-title:first-of-type {
  margin-top: 0;
}

.sidebar a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  min-height: 44px;
  color: #555;
  text-decoration: none;
  font-size: clamp(12px, 1vw + 11px, 13px);
  border-radius: 4px;
  font-weight: 600;
  touch-action: manipulation;
}

.sidebar a:hover,
.sidebar a.active {
  background: #e9e9e9;
  color: #222;
}

.sidebar a:focus-visible {
  outline: 2px solid #ff5c36;
  outline-offset: 2px;
}

.sidebar-pages {
  display: block;
}

.method-post {
  color: #f26b3a;
  font-size: 10px;
  font-weight: 800;
}

/* ——— Main content ——— */
.content {
  padding: var(--docs-content-pad-y) var(--docs-pad-x) clamp(40px, 8vw, 70px);
  min-width: 0;
  max-width: 100%;
}

.page {
  display: none;
}

.page.active {
  display: block;
  scroll-margin-top: calc(var(--docs-topbar-h) + 8px);
}

.endpoint-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 14px;
  margin-bottom: clamp(12px, 2vw, 18px);
}

.endpoint-header .verb {
  color: #0c8f43;
  font-weight: 800;
  flex-shrink: 0;
}

.endpoint-header h1 {
  margin: 0;
  font-size: clamp(1.15rem, 2.8vw + 0.6rem, 1.75rem);
  font-weight: 800;
  line-height: 1.2;
  flex: 1 1 200px;
  min-width: 0;
}

.url-box {
  background: #fff;
  border: 1px solid #e1e1e1;
  border-radius: 4px;
  padding: clamp(10px, 2vw, 12px);
  margin: clamp(12px, 2vw, 18px) 0;
  font-size: clamp(11px, 1vw + 10px, 12.5px);
  overflow-wrap: anywhere;
  word-break: break-word;
}

p {
  color: #555;
  line-height: 1.65;
  max-width: 72ch;
}

ul {
  padding-left: clamp(20px, 5vw, 28px);
}

code.inline {
  background: #eee;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 0.92em;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.section-title {
  margin-top: clamp(22px, 4vw, 30px);
  padding-bottom: 8px;
  border-bottom: 1px solid #dedede;
  font-size: clamp(0.9rem, 1.2vw + 0.65rem, 0.95rem);
  font-weight: 800;
  line-height: 1.35;
}

.params-table {
  width: 100%;
  max-width: 100%;
  margin-top: clamp(16px, 3vw, 24px);
  font-size: clamp(11.5px, 1vw + 10px, 12.5px);
  border-collapse: collapse;
  table-layout: fixed;
}

.params-table td {
  padding: clamp(8px, 1.5vw, 10px) 0;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.params-table .name {
  width: 34%;
  min-width: 0;
  font-weight: 800;
  padding-right: 12px;
}

.params-table td:not(.name) {
  width: 66%;
}

/* Body Params (merchant / reseller): Field — Example — Expected value */
.params-table.body-params {
  table-layout: auto;
  text-align: left;
}

/* UA styles often center <th>; force left for Body Params headers */
.params-table.body-params > thead > tr > th {
  padding: clamp(8px, 1.5vw, 10px) 8px 8px 0;
  border-bottom: 1px solid #e5e5e5;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #5a6570;
  text-align: left !important;
  vertical-align: bottom;
}

.params-table.body-params > thead > tr > th:first-child {
  padding-left: 0;
}

.params-table.body-params tbody td {
  text-align: left;
  padding-right: 10px;
}

.params-table.body-params tbody td:last-child {
  padding-right: 0;
}

.params-table.body-params .name {
  width: 22%;
}

.params-table.body-params td.example,
.params-table.body-params th.example {
  width: 26%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
  color: #1a1a1a;
  text-align: left !important;
}

.params-table.body-params td.param-desc,
.params-table.body-params th.param-desc {
  width: 52%;
  color: #4b5563;
  font-weight: 400;
  line-height: 1.45;
  text-align: left !important;
}

.params-table.body-params thead th.name {
  text-align: left !important;
}

.overview-title {
  font-size: clamp(1.35rem, 3.5vw + 0.75rem, 1.75rem);
  font-weight: 800;
  line-height: 1.2;
}

.overview-intro {
  max-width: 760px;
  margin-bottom: clamp(18px, 3vw, 28px);
}

.docs-url-note {
  max-width: 72ch;
  margin: clamp(-6px, -1vw, 0) 0 clamp(14px, 2vw, 18px);
  padding: 10px 12px;
  font-size: clamp(12px, 1vw + 10px, 13px);
  line-height: 1.5;
  color: #4a5563;
  background: #f8f9fa;
  border: 1px solid #e8eaed;
  border-radius: 6px;
}

#doc-errors .docs-inline-code {
  margin-top: clamp(10px, 2vw, 14px);
  margin-bottom: clamp(18px, 3vw, 24px);
}

.cards-title {
  margin: clamp(20px, 3vw, 28px) 0 clamp(14px, 2vw, 18px);
  font-size: clamp(1rem, 1.5vw + 0.75rem, 1.125rem);
  font-weight: 800;
}

.overview-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(12px, 2.5vw, 18px);
}

.overview-card {
  background: #fff;
  border: 1px solid #dedede;
  border-radius: 4px;
  cursor: pointer;
  touch-action: manipulation;
  min-height: 44px;
}

.overview-card-body {
  padding: clamp(14px, 2.5vw, 18px) clamp(14px, 3vw, 20px);
}

.overview-card-body h3 {
  margin: 0 0 8px;
  font-size: clamp(1rem, 1.2vw + 0.85rem, 1.1rem);
}

.overview-card-body p {
  margin: 0;
  font-size: 0.95em;
}

/* ——— Right panel (examples) ——— */
.right-panel {
  background: #292929;
  color: #efefef;
  align-self: stretch;
  position: sticky;
  top: var(--docs-topbar-h);
  height: var(--docs-fill-h);
  max-height: var(--docs-fill-h);
  min-height: var(--docs-fill-h);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid #3a3a3a;
  min-width: 0;
}

.right-page {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.right-page.active {
  display: flex;
}

.right-top {
  flex-shrink: 0;
  padding: 0 clamp(14px, 3vw, 32px);
  min-height: 52px;
  height: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #3c3c3c;
  font-size: clamp(12px, 1.2vw + 10px, 14px);
}

.right-top strong,
.right-top span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.example-section {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px clamp(14px, 3vw, 32px) max(20px, env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
}

.code-card {
  background: #333;
  border-radius: 4px;
  margin-bottom: 18px;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.code-card:last-child {
  margin-bottom: 0;
}

pre {
  margin: 0;
  padding: clamp(10px, 2vw, 14px);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: clamp(10px, 0.35rem + 2.2vw, 13px);
  line-height: 1.45;
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
  min-width: min(100%, max-content);
}

.green-code {
  color: #7aa05b;
}

.response-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 12px 0 14px;
  border-bottom: 1px solid #444;
  font-size: clamp(11px, 1vw + 10px, 13px);
}

.response-tabs span {
  padding: 10px 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: #bbb;
  cursor: pointer;
  position: relative;
  touch-action: manipulation;
}

.response-tabs span.active {
  color: #fff;
  font-weight: 700;
}

.response-tabs span.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 2px;
  background: #ff5c36;
}

.right-panel .section-title {
  color: #fff;
  border-color: #444;
  margin-top: 18px;
}

/* ——— Wide → narrow grid ——— */
@media (max-width: 1320px) {
  .app:not(.overview-mode) {
    grid-template-columns: 230px minmax(0, 1fr) minmax(240px, clamp(260px, 36vw, 480px));
  }
}

@media (max-width: 1180px) {
  .app:not(.overview-mode) {
    grid-template-columns: 210px minmax(0, 1fr) minmax(220px, 32vw);
  }
}

@media (max-width: 1024px) {
  .app.overview-mode {
    grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .app.overview-mode {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Overview : liens nav en grille 2 colonnes tant que la grille 3-col desktop est encore active */
  .app.overview-mode .sidebar {
    position: relative;
    top: auto;
    height: auto;
    max-height: none;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 12px;
    align-content: start;
    border-right: none;
    border-bottom: 1px solid #ddd;
    padding: 12px var(--docs-pad-x) 16px;
  }

  .app.overview-mode .sidebar-section-title {
    grid-column: 1 / -1;
    margin-top: 12px;
    margin-bottom: 6px;
  }

  .app.overview-mode .sidebar-section-title:first-of-type {
    margin-top: 0;
  }

  .app.overview-mode .sidebar > .sidebar-section-title:first-of-type {
    margin-top: 0;
  }

  .app.overview-mode .sidebar a {
    grid-column: span 1;
  }

  .app.overview-mode .sidebar-pages {
    grid-column: 1 / -1;
  }
}

/*
 * Tablette / mobile : une colonne (nav → contenu → exemples code).
 * Déclenché tôt pour éviter une grille 3 colonnes illisible entre ~820px et 1100px.
 */
@media (max-width: 1100px) {
  .app,
  .app.overview-mode {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: relative;
    top: auto;
    height: auto;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid #ddd;
    padding: 12px var(--docs-pad-x) 14px;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar-section-title {
    margin-top: 12px;
  }

  .sidebar > .sidebar-section-title:first-of-type {
    margin-top: 0;
  }

  .sidebar a {
    min-height: 44px;
  }

  .content {
    padding-top: clamp(14px, 3vw, 22px);
    padding-bottom: clamp(28px, 6vw, 48px);
  }

  .right-panel {
    position: relative;
    top: auto;
    border-left: none;
    border-top: 1px solid #3a3a3a;
    height: auto;
    min-height: min(280px, 55dvh);
    max-height: min(520px, 78dvh);
    min-width: 0;
  }

  .example-section {
    padding-left: clamp(12px, 3vw, 24px);
    padding-right: clamp(12px, 3vw, 24px);
  }

  .right-top {
    padding-left: clamp(12px, 3vw, 24px);
    padding-right: clamp(12px, 3vw, 24px);
    flex-wrap: wrap;
    min-height: 48px;
    height: auto;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .right-top strong,
  .right-top span {
    white-space: normal;
  }
}

/* ——— Compact phone : nav en pastilles défilantes ——— */
@media (max-width: 640px) {
  .sidebar-pages {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 2px 12px;
    margin: 0 -4px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .sidebar-pages::-webkit-scrollbar {
    height: 4px;
  }

  .sidebar-pages .sidebar-section-title {
    display: none;
  }

  .sidebar-pages .nav-link {
    flex: 0 0 auto;
    scroll-snap-align: start;
    padding: 10px 14px;
    min-height: 44px;
    border-radius: 999px;
    border: 1px solid #dedede;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  }

  .sidebar-pages .nav-link.active {
    border-color: #bbb;
    background: #e9e9e9;
  }
}

@media (max-width: 820px) {
  .overview-cards {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding-left: max(8px, env(safe-area-inset-left, 0px));
    padding-right: max(8px, env(safe-area-inset-right, 0px));
  }

  .endpoint-header {
    gap: 8px;
  }

  pre {
    font-size: clamp(10px, 2.8vw, 12px);
  }

  .right-panel {
    min-height: min(260px, 50dvh);
    max-height: min(480px, 72dvh);
  }
}

/* ——— Tables : cartes empilées sur très petit écran ——— */
@media (max-width: 520px) {
  .params-table,
  .params-table tbody,
  .params-table tr,
  .params-table td {
    display: block;
    width: 100%;
  }

  .params-table tr {
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e5e5;
  }

  .params-table tr:last-child {
    border-bottom: none;
  }

  .params-table .name {
    width: 100%;
    padding: 0 0 4px;
    font-weight: 800;
  }

  .params-table td:not(.name) {
    width: 100%;
    padding-top: 0;
    color: #555;
  }

  .params-table.body-params thead {
    display: none;
  }

  .params-table.body-params td.example::before {
    display: block;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #888;
    margin-bottom: 6px;
    text-align: left;
    content: "Example";
  }

  .params-table.body-params td.param-desc::before {
    display: block;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #888;
    margin-bottom: 6px;
    margin-top: 10px;
    text-align: left;
    content: "Expected value";
  }

  .params-table.body-params td.example {
    padding-bottom: 4px;
  }
}

@media (max-width: 380px) {
  .endpoint-header h1 {
    flex-basis: 100%;
  }
}
