/* MAP-Tool specific styles */
.map-hero {
  position: relative;
  z-index: 1;
  width: min(1200px, calc(100% - 2rem));
  margin-inline: auto;
  padding: 3.5rem 0 1.75rem;
}

.map-shell {
  position: relative;
  z-index: 1;
  width: min(1200px, calc(100% - 2rem));
  margin-inline: auto;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 1rem;
  padding-bottom: 1.4rem;
}

/* Responsive breakpoints for better use of space */
@media (max-width: 768px) {
  .map-shell {
    grid-template-columns: 1fr;
  }

  .map-palette {
    display: none;
  }

  .map-workspace {
    min-height: 60vh;
  }

  .map-toolbar {
    flex-direction: column;
  }

  .map-hint {
    margin-left: 0;
    width: 100%;
  }

  .map-editor {
    grid-template-columns: 1fr;
  }

  .map-btn {
    width: 100%;
  }

  .map-canvas {
    min-height: 420px;
  }
}

@media (min-width: 769px) and (max-width: 1200px) {
  .map-palette {
    max-height: calc(100vh - 2rem);
    padding: 0.8rem;
  }

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

  .map-canvas {
    min-height: 500px;
  }
}

@media (min-width: 1201px) and (max-width: 1600px) {
  .map-palette {
    max-height: calc(100vh - 2rem);
  }

  .map-canvas {
    min-height: 550px;
  }
}

@media (min-width: 1601px) {
  .map-shell {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .map-palette {
    max-height: calc(100vh - 2rem);
    padding: 1rem;
  }

  .map-editor {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
  }

  .map-canvas {
    min-height: 650px;
  }

  .map-workspace {
    min-height: 75vh;
  }
}


.map-panel {
  border: 1px solid var(--card-border);
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.map-palette {
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow: hidden;
}

.map-palette h2,
.map-palette h3 {
  margin: 0;
}

.palette-section {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 0;
  flex: 1 1 0;
}

.palette-section-objects {
  flex: 0 0 auto;
}

.palette-section-objects .palette-list {
  flex: 0 0 auto;
  max-height: 140px;
}

.palette-section-services {
  flex: 1 1 auto;
}

.palette-list {
  display: grid;
  gap: 0.5rem;
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.2rem;
}

.palette-item {
  border: 1px solid #cc000055;
  background: #130000;
  color: #ff9a9a;
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
  font: 500 0.85rem 'IBM Plex Mono', monospace;
  text-align: left;
  cursor: grab;
}

.palette-item:active {
  cursor: grabbing;
}

.palette-item small {
  display: block;
  margin-top: 0.25rem;
  color: #cc6666;
  font-size: 0.72rem;
}

.service-filter {
  width: 100%;
  border: 1px solid #cc000033;
  border-radius: 10px;
  background: #0a0000;
  color: var(--text);
  padding: 0.6rem;
  font: inherit;
}

.map-workspace {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 68vh;
}

.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.8rem;
  border-bottom: 1px solid #cc000025;
}

.map-btn {
  border: 1px solid #cc000055;
  background: #140000;
  color: #ff9999;
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  font: 500 0.84rem 'IBM Plex Mono', monospace;
}

.map-btn.active {
  background: linear-gradient(135deg, #cc0000, #7f0000);
  color: #fff;
  border-color: transparent;
}

.map-hint {
  color: var(--text-soft);
  font-size: 0.82rem;
  margin-left: auto;
}

.map-canvas {
  position: relative;
  margin: 0.8rem;
  border: 1px dashed #cc000055;
  border-radius: 12px;
  background:
    linear-gradient(#22000020 1px, transparent 1px),
    linear-gradient(90deg, #22000020 1px, transparent 1px),
    #060000;
  background-size: 24px 24px;
  min-height: 480px;
  overflow: hidden;
}

.map-link-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map-node-layer {
  position: absolute;
  inset: 0;
}

.map-node {
  position: absolute;
  min-width: 140px;
  max-width: 220px;
  border: 1px solid #cc000055;
  border-radius: 12px;
  background: #160000f2;
  color: #ff9a9a;
  padding: 0.5rem 0.6rem;
  cursor: move;
  user-select: none;
  box-shadow: 0 8px 20px #00000066;
}

.map-node-client,
.map-node-server {
  min-width: 124px;
  max-width: 168px;
  padding: 0.42rem 0.5rem;
  border-radius: 10px;
}

.map-node.selected {
  border-color: #ff4444;
  box-shadow: 0 0 0 2px #ff444444;
}

.map-node-title {
  margin: 0;
  font-weight: 700;
  font-size: 0.86rem;
  line-height: 1.25;
}

.map-node-meta {
  margin-top: 0.25rem;
  color: #cc6666;
  font-size: 0.72rem;
  font-family: 'IBM Plex Mono', monospace;
}

.map-node-client {
  background: #1c0000f2;
}

.map-node-server {
  background: #12081af2;
}

.map-node-service {
  background: #0f101af2;
}

.map-link {
  stroke: #ff6666;
  stroke-width: 2;
  stroke-dasharray: 7 6;
  animation: mapFlowForward 1.05s linear infinite;
}

.map-link-reverse {
  animation: mapFlowReverse 1.05s linear infinite;
}

.map-link-both {
  animation: mapFlowPulse 0.9s ease-in-out infinite;
}

.map-link-hit {
  stroke: transparent;
  stroke-width: 16;
  cursor: pointer;
}

.map-link.selected {
  stroke: #ffd1d1;
  stroke-width: 2.6;
}

.map-arrow-head {
  fill: #ff6666;
}

.map-link.selected + .map-link-hit + .map-link-label {
  fill: #fff;
}

.map-link-label {
  fill: #ffdada;
  font-size: 12px;
  font-family: 'IBM Plex Mono', monospace;
  paint-order: stroke;
  stroke: #000;
  stroke-width: 3px;
  stroke-opacity: 0.65;
}

.map-editor {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 0.7rem;
  align-items: end;
  padding: 0.8rem;
  border-top: 1px solid #cc000025;
}

.map-editor-group {
  display: grid;
  gap: 0.35rem;
}

.map-editor label {
  font-size: 0.78rem;
}

.map-editor input {
  width: 100%;
  border: 1px solid #cc000033;
  border-radius: 10px;
  background: #0a0000;
  color: var(--text);
  padding: 0.55rem 0.6rem;
  font: inherit;
}

.map-editor small {
  color: #cc6666;
}

@keyframes mapFlowForward {
  from {
    stroke-dashoffset: 0;
  }
  to {
    stroke-dashoffset: -26;
  }
}

@keyframes mapFlowReverse {
  from {
    stroke-dashoffset: 0;
  }
  to {
    stroke-dashoffset: 26;
  }
}

@keyframes mapFlowPulse {
  0% {
    stroke-dashoffset: 0;
    stroke-opacity: 0.8;
  }
  50% {
    stroke-opacity: 1;
  }
  100% {
    stroke-dashoffset: -12;
    stroke-opacity: 0.8;
  }
}

/* Export Dialog */
.map-export-dialog {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.map-export-box {
  border: 1px solid #cc000055;
  background: #160000f2;
  color: #ff9a9a;
  border-radius: 14px;
  padding: 2rem;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 60px #00000088;
  animation: slideInUp 300ms ease both;
}

.map-export-box h2 {
  margin: 0 0 0.8rem 0;
  font-size: 1.2rem;
  color: #ff6666;
}

.map-export-box p {
  margin: 0.5rem 0;
  color: #ff9a9a;
  font-size: 0.9rem;
}

.map-export-group {
  margin: 1.2rem 0;
  display: grid;
  gap: 0.35rem;
}

.map-export-group label {
  font-size: 0.85rem;
  color: #cc6666;
  font-weight: 600;
}

.map-export-group input {
  width: 100%;
  border: 1px solid #cc000055;
  border-radius: 10px;
  background: #0a0000;
  color: #ff9a9a;
  padding: 0.65rem 0.75rem;
  font: inherit;
  font-size: 0.9rem;
}

.map-export-group input:focus {
  outline: 2px solid #ff444466;
  border-color: #ff4444;
}

.map-export-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  margin-top: 1.5rem;
}

.map-export-actions .map-btn {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

@keyframes slideInUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
