/* Componentes reutilizáveis: badges, cards, botões, empty states, chips, timeline, toasts. */

/* ---- Cards de seção ---- */
.cm-card {
  background: var(--cm-surface);
  border: 1px solid var(--cm-border);
  border-radius: var(--cm-radius-lg);
  box-shadow: var(--cm-shadow-sm);
  padding: var(--cm-space-4) var(--cm-space-5);
}
.cm-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--cm-space-3); margin-bottom: var(--cm-space-3); }
.cm-card-title { font-size: 16px; font-weight: 600; margin: 0; }
.cm-card-subtitle { font-size: 13px; color: var(--cm-text-muted); margin-top: 2px; }

/* Faixa de resumo compacta */
.cm-summary-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--cm-space-3); margin-bottom: var(--cm-space-4); }
.cm-summary-item {
  background: var(--cm-surface);
  border: 1px solid var(--cm-border);
  border-radius: var(--cm-radius);
  padding: var(--cm-space-3) var(--cm-space-4);
}
.cm-summary-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--cm-text-muted); font-weight: 600; }
.cm-summary-value { font-size: 15px; font-weight: 600; color: var(--cm-text); margin-top: 2px; }
.cm-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.cm-dot-on { background: var(--cm-success); }
.cm-dot-off { background: var(--cm-neutral); }

/* Grid de dados chave/valor */
.cm-field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--cm-space-4) var(--cm-space-5); }
.cm-field-label { font-size: 12px; color: var(--cm-text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.cm-field-value { font-size: 14.5px; color: var(--cm-text); margin-top: 2px; }

/* ---- Badges de status ---- */
.cm-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}
.status-interesse { background: var(--cm-info-light); color: var(--cm-info); }
.status-participando { background: var(--cm-primary-light); color: var(--cm-primary); }
.status-disputa { background: var(--cm-violet-light); color: var(--cm-violet); }
.status-julgamento { background: var(--cm-warning-light); color: var(--cm-warning); }
.status-recurso { background: var(--cm-warning-light); color: var(--cm-warning); }
.status-encerrado { background: var(--cm-neutral-light); color: var(--cm-neutral); }
.status-success { background: var(--cm-success-light); color: var(--cm-success); }
.status-danger { background: var(--cm-danger-light); color: var(--cm-danger); }

/* ---- Alerta crítico (menção à empresa) ---- */
.cm-ativar-alertas-btn {
  position: fixed;
  bottom: var(--cm-space-4);
  right: var(--cm-space-4);
  z-index: 1040;
  background: var(--cm-warning);
  color: #1a1a1a;
  border: none;
  border-radius: var(--cm-radius);
  padding: 10px 16px;
  font-weight: 600;
  box-shadow: var(--cm-shadow-md, 0 4px 12px rgba(0,0,0,.2));
  cursor: pointer;
}

.cm-alerta-overlay {
  position: fixed;
  inset: 0;
  z-index: 1080;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  padding: var(--cm-space-4);
}

.cm-alerta-box {
  background: var(--cm-danger, #c0392b);
  color: #fff;
  border-radius: var(--cm-radius-lg);
  padding: var(--cm-space-5);
  max-width: 520px;
  width: 100%;
  text-align: center;
  animation: cm-alerta-pulse 1.5s ease-in-out infinite;
}

.cm-alerta-icon { font-size: 40px; line-height: 1; margin-bottom: var(--cm-space-2); }

/* Pulsação lenta (1.5s) e de baixo contraste de opacidade — nunca strobe, para não
   representar risco a pessoas fotossensíveis. */
@keyframes cm-alerta-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192, 57, 41, 0.7); }
  50% { box-shadow: 0 0 0 18px rgba(192, 57, 41, 0); }
}

/* ---- Badges de portal (arquitetura multiportal) ---- */
.cm-portal {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--cm-radius-sm);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}
.portal-comprasgov { background: var(--cm-primary-light); color: var(--cm-primary); }
.portal-pncp { background: var(--cm-violet-light); color: var(--cm-violet); }
.portal-desconhecido { background: var(--cm-neutral-light); color: var(--cm-neutral); }
a.cm-portal { text-decoration: none; gap: 4px; }
a.cm-portal:hover { filter: brightness(0.92); }
.cm-portal-disabled { opacity: .5; }

/* ---- Botões ---- */
.btn-ghost { background: transparent; border: 1px solid transparent; color: var(--cm-text-secondary); }
.btn-ghost:hover { background: var(--cm-surface-secondary); color: var(--cm-text); }
.btn-danger-soft { background: var(--cm-danger-light); border: 1px solid transparent; color: var(--cm-danger); }
.btn-danger-soft:hover { background: var(--cm-danger); color: #fff; }
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--cm-radius-sm); }

/* ---- Tabelas ---- */
.cm-table thead th {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--cm-text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--cm-border);
  white-space: nowrap;
}
.cm-table tbody td { font-size: 14px; vertical-align: middle; }
.cm-table tbody tr { transition: background var(--cm-transition); }
.cm-table tbody tr:hover { background: var(--cm-surface-secondary); }
.cm-table .cm-row-link { color: inherit; text-decoration: none; cursor: pointer; }
.cm-id-strong { font-weight: 600; color: var(--cm-text); }
.cm-id-muted { font-size: 12px; color: var(--cm-text-muted); font-family: ui-monospace, monospace; }

/* ---- Chips ---- */
.cm-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--cm-surface-secondary);
  border-radius: 999px;
  padding: 3px 6px 3px 3px;
  font-size: 13px;
  margin: 0 6px 6px 0;
}
.cm-chip-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--cm-primary); color: #fff;
  font-size: 10.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.cm-chip button { border: none; background: transparent; color: var(--cm-text-muted); line-height: 1; padding: 0 2px; }
.cm-chip button:hover { color: var(--cm-danger); }

/* ---- Empty states ---- */
.cm-empty { text-align: center; padding: var(--cm-space-6) var(--cm-space-4); color: var(--cm-text-muted); }
.cm-empty i { font-size: 30px; color: var(--cm-text-muted); opacity: .5; margin-bottom: var(--cm-space-2); display: block; }
.cm-empty-title { font-size: 14px; font-weight: 600; color: var(--cm-text-secondary); }
.cm-empty-desc { font-size: 13px; margin-top: 2px; }

/* ---- Timeline (histórico de sincronizações) ---- */
.cm-timeline { position: relative; padding-left: 20px; }
.cm-timeline::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 1px; background: var(--cm-border); }
.cm-timeline-item { position: relative; padding-bottom: var(--cm-space-4); }
.cm-timeline-item:last-child { padding-bottom: 0; }
.cm-timeline-item::before {
  content: ""; position: absolute; left: -20px; top: 4px;
  width: 9px; height: 9px; border-radius: 50%; background: var(--cm-primary); border: 2px solid var(--cm-surface);
}
.cm-timeline-item.is-error::before { background: var(--cm-danger); }
.cm-timeline-date { font-size: 12.5px; color: var(--cm-text-muted); }
.cm-timeline-text { font-size: 13.5px; color: var(--cm-text); margin-top: 2px; }

/* ---- Toasts ---- */
.cm-toast-container { z-index: 1080; }

/* ==================================================================
   Accordion de Itens/Propostas — <details>/<summary> nativos, sem JS.
   Adaptado do bloco .cm-* original pras variáveis do design system.
   ================================================================== */
.cm-certame { --cm-accordion-accent: var(--cm-primary); }
.cm-item { border: 1px solid var(--cm-border); border-radius: var(--cm-radius); margin-bottom: var(--cm-space-3); background: var(--cm-surface); }
.cm-item > summary, .cm-fornecedor > summary {
  cursor: pointer; display: flex; align-items: center; gap: var(--cm-space-4);
  padding: var(--cm-space-3) var(--cm-space-4); list-style: none; color: var(--cm-text);
}
.cm-item > summary::-webkit-details-marker, .cm-fornecedor > summary::-webkit-details-marker { display: none; }
.cm-item > summary::after, .cm-fornecedor > summary::after {
  content: "\F282"; font-family: "bootstrap-icons"; font-size: 14px; color: var(--cm-accordion-accent); margin-left: auto;
}
.cm-item[open] > summary::after, .cm-fornecedor[open] > summary::after { content: "\F286"; }
.cm-item > summary:focus-visible, .cm-fornecedor > summary:focus-visible { outline: 2px solid var(--cm-primary); outline-offset: 2px; }
.cm-item-heading { background: var(--cm-surface-secondary); border-radius: var(--cm-radius) var(--cm-radius) 0 0; }
.cm-item[open] > .cm-item-heading { border-radius: var(--cm-radius) var(--cm-radius) 0 0; }
.cm-item-heading > span:first-child { flex: 1; font-weight: 600; }
/* Seções recolhíveis da tela de detalhes (mensagens, quadro informativo, participantes...):
   mesmo comportamento visual dos grupos/itens — começam fechadas, seta à direita. */
.cm-secao > summary { cursor: pointer; list-style: none; align-items: center; }
.cm-secao > summary::-webkit-details-marker { display: none; }
.cm-secao > summary::after {
  content: "\F282"; font-family: "bootstrap-icons"; font-size: 16px; color: var(--cm-primary); margin-left: auto;
}
.cm-secao[open] > summary::after { content: "\F286"; }
.cm-secao:not([open]) > summary { margin-bottom: 0; }
.cm-secao > summary:focus-visible { outline: 2px solid var(--cm-primary); outline-offset: 2px; }
.cm-summary-value { text-align: right; white-space: nowrap; font-size: 13px; color: var(--cm-text-secondary); }
.cm-item-body { padding: var(--cm-space-4); border-top: 1px solid var(--cm-border); }
.cm-fornecedor { border: 1px solid var(--cm-border); border-radius: var(--cm-radius-sm); margin-bottom: 6px; margin-left: var(--cm-space-4); }
.cm-supplier-name { flex: 1; min-width: 180px; }
.cm-fornecedor summary small { display: block; color: var(--cm-text-muted); font-size: 12px; margin-top: 4px; }
.cm-fornecedor[open] > summary { background: var(--cm-primary-light); }
.cm-proposal-body { padding: var(--cm-space-4); border-top: 1px solid var(--cm-border); }

@media (max-width: 700px) {
  .cm-item > summary, .cm-fornecedor > summary { flex-wrap: wrap; gap: var(--cm-space-2); padding: var(--cm-space-3); }
  .cm-supplier-name { flex-basis: 100%; }
  .cm-summary-value { text-align: left; white-space: normal; }
  .cm-item-body, .cm-proposal-body { padding: var(--cm-space-3); }
  .cm-fornecedor { margin-left: 0; }
}
