/* B-Plan-Portal – öffentliche Seiten. Farben/Schrift kommen als CSS-Variablen aus dem Adminbereich. */
html { font-size: var(--bp-size, 16px); }
body { font-family: var(--bp-font); background: var(--bp-bg); color: #212529; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1 0 auto; }
a { color: var(--bp-primary); }
.skip-link { position: absolute; left: 8px; top: 8px; z-index: 2000; background: #fff; padding: 6px 10px; }

.bp-header { background: var(--bp-header); color: var(--bp-header-text); }
.bp-header a { color: var(--bp-header-text); text-decoration: none; }
.bp-title { font-size: 1.35rem; font-weight: 600; }
.bp-subtitle { font-size: .85rem; opacity: .8; }
.bp-logo { max-height: 52px; max-width: 180px; }
.bp-header-link { white-space: nowrap; }
.bp-footer { background: #fff; border-top: 1px solid #dee2e6; font-size: .9rem; }
.bp-footer a { color: #495057; }

.bp-card { background: #fff; border-radius: .5rem; box-shadow: 0 1px 3px rgba(0,0,0,.08); padding: 1.25rem; }
.bp-card > h2:first-child { margin-top: 0; }
.btn-primary, .btn-primary:hover, .btn-primary:focus { background: var(--bp-primary); border-color: var(--bp-primary); }
.btn-outline-primary { color: var(--bp-primary); border-color: var(--bp-primary); }
.btn-outline-primary:hover, .btn-outline-primary.active { background: var(--bp-primary); border-color: var(--bp-primary); color: #fff; }
.btn-accent { background: var(--bp-accent); border-color: var(--bp-accent); color: #212529; font-weight: 600; }
.btn-accent:hover { filter: brightness(.95); }
.nav-pills .nav-link.active { background: var(--bp-primary); }
.nav-pills .nav-link { color: var(--bp-primary); }

/* Ansicht umschalten */
.bp-viewswitch .btn { min-width: 8rem; }

/* Karte */
#map { height: 70vh; min-height: 420px; border-radius: .5rem; z-index: 1; }
.bp-mapwrap { position: relative; }
.leaflet-container { font: inherit; font-size: .9rem; }
.bp-legend { background: rgba(255,255,255,.95); padding: 8px 10px; border-radius: 6px; box-shadow: 0 1px 4px rgba(0,0,0,.3); font-size: .82rem; line-height: 1.5; max-width: 230px; }
.bp-legend i { display: inline-block; width: 16px; height: 12px; margin-right: 6px; vertical-align: -1px; border: 2px solid; }
.bp-legend .dash { border-style: dashed; }
.bp-opacity { background: rgba(255,255,255,.95); padding: 6px 10px; border-radius: 6px; box-shadow: 0 1px 4px rgba(0,0,0,.3); font-size: .82rem; }
.bp-opacity input { width: 140px; vertical-align: middle; }
.bp-popup h3 { font-size: 1rem; margin: 0 0 4px; }
.bp-popup .meta { color: #555; font-size: .85rem; }
.bp-popup img { width: 220px; height: 140px; object-fit: contain; background: #fff; display: block; margin: 6px 0; border: 1px solid #ddd; }
.bp-popup-list { list-style: none; padding: 0; margin: 0; max-height: 260px; overflow: auto; }
.bp-popup-list li { padding: 6px 0; border-bottom: 1px solid #eee; }
.bp-popup-list li:last-child { border-bottom: 0; }
.bp-status { display: inline-block; font-size: .75rem; padding: 1px 7px; border-radius: 10px; color: #fff; white-space: nowrap; }

/* Tabelle */
.bp-table th[data-sort] { cursor: pointer; white-space: nowrap; user-select: none; }
.bp-table th[data-sort]::after { content: ' ↕'; opacity: .35; font-size: .8em; }
.bp-table th.asc::after { content: ' ▲'; opacity: .8; }
.bp-table th.desc::after { content: ' ▼'; opacity: .8; }
.bp-table tr.is-child td:nth-child(2) { padding-left: 1.6rem; }
.bp-table tr.is-child td:nth-child(2)::before { content: '↳ '; color: #999; }
.bp-table tbody tr { cursor: pointer; }
.bp-table tbody tr:hover { background: rgba(0,0,0,.03); }

.bp-hitbar { background: #fff3cd; border: 1px solid #ffe69c; border-radius: .4rem; padding: .5rem .75rem; }

/* Detailseite */
.bp-dl dt { color: #555; font-weight: 600; }
.bp-dl dd { margin-bottom: .6rem; }
.bp-family { list-style: none; padding: 0; margin: 0; }
.bp-family li { padding: .35rem .5rem; border-radius: .3rem; }
.bp-family li.current { background: rgba(0,0,0,.06); font-weight: 600; }
.bp-family li.child { padding-left: 1.5rem; }
.bp-docs a { text-decoration: none; }
.bp-docs .list-group-item:hover { background: #f8f9fa; }
.bp-doc-icon { display: inline-block; min-width: 3rem; font-size: .7rem; font-weight: 700; text-align: center; padding: 3px 4px; border-radius: 3px; background: #6c757d; color: #fff; margin-right: .6rem; }
.bp-doc-icon.pdf { background: #c0392b; }
.bp-doc-icon.img { background: #2980b9; }
.bp-doc-icon.gml, .bp-doc-icon.zip, .bp-doc-icon.xml { background: #16a085; }
#detailmap { height: 340px; border-radius: .5rem; }
.bp-contact { border: 1px solid #e5e5e5; border-radius: .4rem; padding: .75rem; height: 100%; }
.bp-legal { background: #fff; border-left: 4px solid var(--bp-accent); padding: 1rem 1.25rem; border-radius: .3rem; font-size: .92rem; }

/* Plan-Viewer (Zoom/Pan/Vollbild) */
.bp-viewer { position: relative; background: #e9ecef; border-radius: .5rem; overflow: hidden; height: 70vh; min-height: 420px; }
.bp-viewer #planviewer { position: absolute; inset: 0; background: #e9ecef; }
.bp-viewer .bp-viewer-tools { position: absolute; top: 10px; right: 10px; z-index: 1000; display: flex; gap: 6px; }
.bp-viewer .bp-viewer-tools .btn { box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.bp-viewer .bp-viewer-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 900; color: #555; text-align: center; padding: 2rem; }
.bp-viewer:fullscreen { height: 100vh; border-radius: 0; }
.bp-viewer.pseudo-full { position: fixed; inset: 0; height: 100vh; z-index: 3000; border-radius: 0; }
.bp-pdfpages { position: absolute; left: 10px; top: 10px; z-index: 1000; }

@media (max-width: 575px) {
  #map { height: 60vh; }
  .bp-title { font-size: 1.1rem; }
}
@media print {
  .bp-header, .bp-footer, .bp-viewer-tools, .no-print { display: none !important; }
}

/* Autovervollständigung */
.bp-ac { position: relative; }
.bp-ac-list { position: absolute; z-index: 1050; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: 4px 0; list-style: none;
  background: #fff; border: 1px solid #ced4da; border-radius: .375rem; box-shadow: 0 6px 16px rgba(0,0,0,.15); max-height: 300px; overflow-y: auto; }
.bp-ac-list li { padding: .45rem .75rem; cursor: pointer; }
.bp-ac-list li[aria-selected="true"], .bp-ac-list li:hover { background: var(--bp-primary); color: #fff; }
.bp-ac-list li mark { background: none; padding: 0; font-weight: 700; color: inherit; }
.bp-ac-list .bp-ac-empty { color: #6c757d; cursor: default; font-size: .9em; }
.bp-ac-list .bp-ac-empty:hover { background: none; color: #6c757d; }
.bp-hint-link { cursor: pointer; text-decoration: underline; }

/* Lagekarte: Flächen zeigen Tooltip, sind aber kein Link */
.leaflet-interactive.bp-nolink { cursor: grab; }
.leaflet-dragging .leaflet-interactive.bp-nolink { cursor: grabbing; }

/* Startseite: Plansuche, Reiter, Statusauswahl, Treffer */
.bp-ac-plans { max-height: 380px; }
.bp-ac-plans li { padding: .5rem .75rem; border-bottom: 1px solid #f1f1f1; }
.bp-ac-plans li .bp-status { border: 1px solid rgba(255,255,255,.6); }
.bp-searchtabs .nav-link { color: var(--bp-primary); }
.bp-searchtabs .nav-link.active { font-weight: 600; color: #212529; }
.bp-statusfilter label { cursor: pointer; margin: 0; white-space: nowrap; }
.bp-statusfilter input { margin-right: 4px; vertical-align: -1px; }
.bp-hit-row td { background: #fff3cd !important; }
.bp-flash td { animation: bpflash 1.6s ease; }
@keyframes bpflash { 0%, 60% { background: #ffe08a; } 100% { background: transparent; } }

/* ===== Startseite als Kartenanwendung (Seitenleiste + Karte über volle Höhe) ===== */
.bp-app { display: flex; height: calc(100vh - var(--bp-hdr, 64px)); min-height: 480px; position: relative; padding: 0; }
.bp-side { position: relative; flex: 0 0 360px; width: 360px; background: #fff; border-right: 1px solid #dee2e6; z-index: 500;
  transition: margin-left .25s ease; box-shadow: 2px 0 6px rgba(0,0,0,.06); }
.bp-side-inner { height: 100%; overflow-y: auto; padding: 1rem 1rem 1.5rem; }
.bp-app.side-closed .bp-side { margin-left: -360px; }
.bp-side-toggle { position: absolute; top: 12px; right: 0; transform: translateX(100%); min-width: 30px; height: 44px; border: 1px solid #dee2e6; border-left: 0;
  background: #fff; border-radius: 0 6px 6px 0; box-shadow: 2px 1px 4px rgba(0,0,0,.12); font-size: 1.4rem; line-height: 1; color: var(--bp-primary); cursor: pointer; padding: 0 6px;
  display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.bp-side-toggle:hover { background: #f8f9fa; }
/* Eingeklappt: deutlich als "Suche" beschriftet */
.bp-app.side-closed .bp-side-toggle { padding: 0 12px 0 8px; font-weight: 600; background: var(--bp-primary); color: #fff; border-color: var(--bp-primary); }
.bp-app.side-closed .bp-side-toggle-text { display: inline; font-size: .95rem; }
.bp-app.side-closed .bp-side-toggle-icon { display: inline-block; transform: rotate(180deg); }
.bp-mainview { flex: 1 1 auto; min-width: 0; position: relative; }
.bp-side-toggle-text { display: none; font-size: .9rem; }
.bp-view { position: absolute; inset: 0; }
.bp-view-list { overflow-y: auto; background: var(--bp-bg); }
.bp-app #map { height: 100%; min-height: 0; border-radius: 0; }
.bp-side .bp-hitbar { font-size: .9rem; }
.bp-side-legal summary { cursor: pointer; font-size: .9rem; color: #555; }
.bp-side .bp-ac-plans { max-height: 60vh; }
.bp-app .leaflet-top.leaflet-left { margin-left: 36px; } /* Platz für den Klapp-Knopf */
.bp-app.side-closed .leaflet-top.leaflet-left { margin-left: 112px; }
@media (max-width: 767px) {
  .bp-app { flex-direction: column; height: auto; }
  .bp-side { flex: none; width: 100%; margin-left: 0 !important; border-right: 0; border-bottom: 1px solid #dee2e6; }
  .bp-side-inner { max-height: none; }
  .bp-app.side-closed .bp-side-inner { display: none; }
  .bp-side-toggle { position: static; transform: none; width: 100%; height: 36px; border: 0; border-top: 1px solid #eee; border-radius: 0; box-shadow: none; font-size: 1rem; justify-content: center; }
  .bp-app.side-closed .bp-side-toggle { padding: 0; }
  .bp-app.side-closed .leaflet-top.leaflet-left { margin-left: 0; }
  .bp-side-toggle-icon { display: inline-block; transform: rotate(90deg); }
  .bp-side-toggle-text { display: inline; }
  .bp-app.side-closed .bp-side-toggle-icon { transform: rotate(-90deg); }
  .bp-mainview { height: 70vh; }
  .bp-app .leaflet-top.leaflet-left { margin-left: 0; }
}
