/* MCM Map-Editor — standalone styles, do not share with the game UI. */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, sans-serif;
  font-size: 14px;
  background: #1c1f24;
  color: #e6e8eb;
}

#editor-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 8px 12px;
  background: #2a2f37;
  border-bottom: 1px solid #3a3f47;
}

.topbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-group label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #c0c4c8;
}

#editor-topbar input[type="text"],
#editor-topbar input[type="number"],
#editor-topbar select {
  background: #1c1f24;
  color: #e6e8eb;
  border: 1px solid #3a3f47;
  padding: 4px 6px;
  border-radius: 3px;
  font-size: 13px;
}

#editor-topbar input[type="number"] {
  width: 80px;
}

#editor-topbar button {
  background: #3a4560;
  color: #e6e8eb;
  border: 1px solid #4a5570;
  padding: 5px 10px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
}

#editor-topbar button:hover {
  background: #4a5570;
}

#dirty-flag {
  background: #b04040;
  color: #fff;
  padding: 3px 8px;
  border-radius: 3px;
  font-size: 11px;
  text-transform: uppercase;
}

#status-flash {
  background: #2d6a4f;
  color: #d8f3dc;
  padding: 3px 10px;
  border-radius: 3px;
  font-size: 12px;
  margin-right: 8px;
  transition: opacity 0.4s ease;
}

#status-flash.error {
  background: #7a2820;
  color: #f8d7da;
}

#status-flash.fading {
  opacity: 0;
}

/* --- Server-load modal ---------------------------------------------------- */

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

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  background: #23272e;
  border: 1px solid #3a3f47;
  border-radius: 8px;
  min-width: 360px;
  max-width: 480px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
}

.modal-card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #3a3f47;
}

.modal-card > header h3 {
  margin: 0;
  font-size: 14px;
  text-transform: none;
  color: #e6e8eb;
  letter-spacing: 0;
}

.modal-card > header button {
  background: transparent;
  color: #c0c4c8;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.modal-card > header button:hover {
  color: #fff;
}

.server-load-list {
  padding: 8px;
  overflow-y: auto;
}

.server-load-list .server-map-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: #2a2f37;
  border-radius: 4px;
  margin-bottom: 4px;
  cursor: pointer;
  border: 1px solid transparent;
}

.server-load-list .server-map-row:hover {
  background: #3a4560;
  border-color: #4a5570;
}

.server-load-list .server-map-meta {
  font-family: monospace;
  font-size: 11px;
  color: #a0a4a8;
}

.server-load-empty {
  color: #8a8e92;
  font-style: italic;
  text-align: center;
  padding: 20px;
}

.hidden {
  display: none !important;
}

#editor-main {
  display: grid;
  /* 2D-Editor bekommt den Großteil der Breite; das 3D-Preview-Pane sitzt
     als rechtes Sidebar mit fester Mindestbreite (480px) und darf bis zu
     30% der Gesamtbreite einnehmen. So bleibt Platz zum präzisen Editieren
     im 2D-Canvas, ohne dass die 3D-Vorschau auf "Vignettengröße" schrumpft. */
  grid-template-columns: 220px minmax(0, 1fr) clamp(360px, 30vw, 560px);
  grid-template-rows: 1fr 1fr;
  gap: 0;
  height: calc(100vh - 56px);
}

/* When the 3D-Preview toggle is off, collapse the preview column. */
#editor-main.preview-off {
  grid-template-columns: 220px minmax(0, 1fr) 0;
}

#editor-main.preview-off #preview-area {
  display: none;
}

#tools-sidebar {
  grid-column: 1;
  grid-row: 1;
  background: #23272e;
  border-right: 1px solid #3a3f47;
  padding: 12px;
  overflow-y: auto;
}

#props-sidebar {
  grid-column: 1;
  grid-row: 2;
  background: #23272e;
  border-right: 1px solid #3a3f47;
  border-top: 1px solid #3a3f47;
  padding: 12px;
  overflow-y: auto;
}

#canvas-area {
  grid-column: 2;
  grid-row: 1 / span 2;
  position: relative;
  background: #14161a;
  overflow: hidden;
}

#preview-area {
  grid-column: 3;
  grid-row: 1 / span 2;
  position: relative;
  background: #0a0c0f;
  border-left: 1px solid #3a3f47;
  overflow: hidden;
}

#preview-3d-host {
  position: absolute;
  inset: 0;
}

#preview-3d-host canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

#preview-status {
  position: absolute;
  bottom: 6px;
  left: 6px;
  right: 6px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 10px;
  background: rgba(20, 22, 26, 0.78);
  border-radius: 3px;
  font-family: monospace;
  font-size: 11px;
  color: #c0c4c8;
  pointer-events: none;
}

#preview-status #preview-hint {
  color: #6a6f78;
}

#editor-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

#status-bar {
  position: absolute;
  bottom: 6px;
  left: 6px;
  background: rgba(20, 22, 26, 0.7);
  padding: 3px 8px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 12px;
}

h3 {
  margin: 0 0 8px 0;
  font-size: 13px;
  text-transform: uppercase;
  color: #a0a4a8;
  letter-spacing: 0.05em;
}

.tool-list {
  list-style: none;
  padding: 0;
  margin: 0 0 12px 0;
}

.tool-list li {
  margin-bottom: 4px;
}

.tool-list label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 3px;
  cursor: pointer;
}

.tool-list label:hover {
  background: #2f343c;
}

.hint {
  font-size: 11px;
  color: #8a8e92;
  line-height: 1.4;
}

.props-empty {
  color: #8a8e92;
  font-style: italic;
}

#props-content label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  color: #c0c4c8;
}

#props-content input[type="text"],
#props-content input[type="number"],
#props-content input[type="color"] {
  width: 100%;
  background: #1c1f24;
  color: #e6e8eb;
  border: 1px solid #3a3f47;
  padding: 4px 6px;
  border-radius: 3px;
  font-size: 13px;
  margin-top: 2px;
}

#props-content input[type="color"] {
  height: 30px;
  padding: 1px;
}

#props-content button {
  background: #3a4560;
  color: #e6e8eb;
  border: 1px solid #4a5570;
  padding: 4px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  margin-right: 4px;
  margin-top: 4px;
}

#props-content button.danger {
  background: #6b3030;
  border-color: #803a3a;
}

#props-content button:hover {
  filter: brightness(1.15);
}

#props-content .door-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
}

#props-content .door-row input {
  width: 80px;
}

#props-content .doors-section {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #3a3f47;
}

/* Kind library --------------------------------------------------------- */

#kind-library {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kind-pending {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  padding: 6px 8px;
  background: #1c2a3a;
  border: 1px solid #3a4f6a;
  border-radius: 3px;
  font-size: 12px;
}

.kind-pending strong {
  flex: 1;
  font-family: monospace;
}

.kind-pending button {
  background: transparent;
  color: #c0c4c8;
  border: 1px solid #3a4f6a;
  border-radius: 3px;
  padding: 0 6px;
  cursor: pointer;
  line-height: 1.6;
}

.kind-pending button:hover {
  background: #3a4f6a;
}

.kind-category h4 {
  margin: 0 0 4px 0;
  font-size: 11px;
  text-transform: uppercase;
  color: #a0a4a8;
  letter-spacing: 0.05em;
}

.kind-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
}

.kind-tile {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: #1c1f24;
  border: 1px solid #3a3f47;
  border-radius: 3px;
  padding: 4px;
  cursor: pointer;
  font-size: 11px;
  color: #d0d4d8;
  text-align: left;
  font-family: inherit;
}

.kind-tile:hover {
  background: #2a3140;
  border-color: #5a6478;
}

.kind-tile.selected {
  background: #1c2a3a;
  border-color: #6c93c0;
  color: #ffffff;
}

.kind-tile-swatch {
  height: 56px;
  border-radius: 2px;
  margin-bottom: 3px;
  border: 1px solid rgba(0, 0, 0, 0.4);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.kind-tile-swatch--thumb {
  /* sobald ein Mesh-Thumbnail geladen ist, wird der Color-Fill zur dezenten
     Background-Card hinter dem Mesh — Designer sieht trotzdem die
     Kategorie-Farbe am Rand, das Thumbnail dominiert. */
  background-color: rgba(20, 26, 34, 0.55) !important;
}

.kind-tile-name {
  font-family: monospace;
  font-size: 10px;
  color: #c0c4c8;
  word-break: break-all;
}

.kind-tile-meta {
  font-size: 10px;
  color: #7a808a;
}

/* Layer toggles ------------------------------------------------------------ */

.layer-toggles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 6px;
  margin-bottom: 12px;
}

.layer-toggles label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #c0c4c8;
  padding: 2px 4px;
  border-radius: 3px;
  cursor: pointer;
}

.layer-toggles label:hover {
  background: #2f343c;
}

.layer-toggles input[type="checkbox"] {
  margin: 0;
}

/* Validation strip --------------------------------------------------------- */

#status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 12px);
}

.validation-strip {
  color: #fbbf24;
  font-family: monospace;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: help;
  max-width: 60vw;
}

.validation-strip.ok {
  color: #4ade80;
}

.validation-strip.empty {
  color: #5a6478;
}

/* Undo/redo buttons -------------------------------------------------------- */

#editor-topbar button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
