/* ===== EZToTrack API Reference — Three-Panel Layout ===== */

/* ---------- Override portal defaults for this page ---------- */
body.api-ref-page .portal-sidebar { display: none; }
body.api-ref-page .portal-main { margin-left: 0; padding: 0; }
body.api-ref-page .portal-main .portal-content { max-width: none; }

/* ---------- Three-Panel Grid ---------- */
.api-ref-container {
  display: grid;
  grid-template-columns: 260px 1fr 420px;
  height: calc(100vh - var(--header-height));
  margin-top: var(--header-height);
}

/* ---------- Left Nav Panel ---------- */
.api-nav {
  background: #fff;
  border-right: 1px solid var(--gray-200);
  overflow-y: auto;
  padding: 16px 0;
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
}

.api-nav-search {
  padding: 0 12px 12px;
}
.api-nav-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  font-family: 'Open Sans', sans-serif;
}
.api-nav-search input:focus { border-color: var(--blue); }
.api-nav-search input::placeholder { color: var(--gray-400); }

.api-nav-section { margin-bottom: 4px; }
.api-nav-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-500);
  letter-spacing: .05em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
}
.api-nav-section-title:hover { color: var(--gray-700); }
.api-nav-section-title .chevron {
  font-size: 10px;
  transition: transform .2s;
}
.api-nav-section-title.collapsed .chevron { transform: rotate(-90deg); }
.api-nav-section-items { overflow: hidden; transition: max-height .25s ease; }
.api-nav-section-items.collapsed { max-height: 0 !important; overflow: hidden; }

.api-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 18px;
  font-size: 13px;
  color: var(--gray-700);
  border-left: 3px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all .12s;
}
.api-nav-item:hover {
  background: var(--gray-50);
  color: var(--gray-900);
  text-decoration: none;
}
.api-nav-item.active {
  border-left-color: var(--blue);
  background: var(--blue-light);
  color: var(--blue);
  font-weight: 600;
}

/* ---------- Center Docs Panel ---------- */
.api-docs {
  overflow-y: auto;
  padding: 0;
  height: calc(100vh - var(--header-height));
  scroll-behavior: smooth;
}

.api-endpoint-section {
  padding: 40px 48px;
  border-bottom: 1px solid var(--gray-200);
}
.api-endpoint-section:last-child { border-bottom: none; }

.endpoint-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.endpoint-method {
  font-size: 12px;
  font-weight: 700;
  font-family: 'Fira Code', monospace;
  padding: 4px 10px;
  border-radius: 4px;
  text-transform: uppercase;
  flex-shrink: 0;
}
.endpoint-method.get { background: var(--blue-light); color: var(--blue); }
.endpoint-method.post { background: var(--green-light); color: var(--green); }
.endpoint-method.patch { background: var(--teal-light); color: var(--teal); }
.endpoint-method.put { background: var(--orange-light); color: var(--orange); }
.endpoint-method.delete { background: var(--red-light); color: var(--red); }

.endpoint-path-display {
  font-family: 'Fira Code', monospace;
  font-size: 14px;
  color: var(--gray-800);
  font-weight: 500;
}

.endpoint-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 8px;
}

.endpoint-description {
  font-size: 15px;
  color: var(--gray-600);
  line-height: 1.6;
  margin-bottom: 24px;
}
.endpoint-description code {
  background: var(--gray-100);
  color: var(--red);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Fira Code', monospace;
  font-size: 13px;
}

.endpoint-scope {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--gray-500);
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  padding: 4px 10px;
  border-radius: 4px;
  margin-bottom: 24px;
  font-family: 'Fira Code', monospace;
}
.endpoint-scope::before {
  content: '\1F512';
  font-size: 11px;
}

/* ---------- Parameter Table ---------- */
.params-heading {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-800);
  margin: 24px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-200);
}

.param-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-bottom: 24px;
}
.param-table th {
  text-align: left;
  padding: 8px 12px;
  font-weight: 600;
  color: var(--gray-600);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
  border-bottom: 2px solid var(--gray-200);
  background: var(--gray-50);
}
.param-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: top;
}
.param-table tbody tr:hover { background: var(--gray-50); }

.param-name {
  font-family: 'Fira Code', monospace;
  font-size: 13px;
  color: var(--navy);
  font-weight: 500;
}
.param-required {
  color: var(--red);
  font-size: 11px;
  font-weight: 600;
  margin-left: 6px;
}
.param-type {
  font-family: 'Fira Code', monospace;
  font-size: 12px;
  color: var(--gray-500);
}
.param-default {
  font-size: 12px;
  color: var(--gray-400);
}
.param-constraints {
  font-size: 12px;
  color: var(--teal);
}
.param-description {
  color: var(--gray-600);
  line-height: 1.5;
}
.param-description code {
  background: var(--gray-100);
  color: var(--red);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: 'Fira Code', monospace;
  font-size: 12px;
}

/* ---------- Request Body ---------- */
.request-body-heading {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-800);
  margin: 24px 0 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-200);
}
.request-body-type {
  font-size: 12px;
  color: var(--gray-500);
  font-family: 'Fira Code', monospace;
  margin-bottom: 12px;
}

/* ---------- Response Schema ---------- */
.response-heading {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-800);
  margin: 32px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 8px;
}
.response-code {
  font-size: 12px;
  font-weight: 700;
  font-family: 'Fira Code', monospace;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--green-light);
  color: var(--green);
}

.schema-tree { margin: 0; padding: 0; list-style: none; }
.schema-tree .schema-tree { padding-left: 20px; border-left: 1px solid var(--gray-200); margin-left: 8px; }

.schema-field {
  padding: 6px 0;
  font-size: 14px;
}
.schema-field-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  cursor: default;
}
.schema-field-toggle {
  cursor: pointer;
  user-select: none;
}
.schema-field-toggle:hover .schema-field-name { color: var(--blue); }

.schema-field-name {
  font-family: 'Fira Code', monospace;
  font-size: 13px;
  color: var(--navy);
  font-weight: 500;
}
.schema-field-type {
  font-family: 'Fira Code', monospace;
  font-size: 11px;
  color: var(--gray-400);
}
.schema-field-desc {
  color: var(--gray-600);
  font-size: 13px;
}
.schema-field-desc code {
  background: var(--gray-100);
  color: var(--red);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: 'Fira Code', monospace;
  font-size: 12px;
}

.schema-expander {
  font-size: 10px;
  color: var(--gray-400);
  margin-right: 2px;
  transition: transform .15s;
  display: inline-block;
  width: 14px;
}
.schema-expander.expanded { transform: rotate(90deg); }

.schema-children { display: none; }
.schema-children.expanded { display: block; }

/* ---------- Right Code Panel ---------- */
.api-code-panel {
  background: var(--code-bg);
  border-left: 1px solid var(--code-border);
  overflow-y: auto;
  height: calc(100vh - var(--header-height));
  position: sticky;
  top: var(--header-height);
  display: flex;
  flex-direction: column;
}

.code-panel-inner {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Language tabs */
.code-lang-tabs {
  display: flex;
  gap: 0;
  background: rgba(0,0,0,.25);
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
}
.code-lang-tab {
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,.45);
  cursor: pointer;
  border: none;
  background: none;
  transition: all .15s;
  font-family: 'Open Sans', sans-serif;
}
.code-lang-tab:hover { color: rgba(255,255,255,.75); }
.code-lang-tab.active {
  color: #fff;
  background: rgba(255,255,255,.1);
}

/* Credentials section */
.code-credentials {
  flex-shrink: 0;
}
.code-cred-label {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,.4);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
}
.code-cred-input {
  width: 100%;
  padding: 7px 10px;
  background: rgba(0,0,0,.3);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 4px;
  color: #e2e8f0;
  font-size: 12px;
  font-family: 'Fira Code', monospace;
  outline: none;
  margin-bottom: 8px;
}
.code-cred-input:focus { border-color: var(--blue); }
.code-cred-input::placeholder { color: rgba(255,255,255,.25); }

/* Code display */
.code-example-wrapper {
  flex: 1;
  min-height: 0;
  overflow: auto;
  position: relative;
}
.code-example-block {
  position: relative;
}
.code-example-block pre {
  margin: 0;
  padding: 16px;
  background: rgba(0,0,0,.2);
  border-radius: 6px;
  overflow-x: auto;
  font-family: 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.65;
  color: #e2e8f0;
  white-space: pre;
}
.code-example-block .copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color: rgba(255,255,255,.5);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  transition: all .15s;
}
.code-example-block .copy-btn:hover {
  background: rgba(255,255,255,.15);
  color: #fff;
}

/* Try It button */
.try-it-section {
  flex-shrink: 0;
}
.try-it-btn {
  width: 100%;
  padding: 10px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  font-family: 'Open Sans', sans-serif;
}
.try-it-btn:hover { background: var(--blue-hover); }
.try-it-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}
.try-it-btn.loading {
  position: relative;
  color: transparent;
}
.try-it-btn.loading::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

/* Try It param inputs */
.try-it-params {
  flex-shrink: 0;
}
.try-it-param-group {
  margin-bottom: 8px;
}
.try-it-param-label {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,.4);
  margin-bottom: 3px;
}
.try-it-param-input {
  width: 100%;
  padding: 6px 10px;
  background: rgba(0,0,0,.3);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 4px;
  color: #e2e8f0;
  font-size: 12px;
  font-family: 'Fira Code', monospace;
  outline: none;
}
.try-it-param-input:focus { border-color: var(--blue); }
.try-it-param-input::placeholder { color: rgba(255,255,255,.2); }

.try-it-body-textarea {
  width: 100%;
  min-height: 120px;
  padding: 10px;
  background: rgba(0,0,0,.3);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 4px;
  color: #e2e8f0;
  font-size: 12px;
  font-family: 'Fira Code', monospace;
  outline: none;
  resize: vertical;
}
.try-it-body-textarea:focus { border-color: var(--blue); }

/* Response display */
.try-it-response {
  flex-shrink: 0;
  display: none;
}
.try-it-response.visible { display: block; }

.response-status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px 6px 0 0;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Fira Code', monospace;
}
.response-status-bar.success { background: rgba(22,163,74,.15); color: #4ade80; }
.response-status-bar.error { background: rgba(220,38,38,.15); color: #f87171; }

.response-time {
  margin-left: auto;
  font-size: 11px;
  font-weight: 400;
  color: rgba(255,255,255,.4);
}

.response-body-wrapper {
  max-height: 400px;
  overflow: auto;
}
.response-body-wrapper pre {
  margin: 0;
  padding: 12px 16px;
  background: rgba(0,0,0,.25);
  border-radius: 0 0 6px 6px;
  font-family: 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.5;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Section dividers in code panel */
.code-section-divider {
  height: 1px;
  background: rgba(255,255,255,.08);
  margin: 4px 0;
  flex-shrink: 0;
}

/* ---------- Ask AI FAB ---------- */
.ask-ai-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  z-index: 1100;
  transition: transform .15s, box-shadow .15s;
}
.ask-ai-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(0,0,0,.35);
}

/* Ask AI Modal */
.ask-ai-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.3);
  z-index: 1200;
}
.ask-ai-modal-overlay.open { display: flex; align-items: flex-end; justify-content: flex-end; }

.ask-ai-modal {
  width: 400px;
  height: 520px;
  background: #fff;
  border-radius: 12px 12px 0 0;
  margin: 0 24px 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ask-ai-header {
  background: var(--navy);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.ask-ai-header-icon { font-size: 20px; }
.ask-ai-header-title {
  font-size: 16px;
  font-weight: 700;
  flex: 1;
}
.ask-ai-close {
  background: none;
  border: none;
  color: rgba(255,255,255,.6);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}
.ask-ai-close:hover { color: #fff; }

.ask-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.ask-ai-message {
  margin-bottom: 12px;
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
}
.ask-ai-message.bot {
  background: var(--gray-100);
  color: var(--gray-800);
  border-bottom-left-radius: 4px;
}
.ask-ai-message.user {
  background: var(--blue);
  color: #fff;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.ask-ai-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--gray-200);
  flex-shrink: 0;
}
.ask-ai-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  font-family: 'Open Sans', sans-serif;
}
.ask-ai-input:focus { border-color: var(--blue); }
.ask-ai-input::placeholder { color: var(--gray-400); }

.ask-ai-send {
  padding: 10px 16px;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
  font-family: 'Open Sans', sans-serif;
}
.ask-ai-send:hover { background: var(--navy-light); }

/* ---------- Responsive: Two-panel (<1200px) ---------- */
@media (max-width: 1200px) {
  .api-ref-container {
    grid-template-columns: 260px 1fr;
  }
  .api-code-panel {
    display: none;
  }
  /* Show inline code blocks in center panel */
  .api-endpoint-section .inline-code-block {
    display: block !important;
  }
}

/* ---------- Responsive: Single panel (<768px) ---------- */
@media (max-width: 768px) {
  .api-ref-container {
    grid-template-columns: 1fr;
  }
  .api-nav {
    position: fixed;
    left: 0;
    top: var(--header-height);
    bottom: 0;
    width: 280px;
    z-index: 950;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: none;
  }
  .api-nav.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .api-nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--header-height);
    background: rgba(0,0,0,.4);
    z-index: 940;
  }
  .api-nav-overlay.open { display: block; }
  .api-endpoint-section {
    padding: 24px 20px;
  }

  .ask-ai-modal {
    width: 100%;
    height: 100%;
    margin: 0;
    border-radius: 0;
  }
}

/* ---------- Animations ---------- */
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Scrollbar styling (code panel) ---------- */
.api-code-panel::-webkit-scrollbar,
.code-example-wrapper::-webkit-scrollbar,
.response-body-wrapper::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.api-code-panel::-webkit-scrollbar-track,
.code-example-wrapper::-webkit-scrollbar-track,
.response-body-wrapper::-webkit-scrollbar-track {
  background: transparent;
}
.api-code-panel::-webkit-scrollbar-thumb,
.code-example-wrapper::-webkit-scrollbar-thumb,
.response-body-wrapper::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.15);
  border-radius: 3px;
}

.api-docs::-webkit-scrollbar { width: 6px; }
.api-docs::-webkit-scrollbar-track { background: transparent; }
.api-docs::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }

/* Inline code block (shown on smaller screens) */
.inline-code-block {
  display: none;
  margin: 24px 0;
  background: var(--code-bg);
  border-radius: var(--radius);
  overflow: hidden;
}
.inline-code-block pre {
  margin: 0;
  padding: 16px 20px;
  overflow-x: auto;
  font-family: 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #e2e8f0;
}
