/* ═══════════════════════════════════════════════════════════════
   arch-playground.css — Architecture Topology Explorer Component
   Dileep Kallakuri · dkportfolio
   ═══════════════════════════════════════════════════════════════ */

/* ── OUTER WRAPPER ────────────────────────────────────────────── */
.dk-arch {
  background:
    radial-gradient(ellipse at top center, rgba(220, 195, 154, 0.04) 0%, rgba(220, 195, 154, 0) 30%),
    linear-gradient(180deg, rgba(19, 25, 35, 0.98) 0%, rgba(9, 12, 18, 0.99) 18%, rgba(7, 8, 15, 1) 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 520px;
  box-shadow: 0 40px 110px rgba(0, 0, 0, 0.42), 0 16px 38px rgba(4, 8, 14, 0.24), inset 0 1px 0 rgba(255,255,255,0.05);
  position: relative;
}

/* ── TOP BAR ──────────────────────────────────────────────────── */
.dk-arch-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  background: linear-gradient(180deg, rgba(20, 25, 34, 0.98), rgba(14, 18, 26, 0.98));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  gap: 1rem;
  flex-wrap: wrap;
}

.dk-arch-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.48);
  letter-spacing: 0.04em;
}

.dk-arch-simulate-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.36rem 0.9rem;
  background: rgba(245, 166, 35, 0.1);
  border: 1px solid rgba(245, 166, 35, 0.25);
  border-radius: 999px;
  color: #F5A623;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
  letter-spacing: 0.03em;
}

.dk-arch-simulate-btn:hover {
  background: rgba(245, 166, 35, 0.18);
  border-color: rgba(245, 166, 35, 0.5);
}

.dk-arch-simulate-btn.running {
  background: rgba(245, 166, 35, 0.06);
  color: rgba(245, 166, 35, 0.5);
  pointer-events: none;
}

/* ── BODY LAYOUT ──────────────────────────────────────────────── */
.dk-arch-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── SIDEBAR ──────────────────────────────────────────────────── */
.dk-arch-sidebar {
  width: 200px;
  flex-shrink: 0;
  background: rgba(8, 12, 20, 0.72);
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  overflow-y: auto;
  overflow-x: hidden;
}

.dk-arch-sidebar::-webkit-scrollbar { width: 2px; }
.dk-arch-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); }

.dk-arch-topo-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.7rem 0.9rem;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.dk-arch-topo-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.dk-arch-topo-item.active {
  background: rgba(169, 226, 215, 0.09);
  border-left-color: #a9e2d7;
}

.dk-arch-topo-name {
  font-family: var(--font-ui, sans-serif);
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dk-arch-topo-item.active .dk-arch-topo-name {
  color: #a9e2d7;
}

.dk-arch-topo-desc {
  font-family: var(--font-main, sans-serif);
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dk-arch-topo-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.1rem;
}

.dk-arch-badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.4);
}

.dk-arch-badge.mysql    { background: rgba(245,166,35,0.15); color: #F5A623; }
.dk-arch-badge.postgres { background: rgba(140,186,212,0.15); color: #8cbad4; }
.dk-arch-badge.mongo    { background: rgba(62,201,126,0.15); color: #3ec97e; }
.dk-arch-badge.aws      { background: rgba(255,153,0,0.15); color: #FF9900; }
.dk-arch-badge.multi    { background: rgba(220,195,154,0.16); color: #dcc39a; }

.dk-arch-complexity {
  display: flex;
  gap: 2px;
  align-items: center;
}

.dk-arch-complexity-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
}

.dk-arch-complexity-dot.filled { background: #a9e2d7; }

/* ── CANVAS ───────────────────────────────────────────────────── */
.dk-arch-canvas {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #090d15;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 36px 36px;
}

.dk-arch-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ── SVG NODES ────────────────────────────────────────────────── */
.dk-arch-node {
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.dk-arch-node:hover .dk-node-rect { filter: brightness(1.15); }

.dk-node-rect {
  rx: 6;
  ry: 6;
  transition: filter 0.2s ease;
}

.dk-node-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  fill: rgba(255,255,255,0.85);
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

.dk-node-sublabel {
  font-family: var(--font-ui, sans-serif);
  font-size: 9px;
  fill: rgba(255,255,255,0.4);
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

/* Status indicator dot in SVG */
.dk-node-status {
  transition: fill 0.3s ease;
}

.dk-node-status.healthy { fill: #3ec97e; }
.dk-node-status.warn    { fill: #F5A623; }
.dk-node-status.failed  { fill: #ff5f57; }

/* Pulsing animation for healthy nodes */
@keyframes dkNodePulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.dk-node-pulse {
  animation: dkNodePulse 2.5s ease infinite;
}

/* Failed node shake */
@keyframes dkNodeFail {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-3px, 0); }
  40%  { transform: translate(3px, 0); }
  60%  { transform: translate(-2px, 0); }
  80%  { transform: translate(2px, 0); }
  100% { transform: translate(0, 0); }
}

.dk-arch-node.failing {
  animation: dkNodeFail 0.3s ease;
}

/* ── SVG CONNECTIONS ──────────────────────────────────────────── */
.dk-arch-conn {
  cursor: pointer;
  fill: none;
  stroke-width: 1.5;
  stroke-dasharray: 6 4;
  transition: stroke-opacity 0.3s ease, stroke 0.3s ease;
}

.dk-arch-conn.replication { stroke: #a9e2d7; stroke-dasharray: 6 4; }
.dk-arch-conn.write       { stroke: #F5A623; stroke-dasharray: none; stroke-dasharray: 0; }
.dk-arch-conn.read        { stroke: #3ec97e; stroke-dasharray: 4 3; }
.dk-arch-conn.monitoring  { stroke: rgba(255,255,255,0.18); stroke-dasharray: 3 5; }
.dk-arch-conn.election    { stroke: #dcc39a; stroke-dasharray: 4 4; }
.dk-arch-conn.failed-conn { stroke: #ff5f57 !important; stroke-dasharray: 3 3 !important; opacity: 0.5; }

/* Animated dash flow */
@keyframes dkDashFlow {
  from { stroke-dashoffset: 20; }
  to   { stroke-dashoffset: 0; }
}

.dk-arch-conn.animated {
  animation: dkDashFlow 1.2s linear infinite;
}

/* Arrow markers are defined inline in SVG */

/* ── RIGHT PANEL ──────────────────────────────────────────────── */
.dk-arch-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 260px;
  background: rgba(11, 16, 24, 0.97);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 20;
  padding: 1rem;
}

.dk-arch-panel.open {
  transform: translateX(0);
}

.dk-arch-panel::-webkit-scrollbar { width: 2px; }
.dk-arch-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); }

.dk-arch-panel-close {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.6rem;
}

.dk-arch-panel-close-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.35);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.1rem 0.3rem;
  transition: color 0.2s ease;
}

.dk-arch-panel-close-btn:hover { color: rgba(255,255,255,0.7); }

.dk-arch-panel-type {
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #4A90D9;
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 0.3rem;
}

.dk-arch-panel-name {
  font-family: var(--font-ui, sans-serif);
  font-size: 0.95rem;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  margin-bottom: 0.2rem;
  line-height: 1.2;
}

.dk-arch-panel-role {
  font-family: var(--font-main, sans-serif);
  font-size: 0.74rem;
  color: rgba(255,255,255,0.45);
  margin-bottom: 0.8rem;
  line-height: 1.4;
}

.dk-arch-panel-divider {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.07);
  margin: 0.7rem 0;
}

.dk-arch-panel-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: rgba(255,255,255,0.3);
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 0.3rem;
}

.dk-arch-panel-code {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 4px;
  padding: 0.5rem 0.65rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.65);
  line-height: 1.6;
  white-space: pre-wrap;
  margin-bottom: 0.7rem;
}

.dk-arch-panel-text {
  font-family: var(--font-main, sans-serif);
  font-size: 0.74rem;
  color: rgba(255,255,255,0.5);
  line-height: 1.55;
  margin-bottom: 0.5rem;
}

.dk-arch-panel-text strong { color: rgba(255,255,255,0.8); }
.dk-arch-panel-text .warn  { color: #F5A623; }

.dk-arch-panel-link {
  display: inline-block;
  margin-top: 0.4rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  color: #4A90D9;
  border: 1px solid rgba(74,144,217,0.3);
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  transition: background 0.2s ease;
  cursor: pointer;
}

.dk-arch-panel-link:hover { background: rgba(74,144,217,0.1); }

/* ── FAILOVER STATUS OVERLAY ──────────────────────────────────── */
.dk-arch-failover-status {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: rgba(12, 12, 22, 0.97);
  border: 1px solid rgba(74, 144, 217, 0.3);
  border-radius: 6px;
  padding: 0.65rem 1.1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.74rem;
  color: rgba(255,255,255,0.7);
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  z-index: 30;
  min-width: 260px;
}

.dk-arch-failover-status.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.dk-arch-failover-status .fo-success { color: #3ec97e; }
.dk-arch-failover-status .fo-warn    { color: #F5A623; }

/* ── LEGEND ───────────────────────────────────────────────────── */
.dk-arch-legend {
  position: absolute;
  bottom: 0.75rem;
  left: 0.75rem;
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  z-index: 5;
  pointer-events: none;
}

.dk-arch-legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.63rem;
  color: rgba(255,255,255,0.3);
}

.dk-arch-legend-line {
  width: 18px;
  height: 2px;
  border-radius: 1px;
}

.dk-arch-legend-line.replication { background: #4A90D9; }
.dk-arch-legend-line.write       { background: #F5A623; }
.dk-arch-legend-line.read        { background: #3ec97e; }
.dk-arch-legend-line.monitoring  { background: rgba(255,255,255,0.2); }
.dk-arch-legend-line.election    { background: #7c6bff; }

/* ── RESPONSIVE / MOBILE ──────────────────────────────────────── */
@media (max-width: 760px) {
  .dk-arch {
    min-height: 468px;
  }
  .dk-arch-topbar {
    align-items: stretch;
    gap: 0.7rem;
    padding: 0.8rem 0.85rem 0.75rem;
  }
  .dk-arch-title {
    font-size: 0.68rem;
    line-height: 1.35;
  }
  .dk-arch-simulate-btn {
    width: 100%;
    justify-content: center;
    padding: 0.52rem 0.85rem;
    font-size: 0.69rem;
  }
  .dk-arch-body {
    flex-direction: column;
  }
  .dk-arch-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: none;
    padding: 0.35rem 0.45rem;
    gap: 0.45rem;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }
  .dk-arch-topo-item {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    padding: 0.58rem 0.8rem;
    flex-shrink: 0;
    border-left: none;
    border-bottom: 2px solid transparent;
    border-radius: 14px;
    background: rgba(255,255,255,0.025);
    scroll-snap-align: start;
  }
  .dk-arch-topo-item.active {
    background: rgba(169, 226, 215, 0.08);
    border-bottom-color: #4A90D9;
    border-left: none;
  }
  .dk-arch-topo-name {
    font-size: 0.7rem;
  }
  .dk-arch-topo-desc { display: none; }
  .dk-arch-topo-meta { display: none; }
  .dk-arch-canvas {
    height: 320px;
    min-height: 320px;
  }
  .dk-arch-panel {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: min(46vh, 320px);
    transform: translateY(100%);
    border-left: none;
    border-top: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px 16px 0 0;
    padding: 0.85rem 0.95rem 1rem;
    box-shadow: 0 -18px 44px rgba(0,0,0,0.34);
  }
  .dk-arch-panel.open {
    transform: translateY(0);
  }
}

@media (max-width: 480px) {
  .dk-arch {
    min-height: 430px;
  }
  .dk-arch-title {
    font-size: 0.64rem;
  }
  .dk-arch-simulate-btn {
    font-size: 0.66rem;
    padding-inline: 0.75rem;
  }
  .dk-arch-topo-item {
    padding: 0.52rem 0.72rem;
  }
  .dk-arch-topo-name {
    font-size: 0.66rem;
  }
  .dk-arch-canvas {
    height: 280px;
    min-height: 280px;
  }
  .dk-arch-panel {
    height: min(44vh, 300px);
    padding: 0.8rem 0.85rem 0.95rem;
  }
  .dk-arch-legend { display: none; }
}
