/* ── Rede 3D — Canvas & Overlay Styles ── */

.rede-container {
  position: relative;
  width: 100%;
  height: calc(100vh - 40px);
  min-height: 400px;
  overflow: hidden;
  background: var(--bg-0, #06070b);
}

.rede-container canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ── Government Data (br-acc) ── */
.gov-badge {
  display: inline-block;
  background: rgba(0,255,136,0.15);
  color: #00ff88;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 1px 5px;
  border-radius: 3px;
  margin-right: 6px;
}
.gov-row {
  margin: 6px 0;
}
.gov-label {
  display: inline-block;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #00ff88;
  font-weight: 600;
  margin-bottom: 2px;
}
.gov-label.gov-alert {
  color: #ff4141;
}
.gov-item {
  font-size: 0.68rem;
  color: rgba(200,205,220,0.8);
  padding-left: 8px;
  line-height: 1.5;
}
.gov-source {
  font-size: 0.55rem;
  color: rgba(100,110,130,0.6);
  margin-top: 8px;
  font-style: italic;
}

/* ── Fullscreen ── */
.rede-fullscreen .navbar,
.rede-fullscreen .footer {
  display: none !important;
}

.rede-fullscreen .shell {
  padding: 0;
  max-width: none;
}

.rede-fullscreen .rede-container {
  height: 100vh;
}

/* ── Fullscreen button ── */
.rede-btn-fullscreen {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 20;
  background: var(--rede-overlay-bg, rgba(10, 12, 20, 0.7));
  border: 1px solid var(--rede-overlay-border, rgba(255,255,255,0.12));
  color: var(--text-primary, #e0e0e8);
  font-size: 1.2rem;
  min-width: 44px;
  min-height: 44px;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 4px;
  backdrop-filter: blur(8px);
  transition: background 0.2s;
}
.rede-btn-fullscreen:hover {
  background: var(--rede-overlay-bg-hover, rgba(20, 24, 40, 0.9));
}

/* ── Legend ── */
.rede-legend {
  position: absolute;
  bottom: 16px;
  left: 16px;
  z-index: 20;
  background: var(--rede-overlay-bg, rgba(10, 12, 20, 0.8));
  border: 1px solid var(--rede-overlay-border, rgba(255,255,255,0.08));
  border-radius: 6px;
  padding: 10px 14px;
  backdrop-filter: blur(8px);
  font-size: 0.7rem;
  color: var(--text-secondary, #a0a0b8);
  line-height: 1.8;
}

.rede-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rede-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.rede-legend-dot.cube {
  border-radius: 2px;
}

.rede-legend-dot.gateway {
  border-radius: 3px;
  transform: rotate(45deg);
  width: 10px;
  height: 10px;
}

.rede-legend-dot.ring {
  border-radius: 50%;
  border: 2px solid;
  background: transparent !important;
}

/* ── Search ── */
.rede-search {
  position: absolute;
  top: 38px;
  left: 12px;
  z-index: 20;
}

.rede-search input {
  background: var(--rede-overlay-bg, rgba(10, 12, 20, 0.7));
  border: 1px solid var(--rede-overlay-border, rgba(255,255,255,0.12));
  color: var(--text-primary, #e0e0e8);
  font-size: 0.75rem;
  font-family: inherit;
  padding: 6px 12px;
  border-radius: 4px;
  width: 180px;
  backdrop-filter: blur(8px);
}
.rede-search input::placeholder {
  color: rgba(160,160,184,0.5);
}
.rede-search input:focus {
  border-color: rgba(74,125,255,0.5);
}
/* H8: Visible focus outline for search input */
.rede-search input:focus-visible {
  outline: 2px solid var(--accent, #4a7dff);
  outline-offset: -2px;
}

/* L1: Search feedback message */
.rede-search-feedback {
  display: none;
  margin-top: 4px;
  font-size: 0.7rem;
  color: var(--text-muted, #666);
  padding: 2px 4px;
}

/* ── Info Panel ── */
.rede-info-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(320px, 85vw);
  height: 100%;
  z-index: 30;
  background: var(--rede-overlay-bg-solid, rgba(10, 12, 20, 0.92));
  border-left: 1px solid var(--rede-overlay-border, rgba(255,255,255,0.08));
  backdrop-filter: blur(12px);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
  padding: 16px;
  font-size: 0.8rem;
  color: var(--text-primary, #e0e0e8);
}

.rede-info-panel.open {
  transform: translateX(0);
}

.rede-info-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-secondary, #a0a0b8);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rede-info-close:hover {
  color: var(--text-primary, #e0e0e8);
}

.rede-info-header {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rede-overlay-border, rgba(255,255,255,0.08));
}

.rede-info-name {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 6px;
}

.rede-info-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 6px;
}

.rede-info-badge.entity-pessoa { background: rgba(0,212,255,0.15); color: #00d4ff; }
.rede-info-badge.entity-org { background: rgba(74,245,255,0.15); color: #4af5ff; }
.rede-info-badge.theme { background: rgba(212,168,64,0.15); color: #d4a840; }
.rede-info-badge.source { background: rgba(136,136,170,0.15); color: #8888aa; }
.rede-info-badge.pillar { background: rgba(124,92,252,0.15); color: #7c5cfc; }
.rede-info-badge.keyword { background: rgba(255,107,53,0.15); color: #FF6B35; }
.rede-info-badge.scenario { background: rgba(0,255,65,0.15); color: #00ff41; }
.rede-info-badge.content { background: rgba(52,211,153,0.15); color: #34d399; }
.rede-info-badge.cluster { background: rgba(100,116,139,0.15); color: #64748b; }

/* ── Description & Summary ── */
.rede-info-desc {
  font-size: 0.72rem;
  color: rgba(224, 224, 232, 0.7);
  line-height: 1.5;
  margin: 0 0 12px;
}

.rede-info-summary {
  background: rgba(74,125,255,0.06);
  border-left: 2px solid var(--accent, #4a7dff);
  padding: 8px 10px;
  margin-bottom: 12px;
  font-size: 0.72rem;
  line-height: 1.5;
  color: rgba(224, 224, 232, 0.8);
}

/* ── Scenario role dots ── */
.rede-info-scenario-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 0.72rem;
}

.scenario-role-dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 1px;
}
.scenario-role-dot.scenario-win { background: #00ff41; }
.scenario-role-dot.scenario-lose { background: #ff4141; }
.scenario-role-dot.scenario-neutral { background: #ffaa00; }

.scenario-row-title {
  flex: 1;
}

.scenario-row-prob {
  font-weight: 700;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.7rem;
  color: rgba(0,255,65,0.8);
}

.scenario-row-label {
  font-size: 0.65rem;
  color: rgba(224,224,232,0.4);
}

/* ── Tags chips ── */
.rede-info-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.rede-info-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 0.6rem;
  background: rgba(52,211,153,0.1);
  color: #34d399;
  border: 1px solid rgba(52,211,153,0.2);
}

/* ── Keyword Sparkline ── */
.keyword-sparkline {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 32px;
  padding: 4px 0;
}
.keyword-spark-bar {
  flex: 1;
  min-width: 4px;
  background: rgba(255,107,53,0.6);
  border-radius: 1px 1px 0 0;
}
.keyword-spark-bar:hover {
  background: rgba(255,107,53,1);
}

.rede-info-count {
  font-size: 0.7rem;
  color: var(--text-muted, #666);
}

.rede-info-section {
  margin-bottom: 14px;
}

.rede-info-section h4 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted, #666);
  margin: 0 0 8px;
}

.rede-info-bar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 0.72rem;
}

.rede-info-bar {
  height: 3px;
  background: var(--accent-glow, rgba(74,125,255,0.4));
  border-radius: 2px;
  margin-top: 2px;
}

.rede-info-link {
  display: block;
  padding: 4px 0;
  font-size: 0.72rem;
  color: var(--accent, #4a7dff);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rede-info-link:hover {
  text-decoration: underline;
}

.rede-info-article {
  padding: 4px 0;
  border-bottom: 1px solid var(--rede-overlay-border, rgba(255,255,255,0.04));
}

.rede-info-article a {
  color: var(--text-primary, #e0e0e8);
  text-decoration: none;
  font-size: 0.72rem;
  line-height: 1.4;
}
.rede-info-article a:hover {
  color: var(--accent, #4a7dff);
}

.rede-info-article .article-meta {
  font-size: 0.65rem;
  color: var(--text-muted, #666);
  margin-top: 2px;
}

.rede-info-profile-link {
  display: inline-block;
  margin-top: 12px;
  padding: 6px 14px;
  background: rgba(74,125,255,0.12);
  color: var(--accent, #4a7dff);
  border: 1px solid rgba(74,125,255,0.25);
  border-radius: 4px;
  font-size: 0.72rem;
  text-decoration: none;
}
.rede-info-profile-link:hover {
  background: rgba(74,125,255,0.2);
}

/* ── Zoom controls ── */
.rede-zoom-controls {
  position: absolute;
  bottom: 16px;
  right: 16px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rede-zoom-btn {
  background: var(--rede-overlay-bg, rgba(10, 12, 20, 0.7));
  border: 1px solid var(--rede-overlay-border, rgba(255,255,255,0.12));
  color: var(--text-primary, #e0e0e8);
  font-size: 1rem;
  width: 44px;
  height: 44px;
  cursor: pointer;
  border-radius: 4px;
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.rede-zoom-btn:hover {
  background: var(--rede-overlay-bg-hover, rgba(20, 24, 40, 0.9));
}

/* H7: Focus-visible states for interactive controls */
.rede-zoom-btn:focus-visible,
.rede-btn-fullscreen:focus-visible,
.rede-info-close:focus-visible {
  outline: 2px solid var(--accent, #4a7dff);
  outline-offset: 2px;
}

/* ── Loading ── */
.rede-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 25;
  color: var(--text-secondary, #a0a0b8);
  font-size: 0.85rem;
  text-align: center;
}

.rede-loading-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent, #4a7dff);
  border-radius: 50%;
  animation: rede-spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes rede-spin {
  to { transform: rotate(360deg); }
}

/* ── Tooltip ── */
.rede-tooltip {
  position: absolute;
  z-index: 25;
  pointer-events: none;
  background: var(--rede-overlay-bg-solid, rgba(10, 12, 20, 0.9));
  border: 1px solid var(--rede-overlay-border, rgba(255,255,255,0.12));
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 0.72rem;
  color: var(--text-primary, #e0e0e8);
  white-space: nowrap;
  display: none;
  backdrop-filter: blur(8px);
}

/* ── Overlay entrance animation ── */
.rede-legend,
.rede-search,
.rede-btn-fullscreen,
.rede-zoom-controls {
  animation: rede-fade-in 0.5s ease 1.5s both;
}

@keyframes rede-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Light theme ── */
[data-theme="light"] .rede-container {
  background: var(--bg-0, #f5f6f8);
}

[data-theme="light"] .rede-btn-fullscreen,
[data-theme="light"] .rede-zoom-btn {
  background: rgba(240, 241, 245, 0.85);
  border-color: rgba(0,0,0,0.1);
  color: var(--text-primary, #1a1d2e);
}
[data-theme="light"] .rede-btn-fullscreen:hover,
[data-theme="light"] .rede-zoom-btn:hover {
  background: rgba(220, 222, 230, 0.95);
}

[data-theme="light"] .rede-legend {
  background: rgba(240, 241, 245, 0.9);
  border-color: rgba(0,0,0,0.08);
  color: var(--text-secondary, #555872);
}

[data-theme="light"] .rede-search input {
  background: rgba(240, 241, 245, 0.85);
  border-color: rgba(0,0,0,0.1);
  color: var(--text-primary, #1a1d2e);
}
[data-theme="light"] .rede-search input::placeholder {
  color: rgba(85,88,114,0.5);
}

[data-theme="light"] .rede-info-panel {
  background: rgba(245, 246, 248, 0.95);
  border-left-color: rgba(0,0,0,0.08);
}

/* M1: Light theme overrides for info panel elements */
[data-theme="light"] .rede-info-close {
  color: var(--text-secondary, #555872);
}
[data-theme="light"] .rede-info-close:hover {
  color: var(--text-primary, #1a1d2e);
}

[data-theme="light"] .rede-info-header {
  border-bottom-color: rgba(0,0,0,0.08);
}

[data-theme="light"] .rede-info-article {
  border-bottom-color: rgba(0,0,0,0.04);
}

[data-theme="light"] .rede-info-article a {
  color: var(--text-primary, #1a1d2e);
}

[data-theme="light"] .rede-info-bar-row {
  color: var(--text-primary, #1a1d2e);
}

[data-theme="light"] .rede-info-profile-link {
  background: rgba(43,92,230,0.08);
  border-color: rgba(43,92,230,0.2);
}
[data-theme="light"] .rede-info-profile-link:hover {
  background: rgba(43,92,230,0.15);
}

/* M2: Badge contrast fix for light theme — WCAG-compliant colors */
[data-theme="light"] .rede-info-badge.entity-pessoa { background: rgba(0,150,200,0.12); color: #006080; }
[data-theme="light"] .rede-info-badge.entity-org { background: rgba(0,160,180,0.12); color: #006878; }
[data-theme="light"] .rede-info-badge.theme { background: rgba(180,138,26,0.12); color: #7a5a00; }
[data-theme="light"] .rede-info-badge.source { background: rgba(100,100,140,0.12); color: #4a4a6a; }
[data-theme="light"] .rede-info-badge.pillar { background: rgba(105,64,224,0.12); color: #4a2da0; }
[data-theme="light"] .rede-info-badge.keyword { background: rgba(200,80,30,0.12); color: #c05020; }
[data-theme="light"] .rede-info-badge.scenario { background: rgba(10,110,31,0.12); color: #0a6e1f; }
[data-theme="light"] .rede-info-badge.content { background: rgba(16,120,80,0.12); color: #107850; }
[data-theme="light"] .rede-info-badge.cluster { background: rgba(71,85,105,0.12); color: #475569; }

[data-theme="light"] .rede-info-desc {
  color: rgba(26, 29, 46, 0.7);
}
[data-theme="light"] .rede-info-summary {
  background: rgba(43,92,230,0.04);
  border-left-color: var(--accent, #2b5ce6);
  color: rgba(26, 29, 46, 0.8);
}
[data-theme="light"] .scenario-role-dot.scenario-win { background: #0a6e1f; }
[data-theme="light"] .scenario-role-dot.scenario-lose { background: #dc2626; }
[data-theme="light"] .scenario-role-dot.scenario-neutral { background: #ca8a04; }
[data-theme="light"] .scenario-row-prob { color: #0a6e1f; }
[data-theme="light"] .scenario-row-label { color: rgba(26,29,46,0.4); }
[data-theme="light"] .rede-info-tag {
  background: rgba(16,120,80,0.08);
  color: #107850;
  border-color: rgba(16,120,80,0.2);
}

[data-theme="light"] .keyword-spark-bar {
  background: rgba(200,80,30,0.5);
}
[data-theme="light"] .keyword-spark-bar:hover {
  background: rgba(200,80,30,0.85);
}

[data-theme="light"] .rede-tooltip {
  background: rgba(245, 246, 248, 0.95);
  border-color: rgba(0,0,0,0.1);
  color: var(--text-primary, #1a1d2e);
}

[data-theme="light"] .rede-loading {
  color: var(--text-secondary, #555872);
}

[data-theme="light"] .rede-loading-spinner {
  border-color: rgba(0,0,0,0.08);
  border-top-color: var(--accent, #2b5ce6);
}

[data-theme="light"] .rede-search-feedback {
  color: var(--text-secondary, #555872);
}

/* ── M3: Reduced motion support ── */
@media (prefers-reduced-motion: reduce) {
  .rede-legend,
  .rede-search,
  .rede-btn-fullscreen,
  .rede-zoom-controls {
    animation: none;
  }

  .rede-info-panel {
    transition: none;
  }

  .rede-loading-spinner {
    animation: none;
  }
}

/* ── Responsive ── */
/* H9: Additional breakpoints */
@media (max-width: 1024px) {
  .rede-info-panel {
    width: 300px;
  }
}

@media (max-width: 768px) {
  .rede-info-panel {
    width: 260px;
  }
}

@media (max-width: 600px) {
  .rede-info-panel {
    width: 280px;
  }
  .rede-legend {
    font-size: 0.6rem;
    padding: 8px 10px;
  }
  .rede-search input {
    width: 140px;
    font-size: 0.7rem;
  }
}

@media (max-width: 480px) {
  .rede-info-panel {
    width: 100%;
    height: 50vh;
    bottom: 0;
    top: auto;
    border-left: none;
    border-top: 1px solid var(--rede-overlay-border, rgba(255,255,255,0.08));
    transform: translateY(100%);
  }
  .rede-info-panel.open {
    transform: translateY(0);
  }
}

/* M9: Backdrop-filter fallback */
@supports not (backdrop-filter: blur(8px)) {
  .rede-btn-fullscreen,
  .rede-zoom-btn,
  .rede-search input,
  .rede-tooltip {
    background: rgba(10, 12, 20, 0.95);
  }
  .rede-legend {
    background: rgba(10, 12, 20, 0.95);
  }
  .rede-info-panel {
    background: rgba(10, 12, 20, 0.98);
  }
  [data-theme="light"] .rede-btn-fullscreen,
  [data-theme="light"] .rede-zoom-btn,
  [data-theme="light"] .rede-search input,
  [data-theme="light"] .rede-tooltip {
    background: rgba(240, 241, 245, 0.98);
  }
  [data-theme="light"] .rede-legend {
    background: rgba(240, 241, 245, 0.98);
  }
  [data-theme="light"] .rede-info-panel {
    background: rgba(245, 246, 248, 0.99);
  }
}

/* ── Stats Bar (Fase 4.2) ── */
.rede-stats-bar {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--rede-overlay-bg, rgba(10, 12, 20, 0.65));
  backdrop-filter: blur(8px);
  border: 1px solid var(--rede-overlay-border, rgba(255,255,255,0.08));
  border-radius: 20px;
  padding: 4px 14px;
  font-family: monospace;
  font-size: 0.58rem;
  color: rgba(200,205,220,0.7);
  letter-spacing: 0.04em;
  white-space: nowrap;
  animation: fadeIn 0.5s ease 2s both;
}
.rede-stats-sep {
  color: rgba(0,212,255,0.3);
  margin: 0 1px;
}
[data-theme="light"] .rede-stats-bar {
  background: rgba(240,241,245,0.85);
  border-color: rgba(0,0,0,0.08);
  color: rgba(60,65,80,0.7);
}
[data-theme="light"] .rede-stats-sep {
  color: rgba(0,100,180,0.3);
}

/* ── Quick Focus (Fase 4.4) ── */
.rede-quick-focus {
  position: absolute;
  top: 8px;
  left: 12px;
  z-index: 20;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  max-width: 280px;
  animation: fadeIn 0.5s ease 1.8s both;
}
.rede-qf-btn {
  background: rgba(10, 12, 20, 0.6);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0,212,255,0.15);
  color: rgba(0,212,255,0.8);
  font-family: monospace;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}
.rede-qf-btn:hover {
  background: rgba(0,212,255,0.15);
  border-color: rgba(0,212,255,0.4);
  color: #00d4ff;
}
[data-theme="light"] .rede-qf-btn {
  background: rgba(240,241,245,0.85);
  border-color: rgba(0,100,180,0.15);
  color: rgba(0,100,180,0.7);
}
[data-theme="light"] .rede-qf-btn:hover {
  background: rgba(0,100,180,0.1);
  color: #0077b3;
}

@media (max-width: 600px) {
  .rede-stats-bar {
    font-size: 0.5rem;
    padding: 3px 10px;
    top: 4px;
  }
  .rede-quick-focus {
    top: 28px;
    left: 8px;
    max-width: 220px;
  }
  .rede-qf-btn {
    font-size: 0.5rem;
    padding: 2px 6px;
  }
}

