/* Admin "Report AI" section (admin.html) and the section switching it shares with Feedback. */

.admin-section[hidden] {
  display: none;
}

/* Spans the window: the providers' fields sit side by side and the two
   prompts get a column each on a wide screen (see .llm__fields and
   .llm__prompts), stacking again when there isn't room. */
.llm {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.llm__heading {
  margin: 0 0 0.375rem;
  font-size: 1.25rem;
}

.llm__intro {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.llm__status {
  margin: 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-alt);
}

.llm__status[hidden] {
  display: none;
}

.llm__status[data-kind="ok"] {
  border-color: var(--color-node-eligible);
}

.llm__status[data-kind="warn"] {
  border-color: var(--color-node-incomplete-border);
}

.llm__status[data-kind="error"] {
  border-color: var(--color-danger);
  color: var(--color-danger);
}

.llm__body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ---------- Groups: "AI provider", "Prompts" ---------- */

.llm__group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 0;
  padding: 1rem 1.25rem 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.llm__group-head {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* ---------- Provider tabs ---------- */

/* Wraps rather than scrolls: a scroll container would also scroll by the
   1px the selected tab's underline overlaps the border (margin below). */
.llm__tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  border-block-end: 1px solid var(--color-border);
}

.llm__tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  border: none;
  border-block-end: 2px solid transparent;
  margin-block-end: -1px;
  background: transparent;
  color: var(--color-text-muted);
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.llm__tab:hover {
  color: var(--color-text);
}

.llm__tab[aria-selected="true"] {
  color: var(--color-accent);
  border-block-end-color: var(--color-accent);
}

.llm__tab:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}

/* "Active": the provider the AI features use (once saved). */
.llm__badge {
  padding: 0.0625rem 0.5rem;
  border-radius: 999px;
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-size: 0.6875rem;
  font-weight: 700;
}

.llm__badge[hidden] {
  display: none;
}

.llm__panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.llm__panel[hidden] {
  display: none;
}

/* Model / Server address / API key side by side when there is room. */
.llm__fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 0.875rem 1rem;
  align-items: start;
}

.llm__panel-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem 1rem;
}

.llm__panel-footer .llm__check {
  margin-inline-end: auto;
}

/* ---------- Prompts ---------- */

.llm__prompts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(26rem, 1fr));
  gap: 1rem;
}

.llm__prompt-card {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  padding: 0.875rem 1rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-alt);
}

.llm__prompt-card .llm__prompt {
  background: var(--color-surface);
}

.llm__field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.llm__input,
.llm__prompt {
  inline-size: 100%;
  padding: 0.4375rem 0.625rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-alt);
  color: var(--color-text);
  font: inherit;
}

.llm__prompt {
  font-size: 0.8125rem;
  line-height: 1.5;
  resize: vertical;
}

.llm__input[readonly] {
  color: var(--color-text-muted);
}

.llm__input:focus-visible,
.llm__prompt:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.llm__hint {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

.llm__check {
  font-size: 0.8125rem;
}

.llm__h2 {
  margin: 0;
  font-size: 1rem;
}

.llm__h3 {
  margin: 0;
  font-size: 0.9375rem;
}

.llm__restore {
  align-self: flex-start;
}

/* Save / Test stay in view at the bottom of the scrolling page. */
.llm__actions {
  position: sticky;
  inset-block-end: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.625rem;
  padding-block: 0.75rem;
  border-block-start: 1px solid var(--color-border);
  background: var(--color-bg);
}
