/* AI Assistants (Administration) and the Allow page an assistant sends
   somebody to. Docs/AI-ASSISTANTS-PLAN.md. */

/* ---- the address to paste -------------------------------------------------- */

.ai-address { margin-bottom: var(--sp-4); }

.ai-section__title {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  color: var(--txt);
}

.ai-address .ai-section__title { margin-bottom: var(--sp-2); }

.ai-address__row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}

.ai-address__url {
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--txt);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow-wrap: anywhere;
}

.ai-address__row .btn { flex: 0 0 auto; }

.ai-address__warn {
  margin: var(--sp-2) 0 0;
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: var(--warn-fg);
}

/* ---- how to connect, one card per assistant ----------------------------------- */

.ai-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.ai-step {
  min-width: 0;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

.ai-step__title {
  margin: 0 0 6px;
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  color: var(--txt);
}

.ai-step ol,
.ai-step ul {
  margin: 0;
  padding-left: 1.2em;
  font-size: var(--fs-sm);
  line-height: 1.55;
  color: var(--txt-2);
}

/* The base styles take list markers off; these lists are steps and points. */
.ai-step ol { list-style: decimal; }
.ai-step ul { list-style: disc; }

.ai-step li + li { margin-top: 4px; }

@container content (max-width: 900px) {
  .ai-steps { grid-template-columns: minmax(0, 1fr); }
}

@supports not (container-type: inline-size) {
  @media (max-width: 1100px) {
    .ai-steps { grid-template-columns: minmax(0, 1fr); }
  }
}

/* ---- connections and activity ----------------------------------------------------- */

.ai-section__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2) var(--sp-3);
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.ai-section__note { font-size: var(--fs-sm); color: var(--txt-3); }

.ai-activity { margin-top: var(--sp-4); }

.ai-toggle {
  display: inline-flex;
  padding: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}

.ai-toggle__btn {
  min-height: 30px;
  padding: 0 12px;
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--txt-2);
  background: none;
  border: 0;
  border-radius: calc(var(--r-sm) - 2px);
  cursor: pointer;
}

.ai-toggle__btn.is-active {
  color: var(--primary-soft-fg);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(15, 20, 50, 0.08);
}

.ai-table__name { font-weight: var(--fw-semibold); }

.ai-table__confirm {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.ai-muted { color: var(--txt-3); }

.ai-activity__tool { color: var(--txt); }

.ai-activity__target {
  margin-left: 6px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--txt-3);
}

.ai-activity__error {
  display: block;
  margin-top: 2px;
  font-size: var(--fs-xs);
  color: var(--bad-fg);
}

/* Under a finger every control here is 42px, as across the app. */
@media (pointer: coarse) {
  .ai-toggle__btn,
  .ai-address__row .btn,
  .ai-table .btn,
  .ai-allow__actions .btn { min-height: 42px; }
}

/* ---- the Allow page ------------------------------------------------------------------- */

.ai-allow {
  display: flex;
  justify-content: center;
  padding: var(--sp-6) 0;
}

.ai-allow__card { width: 100%; max-width: 560px; }

.ai-allow__icon {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: var(--sp-3);
  color: var(--primary-soft-fg);
  background: var(--primary-soft);
  border-radius: var(--r-md);
}

.ai-allow__icon svg { width: 24px; height: 24px; }

.ai-allow__title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: var(--fw-bold);
  line-height: 1.3;
  color: var(--txt);
  overflow-wrap: anywhere;
}

.ai-allow__lede {
  margin: 0 0 var(--sp-3);
  font-size: var(--fs-base);
  color: var(--txt-2);
}

/* Where the code goes: the one thing a lookalike app cannot fake. */
.ai-allow__dest {
  display: grid;
  gap: 2px;
  margin: 0 0 var(--sp-3);
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

.ai-allow__dest--warn {
  background: var(--warn-bg);
  border-color: var(--warn);
}

.ai-allow__dest-label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--txt-3);
}

.ai-allow__dest-host {
  font-family: var(--font-mono);
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: var(--txt);
  overflow-wrap: anywhere;
}

.ai-allow__dest-note { font-size: var(--fs-sm); color: var(--txt-2); }
.ai-allow__dest--warn .ai-allow__dest-note { color: var(--warn-fg); }

.ai-allow__facts {
  list-style: disc;
  margin: 0 0 var(--sp-4);
  padding-left: 1.2em;
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--txt-2);
}

.ai-allow__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--sp-2);
}

@media (max-width: 480px) {
  .ai-allow { padding: var(--sp-2) 0; }
  .ai-allow__actions .btn { flex: 1 1 0; }
}

/* ---- what assistants asked: a virtualized list in a box of its own ------------ */

.ai-section__heading {
  display: grid;
  gap: 2px;
  min-width: 0;
}

/* The box each virtualized list scrolls in. Virtualize finds its nearest
   scrolling ancestor and measures the rows against it, so the box has to be
   the thing that scrolls, with a height of its own. */
.ai-list__scroll {
  max-height: min(62vh, 600px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Connections are fewer than questions: a shorter box. */
.ai-connections__scroll { max-height: min(46vh, 440px); }

.ai-list__scroll thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
}

.ai-activity__placeholder td { height: 49px; }

.ai-activity__shimmer {
  display: block;
  height: 10px;
  width: min(60%, 320px);
  border-radius: 5px;
  background: var(--line);
  animation: ai-shimmer 1.2s ease-in-out infinite alternate;
}

@keyframes ai-shimmer {
  from { opacity: 0.45; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .ai-activity__shimmer { animation: none; }
}

@media (pointer: coarse) {
  .ai-activity .ai-section__head .btn { min-height: 42px; }
}
