/* =========================================================================
   The website editor's Agent tab ("Ask Magnet…": src/features/sites/agentPanel.js, docs/AGENT_DESIGN.md §5).
   Agent | Style switch at the top of a live site's right panel; the chat, its live steps, the Changes card and the
   composer. Attio's language: one border level, naked icons, quiet input shadows, the 32/38 control scale. One motion
   (--ease at --dur), none under reduced motion. Linked after collections.css, before responsive.css.
   ========================================================================= */

/* ---- Agent | Style ---- */
.sb-modes { flex: 0 0 auto; padding: var(--space-2-5) var(--space-4) 0; }
.sb-modes .segmented button { height: calc(var(--control-sm) - 4px); }
.sb-panel.is-agent > .sb-tools,
.sb-panel.is-agent > .sb-rp:not(#rpAgent) { display: none; }
.sb-rp--agent { position: relative; }

/* ---- the panel ---- */
.ag { position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0; }
.ag-head { display: flex; align-items: center; gap: var(--space-1); padding: var(--space-2) var(--space-3) var(--space-2) var(--space-4); border-bottom: 1px solid var(--border-faint); }
.ag-chats { display: inline-flex; align-items: center; gap: var(--space-1); min-width: 0; height: var(--control-sm); padding: 0 var(--space-2); margin-left: calc(-1 * var(--space-2)); border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-strong); font: inherit; font-size: var(--text-sm); font-weight: var(--fw-semibold); cursor: pointer; }
.ag-chats span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.ag-chats svg { width: 14px; height: 14px; flex: none; color: var(--text-soft); }
.ag-head .icon-ghost { margin-left: auto; }
@media (hover: hover) and (pointer: fine) { .ag-chats:hover { background: var(--nav-hover-bg); } }
.ag-chats[aria-expanded="true"] { background: var(--nav-active-bg); box-shadow: var(--press-inset-ghost); }

.ag-thread { flex: 1; min-height: 0; overflow: auto; padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-4); scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { .ag-thread { scroll-behavior: auto; } }

/* the empty state */
.ag-empty { margin: auto 0; display: flex; flex-direction: column; align-items: center; gap: var(--space-2); padding: var(--space-4) var(--space-2); text-align: center; }
.ag-empty-mark { display: inline-flex; color: var(--text-soft); }
.ag-empty-mark svg { width: 20px; height: 20px; }
.ag-empty h3 { margin: 0; font-size: var(--text-md); font-weight: var(--fw-semibold); color: var(--text-strong); }
.ag-empty p { max-width: 240px; margin: 0; font-size: var(--text-sm); line-height: var(--leading-normal); color: var(--text-soft); text-wrap: balance; }

/* while the editor asks whether the tab is on (agentPanel agentCheck): its head and composer as skeletons */
.ag-skel-title { width: 72px; height: 12px; margin: calc((var(--control-sm) - 12px) / 2) 0; }
.ag-skel-compose { display: block; height: 84px; margin: 0 var(--space-3) var(--space-3); border-radius: var(--radius-lg); }

/* messages */
.ag-msg { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.ag-msg--user { align-items: flex-end; }
.ag-bubble { max-width: 88%; padding: var(--space-2) var(--space-3); border-radius: var(--radius-lg); background: var(--surface-field); color: var(--text-strong); font-size: var(--text-sm); line-height: var(--leading-normal); white-space: pre-wrap; overflow-wrap: anywhere; }
.ag-pointed { display: inline-flex; align-items: center; gap: var(--space-1); max-width: 88%; font-size: var(--text-xs); color: var(--text-soft); }
.ag-pointed svg { width: 12px; height: 12px; flex: none; }
.ag-msg-photos { display: flex; gap: var(--space-1); flex-wrap: wrap; justify-content: flex-end; }
.ag-msg-photos img { width: 56px; height: 56px; object-fit: cover; border-radius: var(--radius-sm); }

.ag-thinking { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--text-soft); }
.ag-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1-5); }
.ag-step { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--text-muted); }
.ag-step.is-done { color: var(--text-soft); }
.ag-step-ico { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; flex: none; }
.ag-step-ico .spinner { width: 12px; height: 12px; }
.ag-step-ico svg { width: 14px; height: 14px; }
.ag-text { font-size: var(--text-sm); line-height: var(--leading-normal); color: var(--text-strong); white-space: pre-wrap; overflow-wrap: anywhere; }

/* the Changes card: one bordered box, its lines go to their change */
.ag-card { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.ag-card-head { display: flex; align-items: center; gap: var(--space-1-5); padding: var(--space-1-5) var(--space-1-5) var(--space-1-5) var(--space-3); border-bottom: 1px solid var(--border-faint); }
.ag-card-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text-strong); }
.ag-card-head .btn svg { width: 14px; height: 14px; }
.ag-card-state { font-size: var(--text-xs); color: var(--text-soft); padding: 0 var(--space-1-5); }
.ag-lines { list-style: none; margin: 0; padding: var(--space-1); display: flex; flex-direction: column; gap: 1px; }
.ag-line { display: block; width: 100%; text-align: left; min-height: var(--control-sm); padding: var(--space-1-5) var(--space-2); border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text); font: inherit; font-size: var(--text-sm); line-height: var(--leading-snug); cursor: pointer; overflow-wrap: anywhere; }
@media (hover: hover) and (pointer: fine) { .ag-line:not(:disabled):hover { background: var(--nav-hover-bg); } }
.ag-card.is-undone .ag-line { color: var(--text-soft); text-decoration: line-through; cursor: default; }

/* a question for the person: business details, a request to the team */
.ag-confirm { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.ag-confirm.is-done { flex-direction: row; align-items: center; gap: var(--space-2); color: var(--text-muted); font-size: var(--text-sm); }
.ag-confirm.is-done svg { width: 14px; height: 14px; flex: none; }
.ag-confirm-q { margin: 0; font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text-strong); }
.ag-confirm-sum { margin: 0; font-size: var(--text-sm); color: var(--text); }
.ag-confirm-note { margin: 0; font-size: var(--text-xs); line-height: var(--leading-snug); color: var(--text-soft); }
.ag-confirm-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); font-size: var(--text-sm); }
.ag-confirm-rows li { display: flex; gap: var(--space-2); }
.ag-confirm-rows li > span:first-child { width: 104px; flex: none; color: var(--text-soft); }
.ag-confirm-rows b { font-weight: var(--fw-medium); color: var(--text-strong); overflow-wrap: anywhere; }
.ag-confirm-rows .tone-pill { flex: none; }   /* "Check this", on its own row under a detail that sends enquiries */
.ag-confirm-btns { display: flex; gap: var(--space-2); }

.ag-note { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; font-size: var(--text-sm); color: var(--text-muted); }
.ag-note.is-error { color: var(--danger-700); }

/* following paused */
.ag-follow { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin: 0 var(--space-4) var(--space-2); padding: var(--space-1-5) var(--space-1-5) var(--space-1-5) var(--space-3); border-radius: var(--radius-sm); background: var(--surface-sunk); font-size: var(--text-xs); color: var(--text-muted); }
.ag-follow[hidden] { display: none; }

/* the composer: a quiet well, the tools under the words */
.ag-compose { margin: 0 var(--space-3) var(--space-3); padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-xs); transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.ag-compose:focus-within { border-color: var(--border-strong); box-shadow: var(--ring-primary); }
@media (hover: hover) and (pointer: fine) { .ag-compose:hover:not(:focus-within) { box-shadow: var(--shadow-sm); } }
/* (about two lines to start with, growing as it's written in) */
.ag-input { display: block; width: 100%; min-height: 48px; max-height: 168px; padding: var(--space-1) var(--space-1); border: 0; outline: none; resize: none; background: transparent; color: var(--text-strong); font: inherit; font-size: var(--text-sm); line-height: var(--leading-normal); }
.ag-input::placeholder { color: var(--text-placeholder); }
/* the bar under the writing: a hairline over it, edge to edge of the box (its padding undone), the model on the left and
   Point, Add photos and Send together on the right */
.ag-bar { display: flex; align-items: center; gap: var(--space-0-5); margin: var(--space-2) calc(-1 * var(--space-2)) 0; padding: var(--space-2) var(--space-2) 0; border-top: 1px solid var(--border-faint); }
.ag-bar-gap { flex: 1; }
.ag-bar .icon-ghost[aria-pressed="true"] { background: var(--nav-active-bg); color: var(--text-strong); box-shadow: var(--press-inset-ghost); }
/* as wide as the option chosen, its chevron right after the word (the browser's own arrow kept room for the longest
   option): a plain select with the chevron drawn beside it, as the post editor's Text style; agentPanel measures it
   where a browser can't size a select to its content */
.ag-model-wrap { position: relative; display: inline-flex; align-items: center; }
.ag-model-wrap > svg { position: absolute; top: 50%; right: var(--space-2); width: 12px; height: 12px; translate: 0 -50%; color: var(--text-soft); pointer-events: none; }
.ag-model { appearance: none; -webkit-appearance: none; field-sizing: content; height: 30px; padding: 0 calc(var(--space-2) + 12px + var(--space-1)) 0 var(--space-2); border: 0; border-radius: var(--radius-sm); background-color: transparent; color: var(--text-muted); font: inherit; font-size: var(--text-xs); font-weight: var(--fw-medium); cursor: pointer; }
.ag-model:focus-visible { outline: var(--focus-outline); outline-offset: var(--focus-offset); }
@media (hover: hover) and (pointer: fine) { .ag-model:hover { background-color: var(--nav-hover-bg); } }
.ag-send { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border: 0; border-radius: var(--radius-sm); background: var(--btn-primary-bg); color: var(--btn-primary-fg); box-shadow: var(--btn-primary-shadow); cursor: pointer; }
.ag-send svg { width: 16px; height: 16px; }
.ag-send:disabled { background: var(--surface-field); color: var(--text-placeholder); box-shadow: none; cursor: default; }
.ag-send:active:not(:disabled) { box-shadow: var(--btn-primary-press); }
.ag-send.is-stop { background: var(--surface-field); color: var(--text-strong); box-shadow: inset 0 0 0 1px var(--border); }

.ag-chips { display: flex; flex-wrap: wrap; gap: var(--space-1-5); margin-bottom: var(--space-1-5); }
.ag-chips[hidden] { display: none; }
.ag-chip { display: inline-flex; align-items: center; gap: var(--space-1); max-width: 100%; height: 26px; padding: 0 0 0 var(--space-2); border-radius: var(--radius-xs); background: var(--surface-field); font-size: var(--text-xs); color: var(--text-muted); }
.ag-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-chip > svg { width: 12px; height: 12px; flex: none; }
.ag-chip.is-hint { padding-right: var(--space-2); color: var(--text-strong); }
.ag-photo { position: relative; width: 48px; height: 48px; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-field); }
.ag-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ag-photo:not(.is-up) img { opacity: .55; }
.ag-photo .spinner { position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; }
.ag-photo .icon-ghost { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; background: var(--surface); box-shadow: var(--shadow-xs); }
.ag-photo .icon-ghost svg { width: 12px; height: 12px; }

/* dropping photos on the panel */
.ag-drop { position: absolute; inset: var(--space-2); z-index: var(--z-sticky); display: flex; align-items: center; justify-content: center; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg); background: color-mix(in srgb, var(--surface) 92%, transparent); pointer-events: none; font-size: var(--text-sm); color: var(--text-muted); }
.ag-drop[hidden] { display: none; }
.ag-drop span { display: inline-flex; align-items: center; gap: var(--space-2); }
.ag-drop svg { width: 16px; height: 16px; }

/* its menus: the shared menu surface (.filter-menu), placed by the panel */
.ag-menu { top: auto; left: auto; max-width: calc(100% - var(--space-4)); max-height: 60vh; overflow: auto; }
.ag-menu .filter-opt { width: 100%; border: 0; background: transparent; font: inherit; font-size: var(--text-sm); text-align: left; cursor: pointer; }
.ag-menu .filter-opt span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-menu .filter-opt small { color: var(--text-soft); font-size: var(--text-xs); flex: none; }
.ag-menu .filter-opt svg { width: 14px; height: 14px; flex: none; color: var(--text-soft); }
.ag-menu .filter-opt.is-on { background: var(--surface-selected); }
.ag-menu-sep { height: 1px; margin: var(--space-1) var(--space-1-5); background: var(--border-faint); }

/* ---- Sites → Usage → Magnet chats (agentReview.js): a stats band, the replies a list with faint dividers ---- */
.agr-sub { margin: 0 0 var(--space-3); max-width: 70ch; font-size: var(--text-sm); color: var(--text-muted); }
.agr-filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-3); }
.agr-filters select { width: auto; max-width: 220px; }
.agr-check { display: inline-flex; align-items: center; gap: var(--space-1-5); font-size: var(--text-sm); color: var(--text-muted); }
.agr-lines { margin: var(--space-1) 0 0; padding-left: var(--space-4); font-size: var(--text-sm); color: var(--text-muted); }
.agr-skel { height: 64px; margin-bottom: var(--space-2); border-radius: var(--radius-md); }
.agr-list { margin: 0; padding: 0; list-style: none; }
.agr-row { padding: var(--space-3) 0; border-top: 1px solid var(--border-faint); }
.agr-row:first-child { border-top: 0; padding-top: 0; }
.agr-meta { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-2); font-size: var(--text-xs); color: var(--text-soft); }
.agr-meta span + span::before { content: "·"; margin-right: var(--space-2); }
.agr-meta span:first-child { color: var(--text-muted); font-weight: var(--fw-medium); }
.agr-ask { margin: var(--space-1) 0 0; font-size: var(--text-base); font-weight: var(--fw-medium); color: var(--text-strong); overflow-wrap: anywhere; }
.agr-text { margin: var(--space-1) 0 0; font-size: var(--text-sm); color: var(--text-muted); overflow-wrap: anywhere; }
.agr-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); margin-top: var(--space-2); }
.agr-facts { font-size: var(--text-xs); color: var(--text-soft); font-variant-numeric: tabular-nums; }
.agr-acts { display: inline-flex; gap: var(--space-1-5); }
.agr-note { display: flex; gap: var(--space-2); margin-top: var(--space-2); }
.agr-note .input { flex: 1; min-width: 0; }
.agr-said { margin: var(--space-2) 0 0; font-size: var(--text-sm); color: var(--text-muted); }
.agr-prompt { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: var(--space-2) 0 0; font-size: var(--text-sm); color: var(--text-muted); }
.agr-said::before { content: "Not good: "; color: var(--text-soft); }

/* phones: the panel is the editor's sheet; drop zones become the + button */
@media (pointer: coarse) {
  .ag-input { font-size: var(--text-md); }
  .ag-photo { width: 64px; height: 64px; }
  .ag-photo .icon-ghost { top: 0; right: 0; width: 32px; height: 32px; }
  .ag-send, .ag-model { height: 38px; }
  .ag-send { width: 38px; }
}
