/*
  invora-console.css
  Styles for the interactive API console widget: console bar, Send buttons,
  and response panels. All custom properties inherit from brand.css tokens.
*/

/* ── Console bar ──────────────────────────────────────────────────────────── */

/*
  Position: sticky bar that pins below the Material navigation tabs.
  --md-header-height is set by Material for MkDocs; tabs add ~48 px (2.8 rem).
  z-index: 2 sits below Material's header (z-index 4) and tabs (z-index 3).
*/
.inv-console-bar {
  position: sticky;
  top: calc(var(--md-header-height, 2.8rem) + 2.8rem);
  z-index: 2;
  background: var(--md-default-bg-color, #fff);
  border-bottom: 1px solid var(--inv-border, #e6e8ef);
  box-shadow: 0 1px 0 rgba(0, 31, 80, .04), 0 2px 8px rgba(0, 31, 80, .05);
  font-family: var(--md-text-font, Rubik, system-ui, sans-serif);
  font-size: .8125rem; /* 13 px */
}

[data-md-color-scheme="slate"] .inv-console-bar {
  background: var(--md-default-bg-color);
  border-bottom-color: var(--inv-border, rgba(255,255,255,.1));
  box-shadow: 0 1px 0 rgba(0,0,0,.25), 0 2px 8px rgba(0,0,0,.3);
}

.inv-cb__inner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem .75rem;
  max-width: 80rem;
  margin: 0 auto;
  padding: .45rem 1rem;
}

/* ── Brand label ──────────────────────────────────────────────────────────── */

.inv-cb__brand {
  font-weight: 700;
  font-size: .75rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--inv-cobalt, #0059e5);
  user-select: none;
  white-space: nowrap;
}

/* ── Environment selector ─────────────────────────────────────────────────── */

.inv-cb__env {
  display: flex;
  align-items: center;
  gap: .4rem;
}

.inv-cb__env-label {
  font-size: .75rem;
  font-weight: 500;
  color: var(--md-default-fg-color--light, rgba(0,31,80,.6));
  white-space: nowrap;
}

.inv-cb__select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--inv-cobalt-tint, #eef3ff);
  border: 1px solid var(--inv-border, #e6e8ef);
  border-radius: .35rem;
  color: var(--md-default-fg-color, rgba(0,31,80,.87));
  font-family: inherit;
  font-size: .8125rem;
  font-weight: 500;
  padding: .2rem .35rem .2rem .45rem;
  cursor: pointer;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  /* Chevron via inline SVG background */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%230059e5' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .45rem center;
  padding-right: 1.6rem;
}

.inv-cb__select:focus-visible {
  border-color: var(--inv-cobalt, #0059e5);
  box-shadow: 0 0 0 2px rgba(0, 89, 229, .25);
}

[data-md-color-scheme="slate"] .inv-cb__select {
  background-color: rgba(77, 139, 239, .12);
  border-color: rgba(255,255,255,.12);
  color: var(--md-default-fg-color);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%234d8bef' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* ── Auth controls ────────────────────────────────────────────────────────── */

.inv-cb__auth {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-left: auto;
}

.inv-cb__user {
  font-size: .8rem;
  color: var(--md-default-fg-color--light, rgba(0,31,80,.6));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 14rem;
}

.inv-cb__btn {
  appearance: none;
  border: 1.5px solid transparent;
  border-radius: .4rem;
  cursor: pointer;
  font-family: inherit;
  font-size: .8rem;
  font-weight: 600;
  line-height: 1;
  padding: .35rem .8rem;
  white-space: nowrap;
  transition: background-color .15s, border-color .15s, transform .1s, box-shadow .15s;
}

.inv-cb__btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none !important;
}

.inv-cb__btn--in {
  background-color: var(--inv-cobalt, #0059e5);
  border-color: var(--inv-cobalt, #0059e5);
  color: #fff;
}
.inv-cb__btn--in:not(:disabled):hover {
  background-color: var(--inv-cobalt-dark, #0047b8);
  border-color: var(--inv-cobalt-dark, #0047b8);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 89, 229, .3);
}

.inv-cb__btn--out {
  background-color: transparent;
  border-color: var(--inv-border, #e6e8ef);
  color: var(--md-default-fg-color--light, rgba(0,31,80,.6));
}
.inv-cb__btn--out:not(:disabled):hover {
  border-color: var(--inv-cobalt, #0059e5);
  color: var(--inv-cobalt, #0059e5);
  transform: translateY(-1px);
}

/* ── Error banner inside bar ──────────────────────────────────────────────── */

.inv-cb__error {
  width: 100%;
  background: rgba(192, 54, 45, .08);
  border: 1px solid rgba(192, 54, 45, .25);
  border-radius: .4rem;
  color: var(--inv-error, #c0362d);
  font-size: .78rem;
  padding: .3rem .6rem;
  margin-top: .15rem;
}

[data-md-color-scheme="slate"] .inv-cb__error {
  background: rgba(192, 54, 45, .15);
  border-color: rgba(192, 54, 45, .35);
}

/* ── Send row ─────────────────────────────────────────────────────────────── */

.inv-send-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  margin: .45rem 0 0;
  padding: .35rem .6rem;
  background: var(--inv-cobalt-tint, #eef3ff);
  border: 1px solid rgba(0, 89, 229, .15);
  border-radius: 0 0 .45rem .45rem;
  font-family: var(--md-text-font, Rubik, system-ui, sans-serif);
  font-size: .8rem;
}

[data-md-color-scheme="slate"] .inv-send-row {
  background: rgba(77, 139, 239, .1);
  border-color: rgba(77, 139, 239, .25);
}

.inv-send-row__label {
  font-family: var(--md-code-font, 'Roboto Mono', monospace);
  font-size: .75rem;
  color: var(--inv-cobalt, #0059e5);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
}

[data-md-color-scheme="slate"] .inv-send-row__label {
  color: var(--inv-cobalt-light, #4d8bef);
}

/* ── Send button ──────────────────────────────────────────────────────────── */

.inv-send-btn {
  appearance: none;
  background-color: var(--inv-cobalt, #0059e5);
  border: none;
  border-radius: .35rem;
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .01em;
  padding: .3rem .7rem;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color .15s, transform .1s, box-shadow .15s;
}

.inv-send-btn:not(:disabled):hover {
  background-color: var(--inv-cobalt-dark, #0047b8);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 89, 229, .35);
}

.inv-send-btn:disabled {
  opacity: .6;
  cursor: not-allowed;
  transform: none !important;
}

/* ── Response panel ───────────────────────────────────────────────────────── */

.inv-response {
  margin: 0 0 .75rem;
  border: 1px solid var(--inv-border, #e6e8ef);
  border-radius: .5rem;
  background: var(--md-default-bg-color, #fff);
  overflow: hidden;
  font-family: var(--md-text-font, Rubik, system-ui, sans-serif);
  font-size: .8125rem;
}

[data-md-color-scheme="slate"] .inv-response {
  border-color: var(--inv-border, rgba(255,255,255,.1));
}

.inv-response__summary {
  cursor: pointer;
  list-style: none;
  padding: .45rem .75rem;
  font-weight: 600;
  font-size: .8rem;
  color: var(--md-default-fg-color--light, rgba(0,31,80,.6));
  user-select: none;
  background: transparent;
  display: flex;
  align-items: center;
  gap: .4rem;
}

.inv-response__summary::before {
  content: '';
  display: inline-block;
  width: .5rem;
  height: .5rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform .2s;
  margin-right: .1rem;
}

.inv-response[open] > .inv-response__summary::before {
  transform: rotate(45deg) translate(-2px, -2px);
}

.inv-response__summary::-webkit-details-marker { display: none; }

.inv-response__body {
  border-top: 1px solid var(--inv-border, #e6e8ef);
  padding: .6rem .75rem;
}

[data-md-color-scheme="slate"] .inv-response__body {
  border-top-color: var(--inv-border, rgba(255,255,255,.1));
}

/* Status line */
.inv-response__status {
  display: inline-block;
  font-family: var(--md-code-font, 'Roboto Mono', monospace);
  font-size: .8rem;
  font-weight: 600;
  padding: .15rem .5rem;
  border-radius: .3rem;
  margin-bottom: .5rem;
}

.inv-response__status--ok {
  background: rgba(42, 195, 121, .12);
  color: #1a8a55;
}
[data-md-color-scheme="slate"] .inv-response__status--ok {
  background: rgba(42, 195, 121, .18);
  color: var(--inv-success, #2ac379);
}

.inv-response__status--err {
  background: rgba(192, 54, 45, .1);
  color: var(--inv-error, #c0362d);
}
[data-md-color-scheme="slate"] .inv-response__status--err {
  background: rgba(192, 54, 45, .18);
}

.inv-response__status--warn {
  background: rgba(247, 144, 9, .12);
  color: #a85f00;
}
[data-md-color-scheme="slate"] .inv-response__status--warn {
  background: rgba(247, 144, 9, .18);
  color: var(--inv-warning, #f79009);
}

/* JSON / text body */
.inv-response__pre {
  margin: 0;
  overflow: auto;
  max-height: 28rem;
  background: var(--md-code-bg-color, #f5f5f5);
  border-radius: .4rem;
  padding: .6rem .8rem;
  font-size: .78rem;
  line-height: 1.55;
}

.inv-response__pre code {
  font-family: var(--md-code-font, 'Roboto Mono', monospace);
  white-space: pre;
}

/* Loading indicator */
.inv-response__loading {
  color: var(--md-default-fg-color--light, rgba(0,31,80,.55));
  font-size: .8rem;
  padding: .15rem 0;
}

/* ── Placeholder chip strip ───────────────────────────────────────────────── */
/*
  Shown below the main console-bar row when the current page contains placeholder
  tokens (e.g. $TOKEN, $TAP_KEY). Hidden via the `hidden` attribute when no
  tokens are detected so it adds no layout cost on token-free pages.
*/

.inv-cb__placeholders {
  border-top: 1px solid var(--inv-border, #e6e8ef);
  background: var(--md-default-bg-color, #fff);
}

[data-md-color-scheme="slate"] .inv-cb__placeholders {
  border-top-color: var(--inv-border, rgba(255,255,255,.08));
}

.inv-cb__ph-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .6rem;
  max-width: 80rem;
  margin: 0 auto;
  padding: .35rem 1rem;
}

/* ── Individual placeholder chip ──────────────────────────────────────────── */

.inv-ph-chip {
  display: flex;
  align-items: center;
  gap: .3rem;
  background: var(--inv-cobalt-tint, #eef3ff);
  border: 1px solid rgba(0, 89, 229, .15);
  border-radius: 2rem;   /* pill shape */
  padding: .1rem .1rem .1rem .55rem;
  font-size: .75rem;
  white-space: nowrap;
}

[data-md-color-scheme="slate"] .inv-ph-chip {
  background: rgba(77, 139, 239, .1);
  border-color: rgba(77, 139, 239, .22);
}

.inv-ph-chip__label {
  font-size: .7rem;
  font-weight: 600;
  color: var(--inv-cobalt, #0059e5);
  white-space: nowrap;
  cursor: default;
  user-select: none;
  letter-spacing: .01em;
}

[data-md-color-scheme="slate"] .inv-ph-chip__label {
  color: var(--inv-cobalt-light, #4d8bef);
}

.inv-ph-chip__input {
  appearance: none;
  -webkit-appearance: none;
  background: var(--md-default-bg-color, #fff);
  border: 1px solid rgba(0, 89, 229, .2);
  border-radius: 1.5rem;
  color: var(--md-default-fg-color, rgba(0,31,80,.87));
  font-family: var(--md-code-font, 'Roboto Mono', monospace);
  font-size: .75rem;
  height: 1.55rem;
  line-height: 1.55rem;
  outline: none;
  padding: 0 .55rem;
  transition: border-color .15s, box-shadow .15s;
  /* Expand to fit content, but cap at 16 rem so long values don't overflow the bar */
  width: 10rem;
  max-width: 16rem;
}

.inv-ph-chip__input:focus-visible {
  border-color: var(--inv-cobalt, #0059e5);
  box-shadow: 0 0 0 2px rgba(0, 89, 229, .2);
}

[data-md-color-scheme="slate"] .inv-ph-chip__input {
  background: rgba(255,255,255,.06);
  border-color: rgba(77, 139, 239, .25);
  color: var(--md-default-fg-color);
}

[data-md-color-scheme="slate"] .inv-ph-chip__input:focus-visible {
  border-color: var(--inv-cobalt-light, #4d8bef);
  box-shadow: 0 0 0 2px rgba(77, 139, 239, .25);
}

/* Auto-filled inputs (e.g. $TOKEN) are read-only — muted styling signals this. */
.inv-ph-chip__input--auto {
  color: var(--md-default-fg-color--light, rgba(0,31,80,.55));
  cursor: default;
  font-style: italic;
  background: transparent;
  border-color: transparent;
  /* Narrower — just enough to show the truncated token preview. */
  width: 8rem;
}

[data-md-color-scheme="slate"] .inv-ph-chip__input--auto {
  color: var(--md-default-fg-color--lighter, rgba(255,255,255,.35));
  background: transparent;
  border-color: transparent;
}

/* ── Reduced-motion ───────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .inv-cb__btn,
  .inv-send-btn,
  .inv-response__summary::before,
  .inv-ph-chip__input {
    transition: none;
  }
  .inv-cb__btn:hover,
  .inv-send-btn:hover {
    transform: none;
  }
}
