* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family:
    system-ui,
    -apple-system,
    sans-serif;
  color: #1b1f24;
  background: #f7f7f8;
}

#page {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#app {
  display: flex;
  flex: 1 1 auto;
  min-height: 0; /* permite sidebar/graph-area encolherem pra o footer da legenda caber embaixo */
}

#sidebar {
  width: 340px;
  flex: 0 0 340px;
  overflow-y: auto;
  border-right: 1px solid #ddd;
  padding: 12px;
  background: #fff;
}

#graph-area {
  flex: 1;
  position: relative;
}

#cy {
  position: absolute;
  inset: 0;
}

#status {
  font-size: 12px;
  color: #666;
  margin-bottom: 8px;
}

#status.error {
  color: #c0392b;
  font-weight: 600;
}

#refresh-catalog-btn {
  margin-bottom: 6px;
  font-size: 11px;
  padding: 5px 10px;
  cursor: pointer;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
}

#refresh-catalog-btn:hover {
  background: #f0f4fa;
}

#refresh-catalog-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

h1 {
  font-size: 16px;
  margin: 0 0 8px;
}

h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #666;
  margin: 18px 0 6px;
}

/* Legenda — movida pro footer (fora da sidebar) pra liberar espaço vertical, ver `main.js`. */

#legend-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px 18px;
  flex-wrap: wrap;
  padding: 8px 14px;
  border-top: 1px solid #ddd;
  background: #fff;
}

#legend-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #666;
  flex: 0 0 auto;
}

#legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
}

#legend .legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  white-space: nowrap;
}

#legend .swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex: 0 0 12px;
}

.note {
  font-size: 11px;
  color: #666;
  margin-top: 6px;
  line-height: 1.4;
}

.swatch.service-ok {
  background: #4a6fa5;
}

.swatch.service-unavailable {
  background: #c0392b;
}

.swatch.service-skipped {
  background: #ccc;
  border: 1px dashed #888;
}

.swatch.event-clean {
  background: #ddd;
}

.swatch.event-rf05 {
  background: #fff;
  border: 2px solid #e67e22;
}

.swatch.event-rf06 {
  background: #fff;
  border: 2px dotted #999;
}

.swatch.edge-compatible {
  background: #2ecc71;
}

.swatch.edge-incompatible {
  background: #e74c3c;
}

.swatch.edge-not-comparable {
  background: #999;
}

/* Seletor de eventos (RF10) */

#event-picker input {
  width: 100%;
  padding: 6px;
  font-size: 13px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

#event-picker ul {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 4px;
}

#event-picker li {
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}

#event-picker li:hover {
  background: #f0f4fa;
}

#event-picker li.event-list-more {
  color: #999;
  cursor: default;
  font-style: italic;
}

/* Painel de detalhe */

#detail-panel {
  font-size: 12px;
}

#detail-panel h3 {
  font-size: 13px;
  margin: 0 0 6px;
  word-break: break-all;
}

#detail-panel p {
  margin: 4px 0;
}

#detail-panel .flag {
  padding: 4px 6px;
  border-radius: 4px;
  margin: 4px 0;
}

#detail-panel .flag-rf05 {
  background: #fdecea;
  color: #c0392b;
}

#detail-panel .flag-rf06 {
  background: #f2f2f2;
  color: #777;
}

#detail-panel ul {
  margin: 4px 0;
  padding-left: 16px;
}

#detail-panel .unsafe-fields {
  margin: 2px 0 4px;
  padding-left: 14px;
  color: #c0392b;
  font-size: 11px;
}

#detail-panel .unsafe-fields code {
  background: #fdecea;
  padding: 1px 3px;
  border-radius: 3px;
}

#detail-panel .schema-details {
  margin: 4px 0;
  border: 1px solid #eee;
  border-radius: 4px;
  padding: 2px 6px;
}

#detail-panel .schema-details summary {
  cursor: pointer;
  font-size: 11px;
  padding: 3px 0;
}

#detail-panel .trace-step-list {
  list-style: none;
  margin: 6px 0;
  padding: 0;
}

#detail-panel .trace-step-list li {
  padding: 6px 8px;
  margin-bottom: 4px;
  border: 1px solid #eee;
  border-radius: 4px;
}

#detail-panel .trace-step-list li.trace-step-dlq {
  border-color: #f5c6c0;
  background: #fdecea;
}

#detail-panel .trace-step-meta {
  display: flex;
  justify-content: space-between;
  color: #999;
  font-size: 10px;
  margin-bottom: 2px;
}

#detail-panel .trace-step-name {
  font-weight: 600;
  font-size: 12px;
  word-break: break-all;
}

#detail-panel .trace-step-dlq .trace-step-name {
  color: #c0392b;
}

#detail-panel .schema-details pre {
  font-size: 10px;
  max-height: 220px;
  overflow: auto;
  background: #f7f7f8;
  padding: 6px;
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-word;
}

#detail-panel .service-event-list {
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 4px;
  margin-bottom: 8px;
}

#detail-panel .service-event-list li {
  padding: 3px 6px;
  font-size: 11px;
  cursor: pointer;
  border-bottom: 1px solid #f5f5f5;
}

#detail-panel .service-event-list li:hover {
  background: #f0f4fa;
}

#clear-selection {
  margin-top: 10px;
  font-size: 12px;
  padding: 5px 10px;
  cursor: pointer;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
}

#clear-selection:hover {
  background: #f0f4fa;
}

/* Feed ao vivo (RF12) */

h2 .live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ccc;
  margin-left: 4px;
  vertical-align: middle;
}

h2 .live-dot.connected {
  background: #2ecc71;
}

h2 .live-dot.disconnected {
  background: #c0392b;
}

#live-feed {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 4px;
}

.trace-group {
  padding: 5px 8px;
  font-size: 11px;
  cursor: pointer;
  border-bottom: 1px solid #f5f5f5;
}

.trace-group:hover {
  background: #f0f4fa;
}

.trace-group.active {
  background: #eaf1fb;
  border-left: 3px solid #2d7dd2;
}

.trace-group-meta {
  display: flex;
  justify-content: space-between;
  color: #999;
  font-size: 10px;
}

.trace-group-route {
  word-break: break-all;
}

.trace-group-correlation {
  font-size: 10px;
  color: #999;
  word-break: break-all;
}

.trace-group-correlation code {
  background: none;
  padding: 0;
}

.trace-group.has-dlq {
  border-left: 3px solid #c0392b;
}

.trace-group-dlq {
  margin-top: 3px;
  font-size: 10px;
  font-weight: 600;
  color: #c0392b;
}

#publish-event-btn {
  margin: 6px 0 10px;
  font-size: 12px;
  padding: 5px 10px;
  cursor: pointer;
  border: 1px solid #2d7dd2;
  border-radius: 4px;
  background: #eaf1fb;
  color: #2d7dd2;
}

#publish-event-btn:hover {
  background: #dcebfa;
}

#publish-event-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  border-color: #ccc;
  color: #999;
  background: #f2f2f2;
}

/* Publicador manual (RF13) */

.publish-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.publish-modal {
  width: 520px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 6px;
  padding: 16px 18px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.publish-modal h3 {
  margin: 0 0 8px;
  font-size: 14px;
  word-break: break-all;
}

.publish-modal label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #666;
  margin: 10px 0 4px;
}

.publish-modal select {
  width: 100%;
  padding: 5px;
  font-size: 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.publish-modal textarea {
  width: 100%;
  margin-top: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  resize: vertical;
}

.publish-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.publish-modal-actions button {
  font-size: 12px;
  padding: 6px 12px;
  cursor: pointer;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
}

.publish-modal-actions #publish-submit {
  background: #2d7dd2;
  border-color: #2d7dd2;
  color: #fff;
}

.publish-modal-actions #publish-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#publish-feedback {
  margin-top: 8px;
  font-size: 12px;
}

#publish-feedback code {
  background: #f2f2f2;
  padding: 1px 4px;
  border-radius: 3px;
}
