/* ===== SIDEBAR STYLES - SGDN Style ===== */

.sidebar {
    width: var(--sidebar-width, 320px);
    min-width: var(--sidebar-min-width, 280px);
    max-width: var(--sidebar-max-width, 500px);
    background: #fff;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 1500;
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.15);
    margin: 0;
    padding: 0;
    pointer-events: auto;
    transform: translateX(0);
}

.sidebar.closed {
    transform: translateX(-100%);
    pointer-events: none;
}

/* Wenn Sidebar geschlossen ist, sollen auch alle Kindelemente keine Events blockieren */
.sidebar.closed * {
    pointer-events: none;
}

/* Resize Handle */
.sidebar-resize-handle {
    position: absolute;
    top: 0;
    right: -3px;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    background: transparent;
    z-index: 101;
    /* Touch-Unterstützung */
    touch-action: none;
    /* Wichtig: Handle muss immer Events empfangen können */
    pointer-events: auto !important;
}

.sidebar-resize-handle:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* Größerer Touch-Bereich für Mobile */
@media (max-width: 768px) {
    .sidebar-resize-handle {
        width: 12px;
        right: -6px;
    }
}

.sidebar-resize-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 20px;
    background: #ccc;
    border-radius: 1px;
}

.sidebar-resize-handle:hover::after {
    background: #999;
}

.sidebar-header {
    padding: 10px 15px;
    background: var(--primary-color);
    flex-shrink: 0;
    margin: 0;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 14px;
    color: #fff;
    font-weight: 600;
    margin: 0;
    line-height: 26px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Panel Header Actions */
.panel-header-actions {
    display: flex;
    gap: 6px;
}

/* Search Toggle Button */
.search-toggle-btn {
    width: 26px;
    height: 26px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.search-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.search-toggle-btn.active {
    background: rgba(255, 255, 255, 0.4);
}

/* Layer Search Container - immer sichtbar im Layer-Tab */
.layer-search-container {
    /* Flex-Zeile: Suchfeld dehnbar, Baum-Buttons rechts daneben */
    display: flex;
    align-items: center;
    gap: 2px;
    position: relative;
    margin: 0;
    padding: 10px;
    background: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
}

/* Layer Search Input (wie sgdn_3d #layerSearchInput) */
.layer-search {
    width: 100%;
    padding: 8px 32px 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.layer-search:focus {
    border-color: var(--primary-color);
}

.layer-search::placeholder {
    color: #999;
}

/* Search Clear Button (wie sgdn_3d #layerSearchClear) */
.layer-search-field {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
}

.search-clear-btn {
    position: absolute;
    /* relativ zum Suchfeld, nicht zur Zeile — vertraegt die Buttons daneben */
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #999;
    font-size: 12px;
    display: none;
    transition: color 0.2s;
}

.search-clear-btn.visible {
    display: block;
}

.search-clear-btn:hover {
    color: #666;
}

/* Search Highlight */
.layer-search-highlight {
    background: #ffeb3b;
    color: #000;
    font-weight: 600;
    padding: 1px 2px;
    border-radius: 2px;
}

/* Search Hidden Elements */
.search-hidden {
    display: none !important;
}

/* Search Match Styling */
.search-match > .layer-group-header,
.search-match.layer-item {
    background: rgba(255, 235, 59, 0.1);
}

/* X-Button zum Schließen der Sidebar */
.sidebar-close-btn {
    width: 26px;
    height: 26px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.sidebar-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Close Button Icon */
.sidebar-close-btn .close-icon {
    font-size: 14px;
    line-height: 1;
}

/* Mobile: Close Button etwas größer für Touch */
@media (max-width: 768px) {
    .sidebar-close-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
}

/* Tab Content Container - muss immer Flex sein für korrektes Scrolling */
.sidebar-tab-content {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.sidebar-tab-content.active {
    display: flex;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
    margin: 0;
    padding-bottom: 100px;
}

/* ===== BASEMAP SELECTOR ===== */

#basemap-selector {
    padding: 8px 12px;
    background: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
}

#basemap-selector:empty {
    display: none;
}

.basemap-selector-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #666;
    margin-bottom: 4px;
}

.basemap-selector-select {
    width: 100%;
    padding: 6px 28px 6px 8px;
    font-size: 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E") no-repeat right 8px center;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    cursor: pointer;
    color: #333;
}

.basemap-selector-select:focus {
    outline: none;
    border-color: var(--primary-color, #007acc);
    box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.12);
}

/* Basemap Opacity Wrap */
.basemap-opacity-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    min-width: 0;
}

/* Basemap Opacity Slider */
.basemap-opacity-slider {
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: #ccc;
    outline: none;
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.basemap-opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary-color, #007acc);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.basemap-opacity-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary-color, #007acc);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.basemap-opacity-slider::-webkit-slider-thumb:hover {
    background: var(--primary-hover, #005a9e);
    transform: scale(1.1);
}

.basemap-opacity-slider::-moz-range-thumb:hover {
    background: var(--primary-hover, #005a9e);
    transform: scale(1.1);
}

/* Basemap Info Button */
.basemap-info-btn {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 0 2px;
    font-size: 14px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.2s;
}

.basemap-info-btn:hover {
    color: var(--primary-color, #007acc);
}

/* ===== LAYER TREE STYLES ===== */

#layer-tree {
    font-size: 12px;
    margin: 0; /* Explizit margin entfernen */
    padding: 0; /* Explizit padding entfernen */
}

/* Layer Groups */
.layer-group {
    margin-bottom: 2px;
}

.layer-group-header {
    display: flex;
    align-items: center;
    padding: 6px 6px;
    background: #f5f5f5;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s ease;
    user-select: none;
}

.layer-group-header:hover {
    background: #eee;
}

/* Auf-/Zuklapp-Knopf (seit 26.10.2026 ein <button> statt eines <i>, Barrierefreiheit).
   Sieht aus wie vorher; gedreht wird nur das Icon, damit der Fokusrahmen gerade bleibt. */
.layer-group-toggle {
    width: 16px;
    font-size: 10px;
    color: #666;
    margin-right: 6px;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    line-height: 1;
    flex-shrink: 0;
}

.layer-group-toggle > i {
    transition: transform 0.2s ease;
}

.layer-group-toggle:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
    border-radius: 2px;
}

.layer-group.collapsed .layer-group-toggle > i {
    transform: rotate(-90deg);
}

/* Checkboxes und Radio-Buttons */
.group-checkbox,
.layer-checkbox,
.layer-radio {
    width: 14px;
    height: 14px;
    margin: 0;
    margin-right: 6px;
    cursor: pointer;
    accent-color: var(--primary-color);
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    outline: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.group-checkbox:focus,
.layer-checkbox:focus,
.layer-radio:focus {
    outline: none;
    box-shadow: none;
}

.group-checkbox:indeterminate {
    accent-color: var(--primary-color);
}

.group-checkbox:checked,
.layer-checkbox:checked,
.layer-radio:checked {
    accent-color: var(--primary-color);
}

/* Icons - erweitert für Bilder und FontAwesome */
.folder-icon,
.layer-icon {
    margin-right: 8px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Ordner-Icons */
.folder-icon {
    font-size: 12px;
    color: var(--primary-color);
    margin-right: 6px;
    width: 16px;
    text-align: center;
}

/* Layer-Icons (16x16px wie sgdn_3d) */
.layer-icon {
    width: 16px;
    height: 16px;
    font-size: 12px; /* Für FontAwesome Icons */
    color: #bbb;
    margin-right: 6px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Bild-Icons */
.layer-icon img {
    width: 16px;
    height: 16px;
    object-fit: contain;
    border-radius: 2px;
}

/* Fallback-Icon für Layer ohne Bild */
.layer-icon-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Resize-Cursor für gesamten Body während Resize */
body.resizing {
    cursor: col-resize;
    user-select: none;
}

/* Ordner-Icon Wechsel zwischen offen/geschlossen (nur für FontAwesome) */
.layer-group:not(.collapsed) .folder-icon::before {
    content: "\f07c"; /* fa-folder-open */
    color: var(--primary-color);
}

.layer-group.collapsed .folder-icon::before {
    content: "\f07b"; /* fa-folder */
    color: var(--primary-color);
}

/* Layer Farb-Indikatoren (wie sgdn_3d) */
.lt-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.15);
}

.lt-color-polygon {
    width: 12px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
    margin-right: 8px;
    flex-shrink: 0;
    border: 2px solid;
}

.lt-color-line {
    width: 14px;
    height: 3px;
    border-radius: 1px;
    display: inline-block;
    margin-right: 8px;
    flex-shrink: 0;
}

.lt-legend-icon {
    width: 16px;
    height: 16px;
    margin-right: 6px;
    flex-shrink: 0;
    object-fit: contain;
}

.lt-legend-icon-crop {
    width: 16px;
    height: 16px;
    margin-right: 6px;
    flex-shrink: 0;
    overflow: hidden;
    display: inline-block;
}

.lt-legend-icon-crop img {
    height: 16px;
    width: auto;
}

/* Rechteckiges Legenden-Feld (30x15) für die dynamische Legende:
   Das linke Farbfeld eines GetLegendGraphic wird auf ein Rechteck gedehnt,
   der Beschriftungstext rechts wird von der Box abgeschnitten.
   Zweistufig: innen quadratischer Zuschnitt aufs Farbfeld, außen 2x horizontal
   gedehnt -> 30x15. (Punktsymbole nutzen weiter .lt-legend-icon-crop.) */
.legend-icon-rect {
    display: inline-block;
    width: 30px;
    height: 15px;
    margin-right: 6px;
    flex-shrink: 0;
    overflow: hidden;
    vertical-align: middle;
}

.legend-icon-rect > span {
    display: block;
    width: 15px;
    height: 15px;
    overflow: hidden;
    transform: scaleX(2);
    transform-origin: left center;
}

.legend-icon-rect img {
    display: block;
    height: 15px;
    width: auto;
}

/* Baum-Variante: gleiche 16px-Icon-Box wie .lt-legend-icon (ALKIS/Mapserver),
   damit WMS-Symbole im Ebenenbaum NICHT größer sind als die Mapserver-Symbole.
   Farbfeld wird zugeschnitten (Text ab) und auf ein 16x8-Rechteck gedehnt,
   vertikal zentriert (wie object-fit:contain der Mapserver-Icons). */
.lt-legend-icon-rect {
    display: inline-flex;
    align-items: center;
    width: 16px;
    height: 16px;
    margin-right: 6px;
    flex-shrink: 0;
    overflow: hidden;
}

.lt-legend-icon-rect > span {
    display: block;
    width: 8px;
    height: 8px;
    overflow: hidden;
    transform: scaleX(2);
    transform-origin: left center;
}

.lt-legend-icon-rect img {
    display: block;
    height: 8px;
    width: auto;
}

/* Group Names */
.group-name {
    font-size: 12px;
    font-weight: 500;
    color: #333;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Gruppen-Inhalt */
.layer-group-content {
    padding-left: 20px;
    margin-top: 2px;
    border-left: 1px solid #ddd;
    margin-left: 10px;
}


.layer-group.collapsed .layer-group-content {
    display: none;
}

/* Verschachtelung: Der Unterordner wird so weit nach links gezogen, dass seine
   Checkbox exakt auf der Checkbox-Spalte seiner Geschwister-Ebenen sitzt (der
   Auf-/Zuklapp-Pfeil steht dann im linken Gutter — klassischer Baum-Look).
   Rechnung: Layer-Checkbox = 6px (padding .layer-item-main); Ordner-Checkbox =
   margin + 6px (Header-padding) + 22px (Toggle 16 + margin-right 6). Gleichsetzen
   -> margin = 6 - 28 = -22px. Die Ebenen-Einrückung selbst bleibt unberührt. */
.layer-group .layer-group {
    margin-left: -22px;
}

.layer-group .layer-group > .layer-group-header {
    background: #fafafa;
}

.layer-group .layer-group .layer-group > .layer-group-header {
    background: #fff;
}

/* Layer Items (wie sgdn_3d .lt-layer) */
.layer-item {
    margin: 2px 0;
    display: flex;
    align-items: center;
    position: relative;
}

/* Klassen im Ebenenbaum (ui.layerTree.showClasses, ui-manager.js loadLayerClasses).
   Der Pfeil liegt links im Einrückungsabstand (negativer Rand), damit die Checkboxen
   aller Ebenen bündig bleiben; die Klassenliste bricht als eigene Zeile darunter um. */
.layer-item.has-classes {
    flex-wrap: wrap;
}

.layer-classes-toggle {
    background: none;
    border: none;
    padding: 0;
    width: 14px;
    margin-left: -14px;
    flex: 0 0 14px;
    color: #888;
    font-size: 12px;
    cursor: pointer;
    line-height: 1;
}

.layer-classes-toggle i {
    transition: transform 0.15s;
}

.layer-classes-toggle.open i {
    transform: rotate(90deg);
}

.layer-classes-toggle:hover {
    color: var(--primary-color, #007acc);
}

.layer-classes {
    flex: 0 0 100%;
    padding: 0 0 4px 30px;   /* eingerückt bis unter den Ebenennamen */
}

.layer-class-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 1px 0;
    font-size: 11px;
    color: #444;
    min-width: 0;
}

.layer-class-icon {
    flex: 0 0 auto;
    width: 30px;
    height: 15px;
    object-fit: contain;
}

.layer-class-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.layer-class-info {
    color: #888;
    font-style: italic;
}

/* Layer-Item Hauptbereich (wie sgdn_3d .lt-layer-main) */
.layer-item-main {
    display: flex;
    align-items: center;
    padding: 4px 6px;
    border-radius: 2px;
    transition: background 0.15s ease;
    flex: 1;
    /* min-width: 0 ist Pflicht damit Flex-Kinder mit overflow:hidden tatsächlich
       schrumpfen. Sonst übernimmt der intrinsische Content-Width den Vorrang,
       lange Layer-Namen schieben den Container nach rechts und drücken die
       Buttons (Transparenz, Zoom, Info, etc.) aus dem sichtbaren Bereich. */
    min-width: 0;
    cursor: pointer;
    /* Touch-Optimierung */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.layer-item-main:hover {
    background: #f0f0f0;
}

/* Layer Controls Container */
.layer-controls {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.2s;
}

.layer-item:hover .layer-controls {
    opacity: 1;
}

/* Layer Settings Control (Zahnrad) */
.layer-settings-control {
    position: relative;
    flex-shrink: 0;
}

.layer-settings-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 3px 5px;
    border-radius: 3px;
    transition: all 0.2s;
    color: #999;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
}

.layer-settings-btn:hover {
    background-color: rgba(var(--primary-color-rgb, 0, 122, 204), 0.1);
    color: var(--primary-color, #007acc);
}

/* Layer Metadata Control (Info) */
.layer-metadata-control {
    flex-shrink: 0;
}

.layer-metadata-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 3px 5px;
    border-radius: 3px;
    transition: all 0.2s;
    color: #999;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
}

.layer-metadata-btn:hover {
    background-color: rgba(var(--primary-color-rgb, 0, 122, 204), 0.1);
    color: var(--primary-color, #007acc);
}

/* Layer Timeline Control (Film-Icon) — links neben dem Layer-Namen,
   immer sichtbar, da Feature-Hinweis für zeitbezogene Layer. */
.layer-timeline-control {
    flex-shrink: 0;
    opacity: 1;
    margin-right: 2px;
}

.layer-timeline-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 3px 5px;
    border-radius: 3px;
    transition: all 0.2s;
    color: #f59e0b;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
}

.layer-timeline-btn:hover {
    background-color: rgba(245, 158, 11, 0.12);
    color: #d97706;
}

/* Settings Panel */
.layer-settings-panel {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 1000;
    display: none;
    width: 220px;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    white-space: nowrap;
}

.layer-settings-panel.active {
    display: block;
}

/* Klappt nach oben, wenn unten der Platz nicht reicht (Footer-Kollision) */
.layer-settings-panel.flip-up {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 4px;
}

.settings-section {
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
}

.settings-section:last-child {
    border-bottom: none;
}

/* Kontextmenü im Zahnrad-Panel (Auf Layer zoomen, Attributtabelle) */
.layer-menu-section {
    padding: 4px 0;
}

.layer-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 12px;
    background: none;
    border: none;
    text-align: left;
    font-size: 12px;
    color: #333;
    cursor: pointer;
}

.layer-menu-item i {
    width: 14px;
    text-align: center;
    color: #666;
}

.layer-menu-item:hover:not(:disabled) {
    background-color: rgba(var(--primary-color-rgb, 0, 122, 204), 0.08);
    color: var(--primary-color, #007acc);
}

.layer-menu-item:hover:not(:disabled) i {
    color: var(--primary-color, #007acc);
}

.layer-menu-item:disabled {
    color: #bbb;
    cursor: default;
}

.layer-menu-item:disabled i {
    color: #ccc;
}

.layer-menu-status {
    padding: 2px 12px 6px 34px;
    font-size: 11px;
    color: #b45309;
    white-space: normal;
}

/* Geodaten Style-Einstellungen */
.geodata-style-section {
    padding: 8px 12px;
}

.geodata-style-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}

.geodata-style-row:last-child {
    margin-bottom: 0;
}

.geodata-style-row label {
    font-size: 10px;
    color: #555;
    min-width: 55px;
    flex-shrink: 0;
}

.geodata-style-row input[type="color"] {
    width: 28px;
    height: 22px;
    padding: 1px;
    border: 1px solid #ccc;
    border-radius: 3px;
    cursor: pointer;
}

.geodata-style-row input[type="range"] {
    width: 60px;
    flex: 0 0 60px;
    height: 4px;
    cursor: pointer;
}

.geodata-width-value {
    font-size: 10px;
    color: #666;
    flex-shrink: 0;
}

/* Legacy Opacity Control (für Kompatibilität) */
.layer-opacity-control {
    position: relative;
    display: none;
    flex-shrink: 0;
    margin-left: 4px;
}

.layer-item:hover .layer-opacity-control {
    display: block;
}

.layer-opacity-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background-color 0.2s;
    color: #999;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
}

.layer-opacity-btn:hover {
    background-color: rgba(0, 0, 0, 0.08);
    color: #666;
}

.layer-opacity-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Entfernen-Button für externe Layer */
.layer-remove-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 3px;
    transition: all 0.2s;
    color: #999;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    margin-left: 4px;
}

.layer-remove-btn:hover {
    background-color: #ffebee;
    color: #d32f2f;
}

.layer-item.external-layer {
    background: rgba(33, 150, 243, 0.05);
    border-left: 2px solid #2196f3;
    padding-left: 6px;
}

/* Externe Dienste Gruppe */
.layer-group.external-group > .layer-group-header {
    background: rgba(33, 150, 243, 0.08);
    border-left: 3px solid #2196f3;
}

.layer-group.external-group > .layer-group-header .external-icon {
    color: #2196f3;
}

/* Info-Knopf an der Ordnerzeile (Ordner mit hinterlegtem Info-Text) */
.group-info-btn {
    flex-shrink: 0;
    margin-left: 4px;
}

/* Gruppen-Entfernen-Button */
.group-remove-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 3px;
    transition: all 0.2s;
    color: #999;
    font-size: 12px;
    margin-left: auto;
    display: inline-flex;
    align-items: center;
}

.group-remove-btn:hover {
    background-color: #ffebee;
    color: #d32f2f;
}

/* Layer Info Panel Container */
.layer-info-panel {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 1000;
    display: none;
    min-width: 200px;
    white-space: nowrap;
}

.layer-info-panel.active {
    display: block;
}

/* Info Sections */
.info-section {
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
}

.info-section:last-child {
    border-bottom: none;
}

.opacity-slider-header {
    font-size: 11px;
    color: #666;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.opacity-value {
    font-weight: 600;
    color: #333;
}

/* Range Slider Styling */
.opacity-range {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(to right, transparent 0%, #666 100%);
    outline: none;
    -webkit-appearance: none;
    margin: 0;
}

.opacity-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary-color, #007acc);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.opacity-range::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary-color, #007acc);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.opacity-range::-webkit-slider-thumb:hover {
    background: var(--primary-hover, #005a9e);
    transform: scale(1.1);
}

.opacity-range::-moz-range-thumb:hover {
    background: var(--primary-hover, #005a9e);
    transform: scale(1.1);
}

/* Metadaten Link */
.metadata-section {
    padding: 6px 8px !important;
}

.metadata-link {
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: #007bff;
    font-size: 12px;
    padding: 4px 4px;
    border-radius: 3px;
    transition: all 0.2s;
}

.metadata-link:hover {
    background: #f0f8ff;
    color: #0056b3;
}

.metadata-link i {
    font-size: 11px;
}

.metadata-link span {
    white-space: normal;
    line-height: 1.3;
}

.layer-name {
    flex: 1;
    /* Pflicht damit overflow:hidden + ellipsis im Flexbox-Container greifen
       (siehe Kommentar bei .layer-item-main). */
    min-width: 0;
    color: #444;
    font-size: 12px;
    white-space: nowrap; /* Verhindert Zeilenumbruch */
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-loading {
    margin-left: 8px;
    font-size: 10px;
    color: #999;
}

/* Visuelles Feedback für Gruppen mit aktiven Layern */
/* Deaktiviert - Schrift soll sich nicht ändern
.layer-group.has-active-layers > .layer-group-header .group-name {
    font-weight: 600;
    color: var(--primary-color);
}

.layer-group.has-active-layers > .layer-group-header .folder-icon {
    color: var(--primary-color);
}
*/

/* Sidebar Scrollbar */
.sidebar-content::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Radio-Button Styling */
.layer-radio {
    width: 14px;
    height: 14px;
    margin-right: 6px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.layer-radio:checked {
    accent-color: var(--primary-color);
}

/* Optionsgruppen (Radio) optisch wie Checkbox-Gruppen darstellen —
   keine farbliche Hinterlegung, keine Akzentfarbe im Gruppennamen.
   Die Auswahl wird allein durch den Radio-Button selbst kommuniziert. */

/* Uncheckable Gruppen - keine Checkbox anzeigen */
.layer-group[data-uncheckable="true"] > .layer-group-header .group-checkbox {
    display: none;
}

/* Platzhalter fuer Ordner OHNE eigene Checkbox (Radio-/uncheckable-Gruppen):
   belegt exakt den Footprint der Checkbox (14px + 6px Abstand), damit alle
   Ordner buendig untereinander stehen. Dezent und nicht interaktiv. */
.group-checkbox-placeholder {
    width: 14px;
    height: 14px;
    margin: 0 6px 0 0;
    flex-shrink: 0;
    cursor: default;
    pointer-events: none;
    opacity: 0.35;
}

/* Hover-Effekte für Radio-Buttons */
.layer-radio:hover {
    transform: scale(1.1);
    transition: transform 0.15s ease;
}

/* Focus-Styles entfernt - keine störenden Rahmen mehr */
.layer-radio:focus,
.layer-checkbox:focus,
.group-checkbox:focus {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

/* Zusätzliche Browser-spezifische Resets */
.layer-radio::-moz-focus-inner,
.layer-checkbox::-moz-focus-inner,
.group-checkbox::-moz-focus-inner {
    border: 0;
    padding: 0;
}

/* CURSOR FIX - Entfernt den help-cursor bei Tooltips */
.group-name[title],
.layer-name[title] {
    cursor: default; /* Geändert von cursor: help zu cursor: default */
}

/* Explizite Cursor-Definition für alle interaktive Elemente */
.layer-group-header {
    cursor: pointer;
}

.layer-item-main {
    cursor: pointer;
}

.folder-icon,
.layer-icon {
    cursor: inherit; /* Erbt den Cursor vom Parent-Element */
    pointer-events: none; /* Icons sind nicht separat klickbar */
}

.group-name,
.layer-name {
    cursor: inherit; /* Erbt den Cursor vom Parent-Element */
    pointer-events: none; /* Text ist nicht separat klickbar */
}

/* Checkboxes und Radio-Buttons behalten ihren eigenen Cursor */
.group-checkbox,
.layer-checkbox,
.layer-radio {
    cursor: pointer;
    pointer-events: auto; /* Explizit klickbar */
}

/* Opacity Button hat eigenen Cursor */
.layer-opacity-btn {
    pointer-events: auto;
}

/* Layer Settings & Metadata Buttons */
.layer-settings-btn,
.layer-metadata-btn {
    pointer-events: auto;
}

/* ============================================
   LAYER METADATA MODAL STYLES
   ============================================ */

.layer-metadata-content {
    padding: 0;
}

.layer-metadata-content .metadata-section {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
}

.layer-metadata-content .metadata-section:last-child {
    border-bottom: none;
}

.layer-metadata-content .metadata-section h4 {
    margin: 0 0 10px 0;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.layer-metadata-content .metadata-section h4 i {
    color: #666;
    font-size: 12px;
}

/* OGC-Dienste-Zeilen (WMS/WFS) im Layer-Info-Modal */
.layer-metadata-content .ogc-service-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}
.layer-metadata-content .ogc-service-row:last-child {
    margin-bottom: 0;
}
.layer-metadata-content .ogc-service-label {
    min-width: 38px;
    font-weight: 600;
    font-size: 12px;
    color: var(--primary-color);
}
.layer-metadata-content .ogc-url-input {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    padding: 5px 8px;
    border: 1px solid #d5d5d5;
    border-radius: 4px;
    background: #f7f7f7;
    color: #333;
}
.layer-metadata-content .ogc-url-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(var(--primary-color-rgb), 0.15);
}
/* Icon-Buttons (Kopieren + GetCapabilities) in Primärfarbe */
.layer-metadata-content .ogc-icon-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    background: #fff;
    color: var(--primary-color);
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, color .15s, box-shadow .15s;
}
.layer-metadata-content .ogc-icon-btn:hover {
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 1px 5px rgba(var(--primary-color-rgb), 0.35);
}
.layer-metadata-content .ogc-icon-btn:active {
    transform: translateY(1px);
}
.layer-metadata-content .ogc-copy-btn.copied {
    background: #2e7d32;
    border-color: #2e7d32;
    color: #fff;
}

/* ArcGIS REST Legende (im Layer-Info-Modal) */
.arcgis-legend {
    max-height: 300px;
    overflow-y: auto;
}
.arcgis-legend-sublayer {
    margin-bottom: 10px;
}
.arcgis-legend-sublayer:last-child {
    margin-bottom: 0;
}
.arcgis-legend-sublayer-title {
    font-weight: 600;
    font-size: 12px;
    color: #555;
    margin-bottom: 4px;
    padding-bottom: 2px;
    border-bottom: 1px dashed #e0e0e0;
}
.arcgis-legend-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.arcgis-legend-table td {
    padding: 3px 4px;
    vertical-align: middle;
}

/* Metadaten Tabelle */
.metadata-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.metadata-table tr {
    border-bottom: 1px solid #f5f5f5;
}

.metadata-table tr:last-child {
    border-bottom: none;
}

.metadata-table td {
    padding: 6px 0;
    vertical-align: top;
}

.metadata-table td:first-child {
    font-weight: 500;
    color: #666;
    width: 100px;
    padding-right: 12px;
}

.metadata-table td:last-child {
    color: #333;
    word-break: break-word;
}

.metadata-table .metadata-url {
    font-size: 11px;
    color: #666;
    word-break: break-all;
    max-width: 300px;
}

/* Legende */
.metadata-legend {
    text-align: center;
    padding: 8px;
    background: #fafafa;
    border-radius: 4px;
    min-height: 40px;
}

.metadata-legend img {
    max-width: 100%;
    max-height: 150px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.metadata-legend img:hover {
    opacity: 0.8;
}

.metadata-legend .legend-hint {
    font-size: 11px;
    color: #888;
    margin-top: 6px;
}

.metadata-legend .no-legend {
    color: #999;
    font-size: 12px;
    font-style: italic;
}

/* Zusätzliche Informationen (metadataText) */
.metadata-section .metadata-text,
.metadata-section .metadata-text * {
    font-size: 12px !important;
    line-height: 1.5 !important;
    color: #333;
}

.metadata-section .metadata-text p {
    margin: 0 0 8px 0;
}

.metadata-section .metadata-text p:last-child {
    margin-bottom: 0;
}

/* Legende Fullscreen Overlay */
.legend-fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    padding: 20px;
}

.legend-fullscreen-overlay img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.legend-fullscreen-close {
    position: absolute;
    top: 15px;
    right: 20px;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 5px 10px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
}

.legend-fullscreen-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Externer Metadaten-Link */
.metadata-external-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #f0f7ff;
    color: #2196f3;
    text-decoration: none;
    border-radius: 4px;
    font-size: 13px;
    transition: all 0.2s;
}

.metadata-external-link:hover {
    background: #e3f2fd;
    color: #1976d2;
}

.metadata-external-link i {
    font-size: 12px;
}

/* Metadaten-View im Modal (aus metadata_html_view.php) */
.metadata-view-content .section {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
}
.metadata-view-content .section:last-child {
    border-bottom: none;
}
.metadata-view-content .section h2 {
    font-size: 13px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 10px 0;
    padding-bottom: 4px;
    border-bottom: 2px solid #e67e22;
    display: inline-block;
}
.metadata-view-content .field {
    display: flex;
    margin-bottom: 6px;
    font-size: 12px;
}
.metadata-view-content .field .label {
    flex: 0 0 180px;
    font-weight: 500;
    color: #666;
    padding-right: 10px;
}
.metadata-view-content .field .value {
    flex: 1;
    color: #333;
    word-break: break-word;
}
.metadata-view-content .field .value a {
    color: #2980b9;
}
.metadata-view-content .badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
}
.metadata-view-content .badge-success { background: #d4edda; color: #155724; }
.metadata-view-content .badge-info { background: #d6eaf8; color: #1a5276; }
.metadata-view-content .keyword {
    display: inline-block;
    padding: 1px 6px;
    background: #fff3e6;
    border: 1px solid #f5d5b0;
    border-radius: 10px;
    font-size: 11px;
    color: #8a5a1e;
    margin: 2px;
}

/* Loading und Error States */
.metadata-loading,
.metadata-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #666;
    text-align: center;
}

.metadata-loading i,
.metadata-error i {
    font-size: 24px;
    margin-bottom: 12px;
}

.metadata-error {
    color: #d32f2f;
}

.metadata-error i {
    color: #d32f2f;
}

/* ============================================
   SCALE-DEPENDENT LAYER VISIBILITY
   ============================================ */

/* Layer außerhalb des Maßstabsbereichs */
.layer-item.out-of-scale .layer-item-main {
    opacity: 0.5;
}

.layer-item.out-of-scale .layer-name {
    font-style: italic;
}

/* Scale Hint Icon */
.layer-scale-hint {
    font-size: 11px;
    color: #888;
    margin-left: 4px;
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
}

.layer-scale-hint i {
    font-size: 10px;
}

/* Zoom-In Hint (muss reinzoomen) */
.layer-scale-hint.zoom-in {
    color: var(--primary-color, #f57c00);
}

/* Zoom-Out Hint (muss rauszoomen) */
.layer-scale-hint.zoom-out {
    color: var(--primary-color, #1976d2);
}

/* ===== BAUM-WERKZEUGE (alle Gruppen auf-/zuklappen) ===== */
/* Sitzen in der Suchzeile rechts neben dem Eingabefeld — kosten also keine
   zusaetzliche Hoehe im Panel. */
.tree-tools-btn {
    flex: 0 0 auto;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px 6px;
    color: #9a9a9a;
    font-size: 12px;
    line-height: 1;
    border-radius: 3px;
}
.tree-tools-btn:hover { color: #444; background: #e8e8e8; }
