/* ═══════════════════════════════════════════
   DM-Faver – Verkehrszeichenplan (VZ-Plan)
   ═══════════════════════════════════════════ */

/* ─── Vollbild-Editor ─── */
#vz-editor {
  position: fixed; inset: 0; z-index: 900;
  background: var(--bg-900);
  display: none; grid-template-rows: auto 1fr;
  grid-template-columns: 268px 1fr 250px;
  grid-template-areas: "bar bar bar" "cat map insp";
}
#vz-editor.open { display: grid; }

/* ─── Werkzeugleiste ─── */
.vz-bar {
  grid-area: bar;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--bg-800);
  border-bottom: 1px solid var(--bg-500);
}
.vz-bar .vz-title-in {
  background: var(--bg-700); border: 1px solid var(--bg-500); border-radius: var(--r);
  color: var(--text-100); font-size: .9rem; font-weight: 600; padding: 8px 12px; min-width: 200px;
}
.vz-bar select, .vz-bar input[type="text"], .vz-bar input[type="search"] {
  background: var(--bg-700); border: 1px solid var(--bg-500); border-radius: var(--r);
  color: var(--text-200); font-size: .82rem; padding: 8px 10px; font-family: var(--font);
}
.vz-bar .sep { width: 1px; height: 26px; background: var(--bg-500); margin: 0 2px; }
.vz-bar .spacer { flex: 1; }

.vz-tool {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-700); border: 1px solid var(--bg-500); border-radius: var(--r);
  color: var(--text-300); font-size: .8rem; font-family: var(--font);
  padding: 8px 11px; cursor: pointer; transition: var(--transition); white-space: nowrap;
}
.vz-tool:hover { background: var(--bg-600); color: var(--text-100); }
.vz-tool.active { background: var(--accent-glow); border-color: var(--accent-dim); color: var(--accent); font-weight: 600; }

/* ─── Schilderkatalog ─── */
.vz-cat {
  grid-area: cat; background: var(--bg-800); border-right: 1px solid var(--bg-500);
  display: flex; flex-direction: column; overflow: hidden;
}
.vz-cat-search { padding: 10px; border-bottom: 1px solid var(--bg-500); }
.vz-cat-search input {
  width: 100%; background: var(--bg-700); border: 1px solid var(--bg-500);
  border-radius: var(--r); color: var(--text-200); padding: 9px 11px; font-size: .84rem; font-family: var(--font);
}
.vz-cat-scroll { flex: 1; overflow-y: auto; padding: 6px 10px 40px; }
.vz-cat-group { margin-bottom: 4px; }
.vz-cat-head {
  display: flex; align-items: center; gap: 7px; width: 100%;
  padding: 9px 6px; cursor: pointer; user-select: none;
  font-size: .74rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-400); background: none; border: 0; font-family: var(--font);
}
.vz-cat-head:hover { color: var(--text-200); }
.vz-cat-head .chev { margin-left: auto; transition: transform var(--transition); font-size: .7rem; }
.vz-cat-group.collapsed .chev { transform: rotate(-90deg); }
.vz-cat-group.collapsed .vz-cat-grid { display: none; }
.vz-cat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 2px 0 10px; }

.vz-chip {
  background: var(--bg-700); border: 1px solid var(--bg-500); border-radius: 8px;
  padding: 6px 4px 5px; cursor: grab; text-align: center; transition: var(--transition);
}
.vz-chip:hover { border-color: var(--accent-dim); background: var(--bg-600); transform: translateY(-1px); }
.vz-chip.armed { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.vz-chip .thumb {
  height: 40px; display: flex; align-items: center; justify-content: center; margin-bottom: 4px;
  pointer-events: none;
}
.vz-chip .thumb svg, .vz-chip .thumb img { max-width: 100%; max-height: 40px; }
.vz-chip .code {
  font-family: var(--mono); font-size: .58rem; color: var(--text-400);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none;
}
.vz-cat-empty { padding: 24px 10px; text-align: center; color: var(--text-400); font-size: .82rem; }

/* ─── Karte ─── */
.vz-map-wrap { grid-area: map; position: relative; background: var(--bg-700); }
#vz-map { position: absolute; inset: 0; background: #e8e6e1; }
#vz-map.placing { cursor: crosshair; }

/* Adress-Suche über der Karte */
.vz-search {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 620; width: min(430px, 70%);
}
.vz-search input {
  width: 100%; padding: 10px 14px; border-radius: 22px; font-size: .85rem; font-family: var(--font);
  border: 1px solid rgba(0,0,0,.2); background: rgba(255,255,255,.96); color: #18181b;
  box-shadow: 0 3px 14px rgba(0,0,0,.3);
}
.vz-search-res {
  margin-top: 5px; background: #fff; border-radius: 10px; overflow: hidden;
  box-shadow: 0 6px 22px rgba(0,0,0,.35); display: none;
}
.vz-search-res.open { display: block; }
.vz-search-res div {
  padding: 9px 13px; font-size: .8rem; color: #27272a; cursor: pointer; border-bottom: 1px solid #eee;
}
.vz-search-res div:hover { background: #f4f4f5; }
.vz-search-res div:last-child { border-bottom: 0; }

/* Hinweisbanner beim Platzieren */
.vz-hint {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 620;
  background: rgba(24,24,27,.94); color: #fafafa; border: 1px solid var(--bg-400);
  padding: 8px 16px; border-radius: 20px; font-size: .8rem; box-shadow: var(--shadow);
  display: none; pointer-events: none; white-space: nowrap;
}
.vz-hint.show { display: block; }

/* ─── Platzierte Zeichen auf der Karte ─── */
.vz-obj { background: none !important; border: 0 !important; }
.vz-obj .rot { transform-origin: 50% 50%; }
.vz-obj .body {
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.45));
  display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.vz-obj .body svg, .vz-obj .body img { display: block; width: 100%; height: auto; }
.vz-obj .zz { width: 100%; }
.vz-obj .pole {
  width: 3px; background: #3f3f46; margin: 0 auto; border-radius: 1px;
}
.vz-obj .lbl {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: -17px; white-space: nowrap;
  font: 700 10px var(--font); color: #18181b;
  background: rgba(255,255,255,.88); padding: 1px 5px; border-radius: 4px;
}
.vz-obj.selected .body {
  outline: 2px dashed var(--accent); outline-offset: 3px; border-radius: 3px;
}
.vz-obj .num {
  position: absolute; top: -9px; left: -9px;
  width: 17px; height: 17px; border-radius: 50%;
  background: var(--accent); color: #18181b;
  font: 700 10px var(--font); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
}

/* Text-Objekte */
.vz-text-obj {
  font: 700 13px var(--font); color: #18181b; background: rgba(255,255,255,.9);
  border: 1px solid rgba(0,0,0,.35); border-radius: 4px; padding: 3px 7px; white-space: pre;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.vz-text-obj.selected { outline: 2px dashed var(--accent); outline-offset: 2px; }

/* Maßangabe an Linien */
.vz-measure-lbl {
  font: 700 11px var(--mono); color: #18181b; background: rgba(255,255,255,.92);
  border: 1px solid rgba(0,0,0,.3); border-radius: 3px; padding: 1px 5px; white-space: nowrap;
}

/* ─── Inspektor ─── */
.vz-insp {
  grid-area: insp; background: var(--bg-800); border-left: 1px solid var(--bg-500);
  overflow-y: auto; padding: 14px 13px 40px;
}
.vz-insp h3 {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-400); margin-bottom: 10px; font-weight: 700;
}
.vz-insp .none { color: var(--text-400); font-size: .82rem; line-height: 1.6; }
.vz-insp .prev {
  background: #fff; border-radius: 8px; padding: 10px; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: center; min-height: 74px;
}
.vz-insp .prev svg, .vz-insp .prev img { max-height: 68px; max-width: 100%; }
.vz-fg { margin-bottom: 11px; }
.vz-fg label {
  display: block; font-size: .72rem; color: var(--text-400); margin-bottom: 4px; font-weight: 600;
}
.vz-fg input[type="text"], .vz-fg input[type="number"], .vz-fg select, .vz-fg textarea {
  width: 100%; background: var(--bg-700); border: 1px solid var(--bg-500); border-radius: 8px;
  color: var(--text-200); padding: 8px 10px; font-size: .82rem; font-family: var(--font);
}
.vz-fg textarea { resize: vertical; min-height: 54px; }
.vz-fg input[type="range"] { width: 100%; accent-color: var(--accent); }
.vz-fg .rowv { display: flex; align-items: center; gap: 8px; }
.vz-fg .rowv output { font-family: var(--mono); font-size: .76rem; color: var(--text-300); min-width: 44px; text-align: right; }
.vz-rot-quick { display: flex; gap: 4px; margin-top: 5px; }
.vz-rot-quick button {
  flex: 1; background: var(--bg-700); border: 1px solid var(--bg-500); border-radius: 6px;
  color: var(--text-300); font-size: .7rem; padding: 5px 0; cursor: pointer; font-family: var(--font);
}
.vz-rot-quick button:hover { background: var(--bg-600); color: var(--text-100); }
.vz-insp-actions { display: flex; gap: 6px; margin-top: 14px; }

/* ─── Plankopf / Legende (auch im Druck) ─── */
.vz-plankopf {
  position: absolute; right: 10px; bottom: 10px; z-index: 610;
  width: 268px; background: #fff; color: #18181b;
  border: 1.5px solid #18181b; border-radius: 3px;
  font: 400 10.5px var(--font); box-shadow: 0 3px 14px rgba(0,0,0,.35);
}
.vz-plankopf .pk-h {
  background: #18181b; color: #fff; padding: 5px 9px; font-weight: 700; font-size: 11px;
  display: flex; justify-content: space-between; align-items: center;
}
.vz-plankopf .pk-row { display: flex; border-top: 1px solid #d4d4d8; }
.vz-plankopf .pk-row span:first-child { width: 82px; padding: 3px 8px; color: #52525b; flex: none; }
.vz-plankopf .pk-row span:last-child { padding: 3px 8px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.vz-legend { border-top: 1.5px solid #18181b; padding: 6px 8px; max-height: 210px; overflow: auto; }
.vz-legend .lg-t { font-weight: 700; font-size: 10px; margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }
.vz-legend .lg-i { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.vz-legend .lg-i .n {
  width: 15px; height: 15px; border-radius: 50%; background: #18181b; color: #fff; flex: none;
  font: 700 9px var(--font); display: flex; align-items: center; justify-content: center;
}
.vz-legend .lg-i .s { width: 22px; height: 22px; flex: none; display: flex; align-items: center; justify-content: center; }
.vz-legend .lg-i .s svg, .vz-legend .lg-i .s img { max-width: 22px; max-height: 22px; }
.vz-legend .lg-i .x { font-size: 9.5px; line-height: 1.2; overflow: hidden; }
.vz-legend .lg-i .x b { display: block; font-family: var(--mono); font-size: 9px; }

/* Nordpfeil */
.vz-north {
  position: absolute; right: 12px; top: 12px; z-index: 610;
  width: 42px; height: 52px; background: rgba(255,255,255,.9); border-radius: 5px;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.vz-north svg { width: 30px; height: 42px; }

/* ─── Panel-Liste (Übersicht) ─── */
.vz-list-empty { text-align: center; padding: 48px 20px; color: var(--text-400); }
.vz-list-empty .icon { font-size: 2.5rem; margin-bottom: 12px; opacity: .5; }

/* ─── Mobile ─── */
@media (max-width: 900px) {
  #vz-editor { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr auto;
                grid-template-areas: "bar" "cat" "map" "insp"; }
  .vz-cat { border-right: 0; border-bottom: 1px solid var(--bg-500); max-height: 168px; }
  .vz-cat-grid { grid-template-columns: repeat(6, 1fr); }
  .vz-insp { border-left: 0; border-top: 1px solid var(--bg-500); max-height: 210px; padding-bottom: 14px; }
  .vz-plankopf { display: none; }
}

/* ═══ Druck / PDF (A4 quer) ═══ */
@media print {
  @page { size: A4 landscape; margin: 8mm; }
  body { background: #fff !important; }
  #app, #login-screen, #toast, .modal-overlay, .agent-overlay { display: none !important; }
  #vz-editor.open {
    display: block !important; position: static; inset: auto;
    background: #fff; width: 100%; height: auto;
  }
  .vz-bar, .vz-cat, .vz-insp, .vz-search, .vz-hint,
  .leaflet-control-zoom, .leaflet-control-attribution, .leaflet-control-layers { display: none !important; }
  .vz-map-wrap { position: relative !important; width: 100%; height: 185mm; page-break-inside: avoid; }
  #vz-map { position: absolute !important; inset: 0; border: 1px solid #18181b; }
  .vz-plankopf { display: block !important; box-shadow: none; width: 290px; }
  .vz-legend { max-height: none; overflow: visible; }
  .vz-obj .body { filter: none; }
  .vz-obj.selected .body { outline: 0; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}
