/* ═══════════════════════════════════════════════════════════
   Cards do dashboard — revisões agrupadas
═══════════════════════════════════════════════════════════ */

/* Botões de ação compactos: só ícone para não estourar a largura do card */
.model-card-btn.model-card-btn-icon {
  width: 34px;
  min-width: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Chip "N revisões" abaixo do nome */
.model-card-revisions-toggle {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(100, 101, 240, 0.28);
  background: rgba(100, 101, 240, 0.08);
  color: #6465F0;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s;
}
.model-card-revisions-toggle:hover { background: rgba(100, 101, 240, 0.16); }
.model-card-revisions-toggle.expanded { background: rgba(100, 101, 240, 0.18); }
.model-card-revisions-toggle.expanded svg { transform: rotate(90deg); }

/* Lista de revisões expandida */
.model-card-revisions {
  margin-top: 10px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.02);
  overflow: hidden;
}
.model-card-revision-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 0.8rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}
.model-card-revision-row:last-child { border-bottom: none; }
.model-card-revision-tag {
  font-weight: 600;
  color: #6b7280;
  min-width: 54px;
  font-size: 0.72rem;
}
.model-card-revision-tag.head { color: #16a34a; }
.model-card-revision-date {
  flex: 1;
  color: #9ca3af;
  font-size: 0.72rem;
}
.model-card-revision-open {
  background: transparent;
  border: 1px solid rgba(100, 101, 240, 0.4);
  color: #6465F0;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  cursor: pointer;
  transition: background 0.15s;
}
.model-card-revision-open:hover {
  background: rgba(100, 101, 240, 0.12);
}

/* Painel "Alterações" e seletor de revisão — injetados no viewer */

.rev-panel {
  position: absolute;
  top: 74px;
  right: 16px;
  width: 320px;
  max-height: calc(100vh - 120px);
  background: rgba(15, 18, 32, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  color: #e6e8f0;
  font-family: inherit;
  font-size: 0.9rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rev-panel.hidden { display: none; }

.rev-panel-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.rev-panel-header.dragging { cursor: grabbing; }
.rev-panel.dragged { top: auto; right: auto; } /* neutraliza anchors originais quando o usuário move o painel */
.rev-panel-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.rev-panel-title > span:first-child {
  /* Alça visual sutil antes do título — sinaliza que o header é draggable */
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.rev-panel-title > span:first-child::before {
  content: '⋮⋮';
  display: inline-block;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.35);
  letter-spacing: -2px;
  line-height: 1;
  flex-shrink: 0;
}
.rev-panel-close { cursor: pointer; }
.rev-panel-close {
  background: transparent;
  border: none;
  color: #8b90a8;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}
.rev-panel-close:hover { background: rgba(255, 255, 255, 0.06); color: #e6e8f0; }

.rev-selector {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 0.8rem;
  color: #aab0c6;
}
/* Segundo seletor (Escopo) abaixo de "Comparar com" */
.rev-selector + .rev-selector { margin-top: 6px; }
/* Rótulos alinhados pra os dois selects ficarem na mesma coluna */
.rev-selector > span:first-child { min-width: 82px; }
.rev-selector select {
  flex: 1 1 auto;
  min-width: 0;            /* permite encolher dentro do flex (sem vazar à direita) */
  max-width: 100%;
  box-sizing: border-box;
  background: #0d1020;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e6e8f0;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  text-overflow: ellipsis;
}

/* Resumo em linguagem de obra (total + onde mais mudou + impacto) */
.rev-summary {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 14px 10px;
  padding: 7px 10px;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #c7d2fe;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 8px;
}
.rev-summary-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.rev-summary-impact {
  font-size: 0.72rem;
  color: #aab4e8;
  font-variant-numeric: tabular-nums;
}
.rev-scope-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  margin-top: 4px;
  border-radius: 50%;
  background: #818cf8;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
}

.rev-totals {
  display: grid;
  grid-template-columns: repeat(4, 1fr);   /* 4 cards em linha — cabe em painel de 320px+ */
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.rev-total {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 8px 4px;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.rev-total:hover { background: rgba(255, 255, 255, 0.06); }
.rev-total.active { box-shadow: inset 0 0 0 2px currentColor; }
/* Buckets vazios ficam discretos (sem desaparecer — UX consistente) */
.rev-total.zero { opacity: 0.35; }
.rev-total.zero:hover { opacity: 0.6; }
.rev-total-count {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 3px;
}
.rev-total-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #8b90a8;
}
.rev-total[data-kind="added"]   { color: #22c55e; }
.rev-total[data-kind="changed"] { color: #eab308; }
.rev-total[data-kind="removed"] { color: #ef4444; }
.rev-total[data-kind="moved"]   { color: #f97316; }

.rev-categories {
  overflow-y: auto;
  padding: 8px 0;
  flex: 1 1 auto;
  min-height: 0;
}

.rev-category-group { border-bottom: 1px solid rgba(255, 255, 255, 0.03); }
.rev-category-group:last-child { border-bottom: none; }

.rev-category-row {
  display: flex;
  align-items: center;
  padding: 6px 16px 6px 6px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.1s;
  gap: 4px;
}
.rev-category-row:hover { background: rgba(255, 255, 255, 0.04); }
.rev-category-row.active {
  background: rgba(100, 101, 240, 0.15);
  box-shadow: inset 3px 0 0 #6465F0;
}

.rev-category-chevron {
  background: transparent;
  border: none;
  color: #8b90a8;
  font-size: 0.78rem;
  line-height: 1;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 6px;
  flex-shrink: 0;
  padding: 0;
  font-family: inherit;
  transition: background 0.1s, color 0.1s;
}
.rev-category-chevron:hover { background: rgba(255, 255, 255, 0.08); color: #e6e8f0; }
.rev-category-group.expanded > .rev-category-row { background: rgba(255, 255, 255, 0.03); }
.rev-category-group.expanded > .rev-category-row .rev-category-chevron { color: #e6e8f0; }

.rev-category-children {
  background: rgba(0, 0, 0, 0.18);
  max-height: 260px;
  overflow-y: auto;
  padding: 4px 0;
}
.rev-category-children[hidden] { display: none; }

.rev-element-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 16px 6px 34px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.1s;
  color: #cfd2e0;
}
.rev-element-row:hover { background: rgba(255, 255, 255, 0.06); }
.rev-element-row.active {
  background: rgba(100, 101, 240, 0.18);
  box-shadow: inset 3px 0 0 #6465F0;
}
.rev-element-badge {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.72rem;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.rev-element-badge.added   { background: rgba(34, 197, 94, 0.18);  color: #22c55e; }
.rev-element-badge.changed { background: rgba(234, 179, 8, 0.18);  color: #eab308; }
.rev-element-badge.removed { background: rgba(239, 68, 68, 0.18);  color: #ef4444; }
.rev-element-badge.moved   { background: rgba(249, 115, 22, 0.18); color: #f97316; }
.rev-element-text {
  flex: 1;
  min-width: 0;
}
.rev-element-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #e6e8f0;
}
.rev-element-summary {
  font-size: 0.7rem;
  color: #8b90a8;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rev-element-empty {
  padding: 10px 16px 10px 34px;
  font-size: 0.75rem;
  color: #8b90a8;
  font-style: italic;
}

.rev-category-name {
  flex: 1;
  color: #cfd2e0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 8px;
}
.rev-category-counts {
  display: flex;
  gap: 6px;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}
.rev-category-counts span {
  padding: 1px 6px;
  border-radius: 6px;
  min-width: 22px;
  text-align: center;
}
.rev-category-counts .add    { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.rev-category-counts .chng   { background: rgba(234, 179, 8, 0.15); color: #eab308; }
.rev-category-counts .remove { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.rev-category-counts .move   { background: rgba(249, 115, 22, 0.15); color: #f97316; }
.rev-category-counts .zero   { opacity: 0.3; }

.rev-panel-empty {
  padding: 24px 16px;
  text-align: center;
  color: #8b90a8;
  font-size: 0.85rem;
}

.rev-legend {
  padding: 10px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  gap: 14px;
  font-size: 0.72rem;
  color: #8b90a8;
  justify-content: space-around;
}
.rev-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
  vertical-align: middle;
}
.rev-legend-dot.added   { background: #22c55e; }
.rev-legend-dot.changed { background: #eab308; }
.rev-legend-dot.removed { background: #ef4444; }
.rev-legend-dot.moved   { background: #f97316; }

.rev-panel-footer {
  padding: 10px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.75rem;
  color: #8b90a8;
  line-height: 1.4;
}

.rev-panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.rev-export-label {
  font-size: 0.7rem;
  color: #8b90a8;
  margin-right: 2px;
}
.rev-export-btn {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #cbd5e1;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, opacity 0.12s;
}
.rev-export-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.28);
  color: #ffffff;
}
.rev-export-btn:active:not(:disabled) {
  background: rgba(255, 255, 255, 0.10);
}
.rev-export-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.rev-export-icon {
  font-size: 0.85rem;
  line-height: 1;
  margin-right: 3px;
}

/* ── Overlay 2D: bbox antiga + tag com leader line ────────────────────────── */
/* Cor controlada via --rev-color: muda conforme o bucket (changed/moved). */
.rev-overlay-root {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  --rev-color: #eab308; /* default: amarelo (changed) */
}
.rev-overlay-root.kind-changed { --rev-color: #eab308; }
.rev-overlay-root.kind-moved   { --rev-color: #f97316; }
.rev-overlay-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.rev-overlay-wireframe {
  fill: none;
  stroke: var(--rev-color);
  stroke-width: 1.5;
  stroke-dasharray: 6 4;
  opacity: 0.85;
}
.rev-overlay-leader {
  stroke: var(--rev-color);
  stroke-width: 1.25;
  stroke-dasharray: 3 3;
  opacity: 0.7;
}
.rev-overlay-tag {
  position: fixed;
  background: rgba(20, 22, 30, 0.95);
  border: 1px solid var(--rev-color);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.78rem;
  color: #e6e8f0;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  max-width: 260px;
  pointer-events: none;
}
.rev-overlay-tag-name {
  font-weight: 600;
  color: var(--rev-color);
  margin-bottom: 2px;
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}
.rev-overlay-tag-cat {
  font-size: 0.65rem;
  color: #8b90a8;
  margin-bottom: 6px;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
}
.rev-overlay-tag-line {
  font-size: 0.78rem;
  margin: 2px 0;
  white-space: nowrap;
}
.rev-overlay-tag-key {
  color: #94a3b8;
  font-weight: 500;
}
.rev-overlay-tag-val {
  color: #fef3c7;
  font-weight: 600;
}
.rev-overlay-tag-detail {
  color: #6b7280;
  font-size: 0.7rem;
}
.rev-overlay-tag-note {
  font-size: 0.68rem;
  color: #f97316;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
