/* =====================================================
   JEEBLY INTEGRATIONS — API REFERENCE PAGE
   Sits on top of style.css and uses the same tokens
   ===================================================== */

.api-page { background: var(--jb-bg-alt); }

/* Main grid */
.api-main { padding: 28px 0 80px; }
.api-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 460px;
  gap: 32px;
  align-items: stretch;
}
.api-right { height: 100%; }
@media (max-width: 1250px) {
  .api-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Endpoint title strip */
.api-endpoint {
  background: var(--jb-card);
  border: 1px solid var(--jb-line);
  border-radius: 14px;
  padding: 22px 26px;
  margin-bottom: 22px;
  box-shadow: var(--jb-shadow-sm);
}
.api-endpoint-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.api-method {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 8px;
  font-weight: 800;
  font-size: .78rem;
  letter-spacing: .04em;
  font-family: 'JetBrains Mono', monospace;
}
.api-method.post { background: rgba(40,167,69,.12); color: #218838; border: 1px solid rgba(40,167,69,.25); }
.api-method.get { background: rgba(13,110,253,.12); color: #0d6efd; border: 1px solid rgba(13,110,253,.25); }
.api-method.put { background: rgba(255,193,7,.14); color: #b88800; border: 1px solid rgba(255,193,7,.3); }
.api-method.delete { background: rgba(219,18,75,.12); color: var(--jb-red); border: 1px solid rgba(219,18,75,.25); }
.api-url {
  font-family: 'JetBrains Mono', monospace;
  font-size: .9rem;
  color: var(--jb-text);
  background: var(--jb-bg-alt);
  border: 1px solid var(--jb-line);
  border-radius: 8px;
  padding: 6px 12px;
  flex: 1; min-width: 200px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.api-url-copy {
  background: transparent; border: 1px solid var(--jb-line);
  width: 36px; height: 32px; border-radius: 8px;
  color: var(--jb-muted); cursor: pointer;
  transition: all .15s ease;
}
.api-url-copy:hover { color: var(--jb-red); border-color: var(--jb-red); }

.api-title {
  margin: 14px 0 6px;
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
  color: var(--jb-blue);
}
.api-desc { color: var(--jb-muted); margin: 0; font-size: .96rem; max-width: 760px; }

/* Card base */
.api-card {
  background: var(--jb-card);
  border: 1px solid var(--jb-line);
  border-radius: 14px;
  box-shadow: var(--jb-shadow-sm);
}

/* History */
.api-history-head, .api-history-row {
  display: grid;
  grid-template-columns: 200px 130px 1fr 40px;
  gap: 12px;
  align-items: center;
  padding: 14px 22px;
}
.api-history-card .api-history-head,
.api-history-card .api-history-row {
  grid-template-columns: 130px 110px 120px 1fr;
}
.api-history-head {
  font-size: .72rem;
  font-weight: 700;
  color: var(--jb-muted);
  letter-spacing: .12em;
  border-bottom: 1px solid var(--jb-line);
  background: var(--jb-bg-alt);
  border-top-left-radius: 14px;
  border-top-right-radius: 14px;
}
.api-history-row {
  font-size: .92rem;
  color: var(--jb-text);
}
.api-history-row.is-idle {
  color: var(--jb-muted);
}
.api-history-row.is-idle .jb-method-badge {
  opacity: .45;
}
.api-history-method {
  display: inline-flex;
  align-items: center;
}
.api-history-toggle:disabled {
  opacity: .35;
  cursor: not-allowed;
}
.api-history-toggle:not(:disabled):hover {
  background: var(--jb-bg-alt);
  color: var(--jb-blue);
}
.api-history-time,
.api-history-duration { color: var(--jb-text); font-weight: 600; font-variant-numeric: tabular-nums; }
.api-history-time i,
.api-history-duration i { margin-right: 6px; color: var(--jb-muted); }
.api-history-status {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700;
}
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: #c7ccd5; flex-shrink: 0; }
.dot-green { background: #2dbe60; box-shadow: 0 0 0 3px rgba(45,190,96,.18); }
.dot-red { background: var(--jb-red); box-shadow: 0 0 0 3px rgba(219,18,75,.18); }

.api-tag {
  display: inline-block;
  background: #1f6feb;
  color: #fff; font-size: .78rem; font-weight: 600;
  padding: 4px 12px; border-radius: 999px;
}
.api-tag-soft {
  background: var(--jb-bg-alt);
  color: var(--jb-muted);
  border: 1px solid var(--jb-line);
}
.api-tag-blue { background: #1f6feb; color: #fff; }

.api-history-toggle {
  background: transparent; border: 0; color: var(--jb-muted);
  width: 32px; height: 32px; border-radius: 8px; cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.api-history-toggle:hover { background: var(--jb-bg-alt); color: var(--jb-text); }

/* Section head */
.api-section-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  margin: 28px 0 14px;
}
.api-section-head h2 {
  font-weight: 800; font-size: 1.1rem; margin: 0;
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--jb-blue);
}
.api-required-key {
  font-size: .82rem; color: var(--jb-muted);
}
.api-required-key .req {
  color: var(--jb-red); font-weight: 600;
}

/* Form rows */
.api-fields {
  background: var(--jb-card);
  border: 1px solid var(--jb-line);
  border-radius: 14px;
  box-shadow: var(--jb-shadow-sm);
  overflow: hidden;
}
.api-field {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 20px;
  align-items: center;
  padding: 16px 22px;
  border-bottom: 1px solid var(--jb-line);
}
.api-field:last-child { border-bottom: 0; }
.api-field-label {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  color: var(--jb-text);
  font-size: .92rem;
}
.api-field-label .name {
  font-family: 'JetBrains Mono', monospace;
  word-break: break-all;
  overflow-wrap: break-word;
  display: inline-block;
  vertical-align: middle;
}
.api-field-label .type {
  font-family: 'Poppins', sans-serif;
  color: var(--jb-muted);
  font-weight: 500;
  margin-left: 6px;
  font-size: .7rem;
  background: var(--jb-bg-alt);
  border: 1px solid var(--jb-line);
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
  vertical-align: middle;
  line-height: 1.2;
}
.api-field-label .req {
  font-family: 'Poppins', sans-serif;
  color: var(--jb-red);
  font-weight: 600;
  margin-left: 6px;
  font-size: .7rem;
  background: rgba(219, 18, 75, 0.08);
  border: 1px solid rgba(219, 18, 75, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
  vertical-align: middle;
  line-height: 1.2;
}
.api-field-desc {
  display: block;
  color: var(--jb-muted);
  font-size: .86rem;
  font-weight: 400;
  font-family: 'Poppins', sans-serif;
  margin-top: 6px;
  line-height: 1.5;
}
.api-field-input,
.api-field-select {
  width: 100%;
  background: var(--jb-bg);
  border: 1px solid var(--jb-line);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .92rem;
  color: var(--jb-text);
  font-family: 'Poppins', sans-serif;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.api-field-input::placeholder { color: #b6bdc8; }
.api-field-input:focus,
.api-field-select:focus {
  outline: 0;
  border-color: var(--jb-blue);
  box-shadow: 0 0 0 3px rgba(0,62,112,.12);
}
.api-field.is-invalid .api-field-input,
.api-field.is-invalid .api-field-select {
  border-color: var(--jb-red);
  box-shadow: 0 0 0 3px rgba(219,18,75,.12);
}
.api-field.is-disabled .api-field-input,
.api-field-input:disabled {
  background: #f0f2f5;
  color: #9aa3b2;
  cursor: not-allowed;
  opacity: 0.85;
}
.api-field-date-ymd {
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  letter-spacing: 0.02em;
}

/* Responses */
.api-responses { margin-top: 28px; display: flex; flex-direction: column; gap: 12px; }
.api-response-card {
  background: var(--jb-card);
  border: 1px solid var(--jb-line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--jb-shadow-sm);
}
.api-response-head {
  width: 100%;
  background: transparent;
  border: 0;
  padding: 14px 22px;
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer;
  color: var(--jb-text);
  transition: background .15s ease;
}
.api-response-head:hover { background: var(--jb-bg-alt); }
.api-response-title { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: .94rem; }
.api-response-title strong { font-weight: 700; margin-left: 4px; }
.api-response-head i { transition: transform .2s ease; color: var(--jb-muted); }
.api-response-card.is-open .api-response-head i { transform: rotate(90deg); }
.api-response-body {
  display: none;
  background: var(--jb-code-bg);
  padding: 4px 0 8px;
}
.api-response-card.is-open .api-response-body { display: block; }

/* Next link */
.api-next { margin-top: 36px; }
.api-next-link {
  color: var(--jb-red);
  font-weight: 600;
  text-decoration: none;
  font-size: .98rem;
}
.api-next-link:hover { color: var(--jb-red-hover); }
.api-next-link i { transition: transform .15s ease; }
.api-next-link:hover i { transform: translateX(4px); }

/* ============ RIGHT COLUMN ============ */
.api-right { position: relative; min-width: 0; }
.api-left { min-width: 0; }
.api-right-inner {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.api-lang-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--jb-card);
  border: 1px solid var(--jb-line);
  border-radius: 12px;
  padding: 6px;
  box-shadow: var(--jb-shadow-sm);
  overflow-x: auto;
  scrollbar-width: none;
}
.api-lang-tabs::-webkit-scrollbar { display: none; }
.api-lang {
  border: 0; background: transparent;
  padding: 8px 12px;
  border-radius: 8px;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .82rem; font-weight: 600;
  color: var(--jb-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.api-lang:hover { color: var(--jb-text); background: var(--jb-bg-alt); }
.api-lang.active { background: var(--jb-bg-alt); color: var(--jb-text); }
.api-lang i { font-size: 14px; }
.api-lang span { font-family: 'JetBrains Mono', monospace; }
.api-lang-more {
  margin-left: auto;
  border: 0; background: transparent;
  width: 32px; height: 32px; border-radius: 8px;
  color: var(--jb-muted); cursor: pointer;
}
.api-lang-more:hover { background: var(--jb-bg-alt); color: var(--jb-text); }

/* Code window */
.api-code-window {
  background: var(--jb-code-bg);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.06);
  box-shadow: 0 18px 40px rgba(15,23,42,.18), 0 4px 14px rgba(15,23,42,.06);
  display: flex; flex-direction: column;
  min-height: 320px;
  flex: 1 1 auto;
  max-height: 60vh;
  min-width: 0;
}
.api-code-bar {
  padding: 24px 9px;
  font-family: 'JetBrains Mono', monospace;
  font-size: .72rem;
  color: rgba(255,255,255,.7);
  border-bottom: 1px solid rgba(255,255,255,.06);
  white-space: nowrap; overflow-x: auto;
  scrollbar-width: thin;
}
.api-code-prompt { color: #2dbe60; margin-right: 8px; font-weight: 700; }
.api-code-install { color: #b3c0d6; }
.api-code {
  margin: 0; padding: 16px 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: .82rem;
  line-height: 1.65;
  color: #d6deeb;
  background: transparent;
  flex: 1 1 auto;
  overflow: auto;
}
.api-code code { background: transparent !important; padding: 0 !important; }
.api-code-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px 14px;
  border-top: 1px solid rgba(255,255,255,.04);
}
.api-code-foot-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
}
.api-lang-select {
  flex: 1 1 160px;
  max-width: 220px;
  min-width: 120px;
  padding: 8px 32px 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.28);
  background-color: #1e2a3a;
  color: #ffffff;
  font-size: .82rem;
  font-weight: 600;
  font-family: 'Poppins', sans-serif;
  cursor: pointer;
  appearance: none;
  color-scheme: light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff' d='M3 5l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.api-lang-select:hover {
  border-color: rgba(255,255,255,.45);
  background-color: #243447;
}
.api-lang-select:focus {
  outline: none;
  border-color: rgba(45,190,96,.65);
  box-shadow: 0 0 0 2px rgba(45,190,96,.25);
  background-color: #1e2a3a;
  color: #ffffff;
}
/* Open list — dark text on white (native select ignores light text on options) */
.api-lang-select option {
  color: #0f172a !important;
  background-color: #ffffff !important;
  font-weight: 500;
}
.api-lang-select option:checked,
.api-lang-select option:hover {
  color: #ffffff !important;
  background-color: #003e70 !important;
}
.api-code-copy span {
  font-size: .78rem;
  font-weight: 600;
  margin-left: 6px;
}
.api-code-foot .api-code-copy {
  width: auto;
  padding: 0 14px;
  gap: 4px;
}
.api-code-copy {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  color: rgba(255,255,255,.7);
  width: 36px; height: 36px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all .15s ease;
}
.api-code-copy:hover { background: rgba(255,255,255,.12); color: #fff; }
.api-try-btn {
  background: #1f6feb;
  color: #fff;
  border: 0;
  font-weight: 700; font-size: .92rem;
  padding: 10px 22px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}
.api-try-btn:hover { background: #1860d6; transform: translateY(-1px); }
.api-try-btn.is-loading { opacity: .65; cursor: wait; }

/* Response chooser */
.api-response-chooser { padding: 18px 20px; }
.api-chooser-text { font-size: .92rem; color: var(--jb-text); margin: 0 0 8px; }
.api-chooser-sub { font-weight: 700; color: var(--jb-blue); margin: 12px 0 8px; font-size: .88rem; }
.api-chooser-options { display: flex; gap: 8px; flex-wrap: wrap; }
.api-chooser-btn {
  background: var(--jb-bg-alt);
  border: 1px solid var(--jb-line);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: .86rem; font-weight: 600;
  color: var(--jb-text);
  display: inline-flex; align-items: center; gap: 8px;
  cursor: pointer;
  transition: all .15s ease;
}
.api-chooser-btn:hover { border-color: var(--jb-blue); color: var(--jb-blue); }
.api-chooser-btn.active { border-color: var(--jb-red); background: var(--jb-red-soft); color: var(--jb-red); }

/* Auth credentials (Try It!) */
.api-auth-card { padding: 14px 16px; margin-bottom: 12px; }
.api-auth-label { font-size: .86rem; font-weight: 700; color: var(--jb-text); margin: 0 0 10px; }
.api-auth-fields { display: grid; gap: 10px; }
.api-auth-field label {
  display: block; font-size: .72rem; font-weight: 600;
  font-family: var(--jb-mono, 'JetBrains Mono', monospace);
  color: var(--jb-muted); margin-bottom: 4px;
}
.api-auth-input {
  width: 100%; padding: 8px 10px; font-size: .86rem;
  border: 1px solid var(--jb-line); border-radius: 8px;
  background: var(--jb-bg-alt); color: var(--jb-text);
}
.api-auth-input:focus { outline: none; border-color: var(--jb-blue); box-shadow: 0 0 0 3px rgba(0,62,112,.08); }
.api-auth-field.is-invalid .api-auth-input { border-color: #dc3545; box-shadow: 0 0 0 3px rgba(220,53,69,.12); }

/* Live Try It! response */
.api-live-response { margin-bottom: 4px; }
.api-live-head {
  display: flex; align-items: center; gap: 8px;
  font-size: .92rem; color: var(--jb-text); margin-bottom: 4px;
}
.api-live-duration {
  font-weight: 600;
  font-size: .85rem;
  color: var(--jb-muted);
  font-variant-numeric: tabular-nums;
}
.api-live-duration i { margin-right: 4px; }
.api-live-body {
  margin: 0; max-height: 320px; overflow: auto;
  border-radius: var(--jb-radius-sm, 8px);
  font-size: .78rem;
  background: var(--jb-code-bg);
  color: #d6deeb;
}
.api-live-body code { color: inherit; }

.api-live-pdf { margin-top: 8px; }
.api-pdf-meta {
  font-size: .85rem;
  color: var(--jb-muted);
  margin: 0 0 10px;
}
.api-pdf-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  text-decoration: none;
}
.api-pdf-frame {
  width: 100%;
  height: 420px;
  border: 1px solid var(--jb-line);
  border-radius: var(--jb-radius-sm, 8px);
  background: #fff;
}

/* Field group headers (Scheduled API grouped form) */
.api-field-group {
  border-bottom: 1px solid var(--jb-line);
}
.api-field-group-header {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--jb-muted);
  background: var(--jb-bg-alt);
  width: 100%;
}
.api-field-group-header i {
  font-size: .82rem;
  color: var(--jb-blue);
}

/* Tablet and Mobile field stacking */
@media (max-width: 991.98px) {
  .api-field {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

/* Mobile field stacking & table overrides */
@media (max-width: 720px) {
  .api-history-head, .api-history-row {
    grid-template-columns: 1fr 1fr; row-gap: 4px;
  }
  .api-history-head span:nth-child(3),
  .api-history-row .api-history-method,
  .api-history-toggle { display: none; }
  .api-history-card .api-history-head span:nth-child(2),
  .api-history-card .api-history-head span:nth-child(4),
  .api-history-card .api-history-row .api-history-duration,
  .api-history-card .api-history-row .api-history-method { display: none; }
}

/* Scrollbar polish in code panel */
.api-code::-webkit-scrollbar { width: 8px; height: 8px; }
.api-code::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }
.api-code::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); }

/* Additional Mobile / Tablet Optimization Overrides */
@media (max-width: 767.98px) {
  .api-field {
    padding: 12px 16px;
  }
  .api-fields {
    border-radius: 10px;
  }
  .api-endpoint {
    padding: 16px 18px;
    border-radius: 10px;
    margin-bottom: 16px;
  }
  .api-card {
    border-radius: 10px;
  }
  .api-field-group-header {
    padding: 10px 16px;
    font-size: .72rem;
  }
  .api-section-head {
    margin: 20px 0 10px;
    padding: 0 4px;
  }
  .api-responses {
    margin-top: 20px;
  }
}

@media (max-width: 576px) {
  .api-url {
    font-size: 0.8rem;
    padding: 5px 8px;
    min-width: 150px;
  }
  .api-method {
    font-size: 0.72rem;
    padding: 4px 10px;
  }
  .api-title {
    font-size: 1.35rem;
  }
  .api-history-head, .api-history-row {
    font-size: 0.8rem;
    padding: 10px 12px;
  }
  .api-code-foot {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .api-code-foot-left {
    width: 100%;
  }
  .api-lang-select {
    max-width: none;
    flex: 1;
  }
  .api-try-btn {
    width: 100%;
    text-align: center;
  }
  .api-endpoint .d-flex {
    flex-direction: column;
    align-items: stretch !important;
  }
  .api-endpoint .jb-btn-primary {
    width: 100%;
    text-align: center;
    margin-top: 8px;
  }
}
