/* ============================================================
   api.css — the 🔑 API panel (js/api-panel.js) and the shared
   .api-code block, loaded on every signed-in page. Builds on the
   app.css components (modal, buttons, form-input, section-title);
   colours come from app.css tokens.
   ============================================================ */

.app-page {
  --api-mono: ui-monospace, 'SFMono-Regular', 'Cascadia Mono', 'JetBrains Mono', Menlo, Consolas, 'Liberation Mono', monospace;
}

/* ── Shared code block ────────────────────────────────────────── */

.api-code {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(var(--ink-rgb), .62);
  box-shadow: inset 0 1px 6px rgba(var(--ink-rgb), .45);
  color: color-mix(in srgb, var(--text) 78%, var(--text-secondary));
  font: 400 12.5px/1.7 var(--api-mono);
  white-space: pre;
  tab-size: 2;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
}

.api-code code { font: inherit; color: inherit; }

.api-code:focus-visible {
  outline: none;
  border-color: rgba(var(--primary-rgb), .5);
  box-shadow: var(--focus-ring);
}

/* ── Panel ────────────────────────────────────────────────────── */

.modal-card.api-modal { width: min(600px, 100%); }

.api-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.api-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 176px;
  color: var(--text-muted);
  font-size: 13px;
}

.api-load-error {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.api-load-error .form-error { align-self: stretch; }

.api-creds {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* label ··· buttons
   value (full width, wrapping when needed, so the whole token stays readable) */
.api-cred {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "label actions"
    "value value";
  align-items: center;
  gap: 7px 10px;
}

.api-cred .form-label { grid-area: label; }

.api-cred-actions {
  grid-area: actions;
  display: flex;
  gap: 6px;
}

/* A one-row readonly textarea (js/api-panel.js sizes its height): the value wraps on narrow screens instead of being
   cut off, so the whole token is always visible. */
.form-input.api-value {
  grid-area: value;
  height: auto;
  min-height: 42px;
  padding: 10px 13px;
  overflow: hidden;
  resize: none;
  font-family: var(--api-mono);
  font-size: 13px;
  line-height: 20px;
  letter-spacing: .01em;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-wrap: anywhere;
  cursor: text;
}

.form-input.api-value:not(:focus) {
  background: rgba(var(--ink-rgb), .6);
  box-shadow: inset 0 1px 5px rgba(var(--ink-rgb), .5);
}

.api-cred-token .form-input.api-value { color: var(--primary); }

.form-input.api-value.is-updated { animation: api-value-flash 1.2s var(--ease); }

@keyframes api-value-flash {
  0%, 30% {
    border-color: rgba(var(--success-rgb), .8);
    box-shadow: 0 0 0 3px rgba(var(--success-rgb), .22), 0 0 22px rgba(var(--success-rgb), .25);
  }
}

/* Element-qualified on purpose: app.css resets margins with `.app-page h1, h2, h3, p`, which
   outranks a lone class — an unqualified selector here would silently have no margin at all. */
p.api-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 12px;
  margin-top: -6px;
  font-size: 12px;
  color: var(--text-muted);
}

.api-created {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* ── Quick start ──────────────────────────────────────────────── */

.api-quickstart {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.api-quickstart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.api-quickstart-head .section-title { margin: 0; }

.api-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.api-hint code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(var(--white-rgb), .06);
  color: var(--text-secondary);
  font: 11.5px var(--api-mono);
}

@media (max-width: 540px) {
  .api-panel { gap: 18px; }
  .form-input.api-value { font-size: 12px; padding: 10px; }
  .api-code { padding: 10px 12px; font-size: 12px; }
}
