/*
 * Routen-Segment-Viewer – bereinigte Test-CSS
 * Version: v0.12.1-test
 * Basis: CSS v0.12.0 + gelieferter DOM-Baum
 * Ziel: alte angehängte Override-/Versionsreste entfernen und nur aktuelle UI-Struktur stylen.
 */

:root {
  --bg: #111820;
  --panel: #202932;
  --panel2: #121a21;
  --text: #f3f6fb;
  --muted: #b9c4cf;
  --line: rgba(255, 255, 255, 0.14);
  --blue: #2f86ff;
  --green: #19c37d;
  --red: #ef4444;
  --yellow: #f6c445;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.38);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #0d1218;
  color: var(--text);
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
  background: #d6e6c7;
}

.leaflet-container {
  font-family: inherit;
}

/* Hauptdialog oben links */
#topPanel,
.top-panel {
  position: absolute;
  left: 16px;
  top: 16px;
  right: auto;
  bottom: auto;
  z-index: 1000;
  width: min(680px, calc(100vw - 32px));
  max-width: min(680px, calc(100vw - 32px));
  min-width: 320px;
  background: rgba(25, 32, 39, 0.96);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 12px 16px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

#topPanel.minimized,
.top-panel.minimized {
  width: 48px;
  height: 48px;
  min-width: 48px;
  overflow: hidden;
  padding: 0;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

#topPanel.minimized > *:not(.restore-button),
.top-panel.minimized > *:not(.restore-button) {
  display: none;
}

.restore-button {
  display: none;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 999px;
  background: #1e70c7;
  color: #fff;
  font-size: 24px;
  line-height: 48px;
  cursor: pointer;
}

#topPanel.minimized .restore-button,
.top-panel.minimized .restore-button {
  display: block;
}

.top-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

h1,
#topPanel h1,
.top-panel h1 {
  margin: 0;
  padding: 0;
  color: #fff;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.3px;
}

.hint,
#topPanel .hint,
.top-panel .hint {
  margin: 4px 0 0;
  padding: 0;
  color: var(--muted);
  background: none;
  font-size: 12px;
  font-weight: normal;
  line-height: 1.25;
}

.minimize-top {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 4px 10px;
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.minimize-top:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Aktionsleisten und Buttons */
.panel-actions,
.cleaner-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 8px 0 10px;
}

button,
.file-label {
  border: 1px solid rgba(124, 160, 206, 0.42);
  background: #243142;
  color: #f4f7fb;
  border-radius: 13px;
  padding: 8px 14px;
  min-height: 38px;
  font-size: 15px;
  cursor: pointer;
  user-select: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

button:hover,
.file-label:hover {
  background: #2d3b4e;
}

button.primary {
  background: #1e5a8a;
  border-color: #3a8aca;
}

button.good {
  background: #1a5a3a;
  border-color: #2a8a55;
}

button.warn {
  background: #8a5a1a;
  border-color: #ca8a2a;
}

button.small {
  min-height: 0;
  padding: 7px 10px;
  border-radius: 12px;
  font-size: 14px;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.35);
}

.file-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.file-label input {
  display: none;
}

#saveCleanedRouteBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 10px;
  background: #2a3744;
  color: #fff;
  font-size: 12px;
  line-height: 1.1;
  white-space: nowrap;
}

#saveCleanedRouteBtn.ready,
#saveCleanedRouteBtn:not(:disabled) {
  opacity: 1;
  cursor: pointer;
  filter: none;
  box-shadow: 0 0 0 2px rgba(61, 220, 132, 0.25);
}

/* optionale PHP-Zeile: bleibt unterstützt, obwohl phpUrl aktuell hidden ist */
.php-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 8px 0 12px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
}

.php-row label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.php-row input {
  flex: 2;
  min-width: 140px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  padding: 6px 10px;
  font-size: 12px;
}

.status,
#status {
  margin-top: 8px;
  padding: 8px 12px;
  max-height: 60px;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.35;
  white-space: pre-line;
}

/* Drag & Drop / Toast */
.drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  border: 10px dashed rgba(255, 255, 255, 0.55);
  background: rgba(15, 23, 42, 0.62);
  color: #fff;
  font-size: 36px;
  font-weight: 800;
  text-align: center;
}

.drop-overlay.show {
  display: flex;
}

.toast {
  position: absolute;
  left: 50%;
  top: 18px;
  z-index: 3000;
  display: none;
  transform: translateX(-50%);
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(16, 24, 32, 0.92);
  box-shadow: var(--shadow);
  color: #fff;
  font-size: 16px;
}

.toast.show {
  display: block;
}

/* Segment-Info-Panel */
#infoPanel,
.info-panel {
  position: fixed;
  bottom: 0;
  top: auto;
  z-index: 1100;
  display: none;
  width: 1080px;
  overflow: hidden;
  background: rgba(25, 32, 39, 0.96);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  font-size: 13px;
  line-height: 1.16;
}

#infoPanel.show,
.info-panel.show {
  display: block;
}

#infoPanel.minimized,
.info-panel.minimized {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  max-height: 48px;
  right: auto;
  overflow: hidden;
  resize: none;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

#infoPanel.minimized > *:not(.restore-info-button),
.info-panel.minimized > *:not(.restore-info-button) {
  display: none;
}

.restore-info-button {
  display: none;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #1e70c7;
  color: #fff;
  font-size: 24px;
  line-height: 48px;
  cursor: pointer;
}

#infoPanel.minimized .restore-info-button,
.info-panel.minimized .restore-info-button {
  display: block;
}

.info-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  cursor: default;
  user-select: none;
}

.info-title strong {
  font-size: 13px;
}

.info-title span {
  color: var(--muted);
  font-size: 11px;
}

.info-title-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.info-close,
.info-minimize {
  padding: 7px 10px;
  border-radius: 12px;
  font-size: 14px;
}

.segment-strip-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 10px 12px;
}

.segment-strip {
  display: flex;
  align-items: stretch;
  gap: 4px;
  padding-bottom: 4px;
}

.seg-card {
  flex: 0 0 auto;
  width: 350px;
  max-width: 350px; 
  max-height: 58px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.3);
  cursor: pointer;
  opacity: 0.86;
  transition: transform 0.08s ease, background 0.08s ease, border 0.08s ease;
}

.seg-card:hover {
  transform: translateY(-1px);
  border-color: rgba(91, 159, 255, 0.55);
}

.seg-card.active {
  border: 2px solid var(--yellow);
  background: rgba(0, 0, 0, 0.45);
  opacity: 1;
}

.seg-card.neighbor {
  border-color: rgba(255, 255, 255, 0.24);
  opacity: 1;
}

.seg-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 11px;
}

.seg-role {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.seg-no {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.seg-grid {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-top: 6px;
  color: #c7d2dc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.label {
  color: #aab5c1;
  white-space: nowrap;
}

.coord {
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.4);
  color: #f5f7fb;
  white-space: nowrap;
}

.join-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
  color: #d0d8e2;
  font-size: 11px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.pill.warn {
  background: rgba(246, 196, 69, 0.2);
  border-color: rgba(246, 196, 69, 0.35);
}

.pill.bad {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.38);
}

.join-row button {
  min-height: 0;
  padding: 4px 12px;
  border: none;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 11px;
}

/* Kartenlegende */
.legend {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 900;
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  color: var(--muted);
  font-size: 10px;
}

/* Aktive Segmentmarker / Punktreihenfolge */
.active-segment-marker,
.active-point-order-marker {
  width: auto !important;
  height: auto !important;
}

.active-segment-marker .marker-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.36);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.active-segment-marker .marker-badge.start {
  background: #16a34a;
}

.active-segment-marker .marker-badge.end {
  background: #dc2626;
}

.active-segment-marker .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
}

.active-point-order-marker .point-order {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  background: #111827;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.32);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.active-point-order-marker .point-order.first {
  background: #16a34a;
}

.active-point-order-marker .point-order.last {
  background: #dc2626;
}

.active-point-order-marker .point-order.same {
  outline: 3px solid #facc15;
}

.segment-number-label {
  padding: 3px 7px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.segment-direction-warning {
  color: #fde68a;
  font-weight: 800;
}


.gap-highlight-label {
  padding: 3px 7px !important;
  border: 2px solid #111827 !important;
  border-radius: 999px !important;
  background: #ef4444 !important;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.42) !important;
  color: #fff !important;
  font-size: 12px !important;
  font-weight: 900 !important;
}

.gap-highlight-label::before {
  display: none !important;
}



.gap-end-marker,
.gap-start-marker {
  display: grid;
  place-items: center;
  border: 3px solid #ffffff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.42);
  font-weight: 1000;
}

.gap-end-marker {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 28px;
  line-height: 1;
}

.gap-start-marker {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  background: #16a34a;
  color: #ffffff;
  font-size: 10px;
  line-height: 1;
}



.gap-threshold-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid rgba(148, 163, 184, .55);
  border-radius: 16px;
  background: rgba(15, 23, 42, .72);
  color: #e5e7eb;
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
}

.gap-threshold-control input {
  width: 74px;
  padding: 6px 8px;
  border: 1px solid rgba(191, 219, 254, .65);
  border-radius: 10px;
  background: rgba(2, 6, 23, .86);
  color: #ffffff;
  font: inherit;
  text-align: right;
  outline: none;
}

.gap-threshold-control input:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, .24);
}

/* OSM-Ergebnisbox */
.osm-result {
  position: absolute;
  right: 18px;
  top: 86px;
  z-index: 1300;
  display: none;
  width: min(520px, calc(100vw - 36px));
  max-height: calc(100vh - 130px);
  overflow: auto;
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 20px;
  background: rgba(18, 25, 33, 0.96);
  box-shadow: var(--shadow);
  color: #eef5ff;
}

.osm-result.show {
  display: block;
}

.osm-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.osm-result h2 {
  margin: 0 0 8px;
  font-size: 21px;
}

.osm-result .muted {
  color: #aeb9c5;
  font-size: 15px;
}

.osm-result dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  margin: 12px 0 0;
}

.osm-result dt {
  color: #9fb0c2;
}

.osm-result dd {
  margin: 0;
  font-weight: 700;
  word-break: break-word;
}

.osm-result button {
  min-height: 0;
  padding: 7px 10px;
  border-radius: 12px;
  font-size: 15px;
}

.osm-link {
  color: #8ec5ff;
}

/* Vordergrund-Schaltung für Dialoge */
.dialog-front,
.zindex {
  z-index: 9999 !important;
}

.dialog-back {
  z-index: 9000 !important;
}

/* Mobile Anpassung */
@media (max-width: 760px) {
  #topPanel,
  .top-panel {
    left: 8px;
    top: 8px;
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    min-width: 0;
    padding: 10px 12px;
  }

  .top-head {
    align-items: flex-start;
  }

  h1,
  #topPanel h1,
  .top-panel h1 {
    font-size: 18px;
  }

  button,
  .file-label {
    padding: 7px 11px;
    font-size: 14px;
  }

  #infoPanel,
  .info-panel {
    left: 8px;
    right: 8px;
    bottom: 8px;
    max-height: 38vh;
    border-radius: 16px;
  }

  .seg-card {
    width: 300px;
    min-width: 300px;
  }

  .seg-grid {
    flex-direction: column;
  }

  .drop-overlay {
    font-size: 26px;
  }
}
