/* =========================================================
   Agentes — avatar, seletor (topo/composer) e módulo CRUD
   ========================================================= */
.agent-avatar {
  display: inline-grid; place-items: center; flex-shrink: 0; border-radius: 999px;
  font-weight: 600; color: #fff; letter-spacing: .01em;
}

/* ---------- Seletor de agente (topo) ---------- */
.agent-picker {
  display: flex; align-items: center; gap: 8px; max-width: 220px; height: 36px; padding: 0 10px 0 6px;
  border-radius: 12px; font-size: 14px; font-weight: 500; transition: background-color .2s;
}
.agent-picker:hover, .agent-picker[aria-expanded="true"] { background: rgb(0 0 0 / .05); }
.dark .agent-picker:hover, .dark .agent-picker[aria-expanded="true"] { background: rgb(255 255 255 / .05); }
.agent-picker .agent-picker-icon {
  display: grid; place-items: center; height: 24px; width: 24px; border-radius: 999px;
  border: 1px dashed rgb(0 0 0 / .2); color: rgb(115 115 115);
}
.dark .agent-picker .agent-picker-icon { border-color: rgb(255 255 255 / .2); color: rgb(163 163 163); }
.agent-picker .label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-picker .label.muted { color: rgb(115 115 115); font-weight: 400; }
.dark .agent-picker .label.muted { color: rgb(163 163 163); }
@media (max-width: 639px) { .agent-picker .label, .agent-picker .chev { display: none; } .agent-picker { padding: 0 6px; } }

/* Chip do composer */
.chip .agent-avatar { height: 18px; width: 18px; font-size: 8.5px; }
.chip[data-agent-picker] .label { max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Menu de agentes (fixo, abre perto do gatilho) ---------- */
#agentMenu { width: 300px; max-height: min(440px, calc(var(--vh100) - 24px)); overflow-y: auto; }
#agentMenu.popover-up { transform-origin: bottom left; }
.agent-item { align-items: center; }
.agent-item .meta { min-width: 0; flex: 1; text-align: left; }
.agent-item .meta b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-item .meta small { display: block; font-size: 12px; color: rgb(115 115 115); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dark .agent-item .meta small { color: rgb(163 163 163); }
.agent-item .check { opacity: 0; transform: scale(.5); transition: opacity .2s, transform .3s var(--ease-out); }
.agent-item.selected .check { opacity: 1; transform: none; }
.agent-item .liloo-avatar {
  display: grid; place-items: center; height: 32px; width: 32px; flex-shrink: 0; border-radius: 999px;
  border: 1px solid rgb(0 0 0 / .1);
}
.dark .agent-item .liloo-avatar { border-color: rgb(255 255 255 / .1); }

/* Nome do agente acima da resposta */
.msg-agent { margin-bottom: 2px; font-size: 13px; font-weight: 600; }
.agent-hero { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 4px; }
.agent-hero p { max-width: 28rem; text-align: center; font-size: 14px; color: rgb(115 115 115); }
.dark .agent-hero p { color: rgb(163 163 163); }

/* ---------- Módulo (CRUD) ---------- */
.ag {
  --ag-line: var(--ds-line); --ag-muted: var(--ds-text-muted); --ag-hover: var(--ds-hover); /* tokens do DS */
  position: absolute; inset: 0; display: flex; flex-direction: column; font-size: 14px;
}
.ag-form { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.ag-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--ag-line); }
.ag-search {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px;
  background: rgb(0 0 0 / .04); color: var(--ag-muted);
}
.dark .ag-search { background: rgb(255 255 255 / .05); }
.ag-search input { flex: 1; min-width: 0; background: transparent; outline: none; color: rgb(38 38 38); }
.dark .ag-search input { color: rgb(245 245 245); }
.ag-search input::placeholder { color: var(--ag-muted); }

.ag-primary, .ag-secondary, .ag-danger, .ag-use {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: 999px; font-size: 13.5px; font-weight: 500; white-space: nowrap; transition: background-color .2s, opacity .2s;
}
.ag-primary { background: rgb(23 23 23); color: #fff; }
.ag-primary:hover { opacity: .88; }
.dark .ag-primary { background: #fff; color: rgb(23 23 23); }
.ag-secondary { border: 1px solid var(--ag-line); }
.ag-secondary:hover { background: var(--ag-hover); }
.ag-danger { color: rgb(220 38 38); }
.ag-danger:hover { background: rgb(220 38 38 / .08); }
.dark .ag-danger { color: rgb(248 113 113); }
@media (max-width: 479px) { .ag-head .ag-primary span { display: none; } .ag-head .ag-primary { padding: 0 11px; } }

.ag-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; }
.ag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.ag-card {
  display: flex; flex-direction: column; gap: 12px; padding: 14px; border: 1px solid var(--ag-line); border-radius: 18px;
  animation: fade-up .35s var(--ease-out) both; transition: border-color .2s, box-shadow .2s;
}
.ag-card:hover { border-color: rgb(0 0 0 / .14); box-shadow: 0 4px 18px -8px rgb(0 0 0 / .15); }
.dark .ag-card:hover { border-color: rgb(255 255 255 / .16); box-shadow: none; }
.ag-card.is-active { border-color: rgb(124 58 237 / .45); box-shadow: 0 0 0 3px rgb(124 58 237 / .1); }
.ag-desc { margin-top: 2px; font-size: 13px; color: var(--ag-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ag-badge { flex-shrink: 0; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: rgb(124 58 237 / .12); color: rgb(109 40 217); }
.dark .ag-badge { background: rgb(167 139 250 / .16); color: rgb(196 181 253); }
.ag-foot { display: flex; align-items: center; gap: 6px; }
.ag-model { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ag-muted); }
.ag-foot .btn-icon { height: 32px; width: 32px; }
.ag-use { height: 32px; padding: 0 12px; font-size: 12.5px; border: 1px solid var(--ag-line); margin-left: 4px; }
.ag-use:hover { background: var(--ag-hover); }

.ag-empty { display: flex; min-height: 100%; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 40px 16px; text-align: center; }
.ag-empty-icon {
  display: grid; place-items: center; height: 52px; width: 52px; margin-bottom: 6px; border-radius: 16px;
  background: linear-gradient(135deg, rgb(139 92 246 / .14), rgb(14 165 233 / .14)); color: rgb(109 40 217);
}
.dark .ag-empty-icon { color: rgb(196 181 253); }

/* Formulário */
.ag-form-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--ag-line); }
.ag-fields { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.ag-preview { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 18px; background: var(--ag-hover); }
.ag-field { display: flex; flex-direction: column; gap: 6px; }
.ag-field > span { font-size: 13px; font-weight: 500; }
.ag-field > span em { color: rgb(220 38 38); font-style: normal; }
.ag-field > span small { font-weight: 400; color: var(--ag-muted); }
.ag-field input[type="text"], .ag-field textarea {
  width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--ag-line); background: transparent;
  font-size: 14px; line-height: 1.5; outline: none; resize: vertical; transition: border-color .2s, box-shadow .2s;
}
.ag-field input[type="text"]:focus, .ag-field textarea:focus { border-color: rgb(124 58 237 / .55); box-shadow: 0 0 0 3px rgb(124 58 237 / .12); }
.ag-field input::placeholder, .ag-field textarea::placeholder { color: rgb(163 163 163); }
.ag-error { font-size: 12px; color: rgb(220 38 38); }
.ag-error:empty { display: none; }

.ag-swatch { position: relative; cursor: pointer; }
.ag-swatch input { position: absolute; opacity: 0; pointer-events: none; }
.ag-swatch span { display: block; height: 30px; width: 30px; border-radius: 999px; transition: transform .2s var(--ease-out), box-shadow .2s; }
.ag-swatch:hover span { transform: scale(1.08); }
.ag-swatch input:checked + span { box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgb(23 23 23); }
.dark .ag-swatch input:checked + span { box-shadow: 0 0 0 2px #1b1b1b, 0 0 0 4px #fff; }
.ag-swatch input:focus-visible + span { outline: 2px solid rgb(139 92 246 / .6); outline-offset: 4px; }

.ag-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.ag-option { position: relative; cursor: pointer; }
.ag-option input { position: absolute; opacity: 0; pointer-events: none; }
.ag-option > span {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--ag-line);
  transition: border-color .2s, background-color .2s;
}
.ag-option b { font-weight: 500; font-size: 13.5px; }
.ag-option small { font-size: 12px; color: var(--ag-muted); }
.ag-option:hover > span { background: var(--ag-hover); }
.ag-option input:checked + span { border-color: rgb(124 58 237 / .55); background: rgb(124 58 237 / .06); }
.ag-option input:focus-visible + span { outline: 2px solid rgb(139 92 246 / .6); outline-offset: 2px; }

.ag-form-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--ag-line); }
