/* ─── MÓDULO AGENTES — style.css ─── */
/* Importa shared.css via index.html */

body { font-family: 'IBM Plex Sans', sans-serif; }

/* ─── HEADER DO MÓDULO ─── */
.mod-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 32px 20px;
  border-bottom: 1px solid var(--border);
}

.mod-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mod-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mod-icon--purple {
  background: var(--accent-purple);
  color: #a78bfa;
}

.mod-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 2px;
}

.mod-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

.mod-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ─── SEÇÕES ─── */
.mod-section {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border);
}

.mod-section:last-child {
  border-bottom: none;
}

/* .section-label agora em shared.css */
.section-label { margin-bottom: 14px; }

.section-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-label-row .section-label {
  margin-bottom: 0;
}

/* .btn-sm agora em shared.css */

/* ─── GRID DE AGENTES ─── */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: border-color .2s, transform .15s;
  position: relative;
  overflow: hidden;
}

.agent-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.agent-card.is-selected {
  border-color: #7F77DD;
  border-width: 1.5px;
}

.agent-card-glow {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
  opacity: .7;
}

.agent-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  font-size: 16px;
}

.agent-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.agent-papel {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.4;
}

.agent-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.agent-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 500;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot--idle   { background: var(--text-muted); }
.status-dot--busy   { background: var(--accent-green); animation: pulse 1.5s infinite; }
.status-dot--waiting{ background: var(--accent-amber); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

.status-text--idle    { color: var(--text-muted); }
.status-text--busy    { color: var(--accent-green); }
.status-text--waiting { color: var(--accent-amber); }

.agent-task-count {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.agent-card-menu {
  position: absolute;
  top: 12px; right: 12px;
  opacity: 0;
  transition: opacity .15s;
}

.agent-card:hover .agent-card-menu {
  opacity: 1;
}

/* ─── FEED DE ATIVIDADE ─── */
.feed-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 100px;
  overflow: hidden;
}

.feed-empty {
  padding: 28px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.feed-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
}

.feed-item:last-child {
  border-bottom: none;
}

.feed-item:hover {
  background: var(--bg-card-hover);
}

.feed-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
  color: #fff;
}

.feed-body {
  flex: 1;
  min-width: 0;
}

.feed-agent {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.feed-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.feed-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.feed-badge {
  font-size: 0.68rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 20px;
  flex-shrink: 0;
  align-self: center;
}

.badge--concluido { background: var(--accent-green); color: #052e16; }
.badge--rodando   { background: var(--accent-purple); color: #2e1065; }
.badge--aguardando{ background: var(--accent-amber); color: #431407; }
.badge--erro      { background: var(--accent-red); color: #450a0a; }

/* ─── DELEGAÇÃO ─── */
.delegate-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.delegate-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}

.delegate-top-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.delegate-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.delegate-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  gap: 12px;
  flex-wrap: wrap;
}

.pills-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill {
  font-size: 0.72rem;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .15s;
  user-select: none;
  background: transparent;
}

.pill:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.pill.is-active {
  background: var(--accent-purple);
  color: #c4b5fd;
  border-color: transparent;
}

/* ─── MODAIS ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
  animation: overlay-in .18s ease;
}

@keyframes overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-md);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  animation: modal-in .22s cubic-bezier(.32,1.1,.72,1);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-box--lg {
  max-width: 640px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.modal-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.modal-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 3px 0 0;
  max-width: 340px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-body {
  padding: 20px 22px;
  flex: 1;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* ─── COLOR PICKER ─── */
.color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-opt {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color .15s, transform .1s;
}

.color-opt:hover {
  transform: scale(1.1);
}

.color-opt.selected {
  border-color: var(--text-primary);
}

/* ─── RESULTADO ─── */
.resultado-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 120px;
  padding: 16px;
}

.resultado-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.loading-dots {
  display: flex;
  gap: 6px;
}

.loading-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: blink 1.2s infinite;
}

.loading-dots span:nth-child(2) { animation-delay: .2s; }
.loading-dots span:nth-child(3) { animation-delay: .4s; }

@keyframes blink {
  0%, 100% { opacity: .2; }
  50%       { opacity: 1; }
}

.resultado-content {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.7;
  white-space: pre-wrap;
}

/* ─── AVATAR PEQUENO ─── */
.agent-avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  flex-shrink: 0;
}

/* ─── MICROFONE / VOZ ─── */
.textarea-wrap {
  position: relative;
}

.textarea-wrap .sh-textarea {
  padding-right: 44px;
}

.btn-mic {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  flex-shrink: 0;
}

.btn-mic:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-mic.is-recording {
  background: rgba(220, 38, 38, 0.15);
  border-color: #dc2626;
  color: #f87171;
  animation: mic-pulse 1.2s infinite;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.4); }
  50%       { box-shadow: 0 0 0 6px rgba(220,38,38,0); }
}

/* ─── RESPONSIVO ─── */
@media (max-width: 640px) {

  /* ── Header ── */
  .mod-header {
    padding: 16px 16px 14px;
    gap: 10px;
  }
  .mod-icon-wrap {
    width: 36px;
    height: 36px;
  }
  .mod-title { font-size: 1.05rem; }
  .mod-subtitle { display: none; }
  .mod-header-actions .btn-ghost {
    padding: 8px 14px;
    font-size: 13px;
  }

  /* ── Seções ── */
  .mod-section {
    padding: 16px 14px;
  }

  /* ── Grid de agentes ── */
  .agents-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .agent-card {
    padding: 14px 12px;
  }
  .agent-icon {
    width: 30px;
    height: 30px;
    margin-bottom: 8px;
  }
  .agent-name { font-size: 0.82rem; }
  .agent-papel { font-size: 0.7rem; margin-bottom: 8px; }
  .agent-card-menu { opacity: 1; }

  /* ── Delegação ── */
  .delegate-card {
    padding: 14px;
    border-radius: var(--radius);
  }
  .delegate-top {
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
  }
  .delegate-top > div:nth-child(2) {
    /* "Don Vito vai delegar..." — esconde em telas pequenas */
    display: none;
  }

  /* Textarea maior no mobile para conforto de digitação/ditado */
  .textarea-wrap .sh-textarea {
    min-height: 100px;
    font-size: 15px;      /* evita zoom no iOS */
    padding-right: 50px;
    padding-bottom: 44px; /* espaço para o mic abaixo */
  }

  /* Mic mais fácil de tocar */
  .btn-mic {
    width: 38px;
    height: 38px;
    bottom: 8px;
    right: 8px;
  }

  /* Pills: scroll horizontal (sem quebra de linha) */
  .delegate-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-top: 10px;
  }
  .pills-row {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .pills-row::-webkit-scrollbar { display: none; }
  .pill { flex-shrink: 0; }

  /* Botão Delegar: largura total, maior touch target */
  #btnDelegar {
    width: 100%;
    justify-content: center;
    padding: 13px 20px;
    font-size: 15px;
  }

  /* ── Feed de atividade ── */
  .feed-item { padding: 10px 12px; gap: 10px; }
  .feed-desc { max-width: calc(100vw - 120px); }

  /* ── Modal — bottom sheet no mobile ── */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal-box {
    max-width: 100%;
    width: 100%;
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: 92vh;
  }
  .modal-box--lg {
    max-width: 100%;
    max-height: 95vh;
  }
  .modal-header { padding: 16px 18px 14px; }
  .modal-body   { padding: 16px 18px; }
  .modal-footer {
    padding: 12px 18px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    flex-wrap: wrap;
    gap: 8px;
  }
  .modal-footer .btn-ghost,
  .modal-footer .btn-primary {
    flex: 1;
    justify-content: center;
  }
  /* Slide-up no mobile em vez do scale de desktop */
  .modal-box {
    animation: modal-slide-up .28s cubic-bezier(.22,1,.36,1);
  }
  @keyframes modal-slide-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }

  /* Handle (indicador de bottom sheet) */
  .modal-box::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    border-radius: 99px;
    background: var(--border-md);
    margin: 10px auto 0;
    flex-shrink: 0;
  }

  /* ── Toast: centralizado na base ── */
  .toast {
    left: 50%;
    right: auto;
    transform: translateX(-50%) translateY(8px);
    bottom: max(16px, env(safe-area-inset-bottom));
    white-space: nowrap;
  }
  .toast.show { transform: translateX(-50%) translateY(0); }
}

/* ─── AÇÕES EXECUTADAS (Tool Use badges) ─── */
.resultado-acoes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.acoes-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 99px;
  white-space: nowrap;
}
.acoes-badge--ok {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(34,197,94,.2);
}
.acoes-badge--err {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(248,113,113,.2);
}

/* ─── PAINEL DE RELATÓRIO ─────────────────────────────────────────── */
/* O painel usa estilos inline no HTML (position:fixed, z-index alto).
   Este bloco cobre apenas a animação de entrada. */
#painelRelatorio {
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
