/* dn42.css — DN42 page styles */

/* === Live stats === */
.live-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  padding: 16px 0;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px;
  background: var(--bg, #1e1c3a);
  border-radius: 8px;
  border: 1px solid var(--border, #2a284a);
  text-align: center;
}

.stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted, #8a87b0);
  font-family: monospace;
}

.stat-value {
  font-size: 24px;
  font-weight: bold;
  color: var(--accent, #b8a8e0);
  font-family: monospace;
}

.stat-value.loading {
  animation: pulse 1.5s ease-in-out infinite;
}

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

/* === Network details === */
.network-details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  padding: 16px 0;
}

.network-details dt {
  font-weight: bold;
  color: var(--accent, #b8a8e0);
  font-family: monospace;
  font-size: 14px;
}

.network-details dd {
  margin: 0;
  color: var(--text, #e8e6f0);
  font-family: monospace;
  font-size: 14px;
  word-break: break-all;
}

/* === Glossary === */
.glossary-grid {
  padding: 8px 0;
}

.glossary-category {
  margin: 8px 0;
  border: 1px solid var(--border, #2a284a);
  border-radius: 8px;
  overflow: hidden;
}

.glossary-category[open] {
  border-color: var(--accent, #6a5acd);
}

.glossary-category summary {
  padding: 12px 16px;
  background: var(--bg, #1e1c3a);
  cursor: pointer;
  font-family: monospace;
  font-size: 14px;
  font-weight: bold;
  color: var(--accent, #b8a8e0);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.glossary-category summary::-webkit-details-marker {
  display: none;
}

.glossary-category summary::before {
  content: '▶';
  display: inline-block;
  transition: transform 0.2s;
  font-size: 10px;
}

.glossary-category[open] summary::before {
  transform: rotate(90deg);
}

.glossary-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.glossary-item {
  padding: 12px 16px;
  border-top: 1px solid var(--border, #2a284a);
  cursor: pointer;
  transition: background 0.2s;
}

.glossary-item:hover,
.glossary-item.highlighted,
.glossary-item.pinned {
  background: rgba(106, 90, 205, 0.15);
}

.glossary-item.pinned {
  background: rgba(255, 215, 0, 0.1);
  border-left: 3px solid #ffd700;
}

.glossary-term {
  font-weight: bold;
  color: var(--accent, #b8a8e0);
  font-family: monospace;
  font-size: 14px;
}

.glossary-full {
  font-size: 12px;
  color: var(--text-muted, #8a87b0);
  font-family: monospace;
  margin-left: 8px;
}

.glossary-def {
  margin: 8px 0 0 0;
  font-size: 13px;
  color: var(--text, #c8c5e0);
  line-height: 1.5;
}

.glossary-search {
  width: 100%;
  padding: 10px 14px;
  margin: 12px 0;
  background: var(--bg, #16152a);
  border: 1px solid var(--border, #2a284a);
  border-radius: 6px;
  color: var(--text, #e8e6f0);
  font-family: monospace;
  font-size: 14px;
  box-sizing: border-box;
}

.glossary-search:focus {
  outline: 2px solid var(--accent, #6a5acd);
  outline-offset: 2px;
}

.glossary-search::placeholder {
  color: var(--text-muted, #6a6590);
}

/* === Diagram === */
.diagram-container {
  width: 100%;
  max-width: 700px;
  margin: 16px auto;
  background: var(--bg, #1a1935);
  border-radius: 12px;
  border: 1px solid var(--border, #2a284a);
  padding: 16px;
  overflow-x: auto;
}

.dn42-diagram-svg {
  width: 100%;
  height: auto;
  max-height: 500px;
}

.diagram-node {
  cursor: pointer;
  transition: transform 0.2s;
}

.diagram-node:hover {
  transform: scale(1.05);
}

.diagram-link {
  transition: stroke 0.2s, stroke-width 0.2s;
}

.diagram-link:hover {
  stroke: #ffd700;
  stroke-width: 3;
}

.diagram-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 0;
  font-family: monospace;
  font-size: 12px;
  color: var(--text-muted, #8a87b0);
}

.legend-item {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.legend-item:hover {
  background: rgba(106, 90, 205, 0.2);
}

/* === Peer table === */
.dn42-peer-controls {
  margin: 12px 0;
}

.dn42-peer-search {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg, #16152a);
  border: 1px solid var(--border, #2a284a);
  border-radius: 6px;
  color: var(--text, #e8e6f0);
  font-family: monospace;
  font-size: 14px;
  box-sizing: border-box;
}

.dn42-peer-search:focus {
  outline: 2px solid var(--accent, #6a5acd);
  outline-offset: 2px;
}

.dn42-peer-search::placeholder {
  color: var(--text-muted, #6a6590);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: monospace;
  font-size: 13px;
}

thead th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg, #1e1c3a);
  color: var(--accent, #b8a8e0);
  border-bottom: 2px solid var(--border, #2a284a);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  min-height: 44px;
}

thead th:hover {
  background: var(--accent, #6a5acd);
  color: var(--bg, #16152a);
}

tbody tr {
  border-bottom: 1px solid var(--border, #2a284a);
  transition: background 0.2s;
}

tbody tr:hover {
  background: rgba(106, 90, 205, 0.1);
}

tbody td {
  padding: 8px 12px;
  color: var(--text, #c8c5e0);
}

.peer-status {
  font-weight: bold;
  font-size: 12px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
}

.peer-status.online {
  color: #4caf50;
  background: rgba(76, 175, 80, 0.15);
}

.peer-status.offline {
  color: #f44336;
  background: rgba(244, 67, 54, 0.15);
}

/* === AS-Path Visualizer === */
.as-path-viz {
  margin: 16px 0;
}

.as-path-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.as-path-input-row label {
  display: flex;
  flex-direction: column;
  min-width: 200px;
}

.as-path-input-row input,
.as-path-input-row select,
.as-path-input-row button {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  background: var(--bg, #16152a);
  border: 1px solid var(--border, #2a284a);
  border-radius: 6px;
  color: var(--text, #e8e6f0);
  font-family: monospace;
  font-size: 14px;
  min-height: 44px;
  box-sizing: border-box;
}

.as-path-input-row input:focus,
.as-path-input-row select:focus,
.as-path-input-row button:focus {
  outline: 2px solid var(--accent, #6a5acd);
  outline-offset: 2px;
}

.as-path-input-row button {
  background: var(--accent, #6a5acd);
  color: var(--bg, #16152a);
  border: none;
  cursor: pointer;
}

.as-path-input-row button:hover {
  background: #b8a8e0;
}

.as-path-output {
  padding: 12px;
  background: var(--bg, #1e1c3a);
  border-radius: 8px;
  border: 1px solid var(--border, #2a284a);
  font-family: monospace;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text, #c8c5e0);
  white-space: pre-wrap;
}

.hop {
  display: inline-block;
  padding: 6px 12px;
  background: var(--accent, #6a5acd);
  color: var(--bg, #16152a);
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
  margin-right: 4px;
}

.hop.transit {
  background: #4a90d9;
}

.hop.peer {
  background: #27ae60;
}

/* Arrow between hops */
.as-path-output .arrow {
  color: var(--text-muted, #8a87b0);
  font-size: 16px;
  margin: 0 4px;
}

/* === Route lookup === */
.peer-loc,
.peer-type,
.peer-routes {
  white-space: nowrap;
}

/* === Route lookup === */
.dn42-lookup-controls {
  margin: 12px 0;
}

#dn42-route-lookup {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg, #16152a);
  border: 1px solid var(--border, #2a284a);
  border-radius: 6px;
  color: var(--text, #e8e6f0);
  font-family: monospace;
  font-size: 14px;
  box-sizing: border-box;
  min-height: 44px;
}

#dn42-route-lookup:focus {
  outline: 2px solid var(--accent, #6a5acd);
  outline-offset: 2px;
}

.dn42-lookup-results {
  padding: 12px 0;
  font-family: monospace;
  font-size: 13px;
  color: var(--text, #c8c5e0);
}

.dn42-lookup-results ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.dn42-lookup-results li {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border, #2a284a);
}

.dn42-lookup-results li:hover {
  background: rgba(106, 90, 205, 0.1);
}

/* === BGP session state === */
.bgp-state-summary {
  padding: 12px 0;
}

.bgp-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 12px 0;
}

.bgp-stats .stat {
  padding: 12px 16px;
  background: var(--bg, #1e1c3a);
  border-radius: 8px;
  border: 1px solid var(--border, #2a284a);
  font-family: monospace;
  font-size: 14px;
  text-align: center;
  min-width: 120px;
}

.peer-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 0;
  font-family: monospace;
  font-size: 13px;
  color: var(--text-muted, #8a87b0);
}

/* === Daily fact === */
.dn42-daily-fact {
  margin: 12px 0 0 0;
  padding: 12px 16px;
  background: rgba(106, 90, 205, 0.1);
  border-left: 3px solid var(--accent, #6a5acd);
  border-radius: 0 8px 8px 0;
  font-family: monospace;
  font-size: 13px;
  color: var(--text, #c8c5e0);
}

/* === FAQ === */
.faq-list {
  padding: 12px 0;
}

.faq-list dt {
  font-weight: bold;
  color: var(--accent, #b8a8e0);
  font-family: monospace;
  font-size: 14px;
  margin-top: 16px;
}

.faq-list dd {
  margin: 8px 0 0 0;
  color: var(--text, #c8c5e0);
  font-size: 14px;
  line-height: 1.6;
}

/* === Greentext === */
.greentext {
  color: #4caf50;
  font-family: monospace;
  font-size: 13px;
  line-height: 1.5;
  margin: 12px 0;
  padding: 12px;
  background: rgba(76, 175, 80, 0.05);
  border-radius: 6px;
}

/* === BGP FSM (finite state machine) === */
.bgp-fsm-container {
  width: 100%;
  max-width: 700px;
  margin: 16px auto;
  background: var(--bg, #1a1935);
  border-radius: 12px;
  border: 1px solid var(--border, #2a284a);
  padding: 16px;
  overflow-x: auto;
}

.bgp-fsm-svg {
  width: 100%;
  height: auto;
}

/* === Latency heatmap === */
.latency-heatmap {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 8px;
  padding: 16px 0;
}

.latency-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border-radius: 8px;
  text-align: center;
  font-family: monospace;
  font-size: 12px;
  transition: transform 0.2s;
  cursor: default;
}

.latency-cell:hover {
  transform: scale(1.05);
}

.latency-cell .loc {
  font-weight: bold;
  color: var(--text, #e8e6f0);
  font-size: 13px;
}

.latency-cell .ms {
  font-size: 16px;
  font-weight: bold;
}

.latency-cell .peers-count {
  font-size: 11px;
  color: var(--text-muted, #8a87b0);
}

/* Latency color scale */
.latency-fast {
  background: rgba(76, 175, 80, 0.15);
  border: 1px solid rgba(76, 175, 80, 0.3);
}
.latency-fast .ms { color: #4caf50; }

.latency-medium {
  background: rgba(255, 193, 7, 0.15);
  border: 1px solid rgba(255, 193, 7, 0.3);
}
.latency-medium .ms { color: #ffc107; }

.latency-slow {
  background: rgba(255, 87, 34, 0.15);
  border: 1px solid rgba(255, 87, 34, 0.3);
}
.latency-slow .ms { color: #ff5722; }

/* === Packet tracer === */
.packet-tracer {
  padding: 16px 0;
}

.tracer-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.tracer-input-row input,
.tracer-input-row select {
  flex: 1;
  min-width: 150px;
  padding: 10px 14px;
  background: var(--bg, #16152a);
  border: 1px solid var(--border, #2a284a);
  border-radius: 6px;
  color: var(--text, #e8e6f0);
  font-family: monospace;
  font-size: 14px;
  min-height: 44px;
}

.tracer-input-row input:focus,
.tracer-input-row select:focus {
  outline: 2px solid var(--accent, #6a5acd);
  outline-offset: 2px;
}

.tracer-btn {
  padding: 10px 20px;
  background: var(--accent, #6a5acd);
  color: var(--bg, #16152a);
  border: none;
  border-radius: 6px;
  font-family: monospace;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
}

.tracer-btn:hover {
  background: #b8a8e0;
}

.tracer-btn:active {
  transform: scale(0.98);
}

.tracer-output {
  padding: 12px;
  background: var(--bg, #1e1c3a);
  border-radius: 8px;
  border: 1px solid var(--border, #2a284a);
  font-family: monospace;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text, #c8c5e0);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 300px;
  overflow-y: auto;
}

/* === BGP path tracer === */
.bgp-path {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  padding: 12px 0;
  font-family: monospace;
}

.bgp-path .hop {
  padding: 6px 12px;
  background: var(--accent, #6a5acd);
  color: var(--bg, #16152a);
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
}

.bgp-path .hop.transit {
  background: #4a90d9;
}

.bgp-path .hop.peer {
  background: #27ae60;
}

.bgp-path .arrow {
  color: var(--text-muted, #8a87b0);
  font-size: 16px;
}

/* === Responsive === */
@media (max-width: 768px) {
  .live-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .network-details {
    grid-template-columns: 1fr;
  }

  .network-details dt {
    margin-top: 12px;
  }

  .network-details dd {
    margin-top: 4px;
  }

  .latency-heatmap {
    grid-template-columns: repeat(2, 1fr);
  }

  .bgp-stats {
    flex-direction: column;
  }

  .peer-breakdown {
    flex-direction: column;
  }

  .tracer-input-row {
    flex-direction: column;
  }

  .tracer-input-row input,
  .tracer-input-row select,
  .tracer-btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .live-stats {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .stat-value {
    font-size: 18px;
  }

  .latency-heatmap {
    grid-template-columns: repeat(2, 1fr);
  }

  table {
    font-size: 12px;
  }

  thead th,
  tbody td {
    padding: 6px 8px;
  }
}
