/* ==========================================================================
   Baugebiete Map Container
   ========================================================================== */
#baugebiete-map {
    height: 500px;
    width: 100%;
    border: 2px solid #666;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
}

/* ==========================================================================
   OpenLayers Zoom Control
   ========================================================================== */
.ol-zoom {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ol-zoom button,
.ol-zoom button.ol-zoom-in,
.ol-zoom button.ol-zoom-out {
    background-color: #ffffff !important;
    border: 1px solid #666 !important;
    color: #666 !important;
    width: 31px !important;
    height: 31px !important;
    font-size: 14px !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
    transition: all 0.3s ease !important;
    margin: 0 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
}

.ol-zoom button:hover,
.ol-zoom button.ol-zoom-in:hover,
.ol-zoom button.ol-zoom-out:hover {
    background-color: #b00707 !important;
    border-color: #b00707 !important;
    color: #ffffff !important;
}

.ol-zoom button:disabled {
    background-color: #ebebeb !important;
    border-color: #666 !important;
    color: #999999 !important;
    cursor: not-allowed !important;
}

/* ==========================================================================
   OpenLayers Attribution
   ========================================================================== */
.ol-attribution {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.8);
    padding: 2px 5px;
    font-size: 10px;
    border-radius: 4px;
}

.ol-attribution ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.ol-attribution li {
    display: inline;
}

.ol-attribution a {
    color: #0066cc;
    text-decoration: none;
}

.ol-attribution a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Layer Control (Basemap Switcher)
   ========================================================================== */
.ol-layer-button {
    position: absolute;
    bottom: 10px;
    left: 10px;
}

.ol-layer-button button {
    --btn-size: 40px;
    background-color: #ffffff;
    border: 1px solid #666;
    width: var(--btn-size);
    height: var(--btn-size);
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: all 0.3s ease;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 0;
}

.ol-layer-button button i {
    font-size: calc(var(--btn-size) * 0.4);
}

.ol-layer-button button:hover,
.ol-layer-button button.active {
    background-color: #b00707;
    border-color: #b00707;
    color: #ffffff;
}

.ol-layer-panel {
    position: absolute;
    bottom: 60px;
    left: 10px;
    background: white;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    border: 1px solid #666;
    padding: 5px;
    z-index: 1;
}

.layer-panel-content {
    display: flex;
    flex-direction: column;
}

.layer-preview-item {
    display: flex;
    align-items: center;
    padding: 5px;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    transition: all 0.2s ease;
    margin-bottom: 5px;
}

.layer-preview-item:last-child {
    margin-bottom: 0;
}

.layer-preview-item:hover {
    background-color: #f4f4f4;
}

.layer-preview-item.active {
    border-color: #b00707;
    background-color: rgba(176, 7, 7, 0.05);
}

.layer-preview-image {
    width: 50px;
    height: 50px;
    border-radius: 4px;
    overflow: hidden;
    margin-right: 10px;
    border: 1px solid #ccc;
    flex-shrink: 0;
    background-color: #f0f0f0;
}

.layer-preview-name {
    font-size: 12px;
    color: #333;
}

/* ==========================================================================
   Search Control
   ========================================================================== */
.search-control {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: 350px;
    max-width: calc(100% - 120px);
}

.search-control .search-input-wrapper {
    display: flex;
    align-items: center;
    background: white;
    border: 1px solid #666;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.search-control .search-icon {
    padding: 0 10px;
    color: #999;
    display: flex;
    align-items: center;
}

.search-control .search-input {
    flex: 1;
    padding: 10px 5px;
    border: none;
    font-size: 14px;
    outline: none;
    background: transparent;
    min-width: 0;
}

.search-control .search-input::placeholder {
    color: #999;
}

.search-control .search-clear {
    width: 36px;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0;
    transition: color 0.2s ease;
}

.search-control .search-clear:hover,
.search-control .search-clear:focus {
    color: #b00707;
    outline: none;
}

.search-control .search-clear.hidden {
    display: none;
}

.search-control .search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #666;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 250px;
    overflow-y: auto;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    list-style: none;
    margin: 0;
    padding: 0;
}

.search-control .search-suggestions.hidden {
    display: none;
}

.search-control .search-suggestion-item {
    display: flex;
    align-items: flex-start;
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    transition: background-color 0.15s ease;
}

.search-control .search-suggestion-item:last-child {
    border-bottom: none;
}

.search-control .search-suggestion-item:hover,
.search-control .search-suggestion-item.active {
    background-color: #f4f4f4;
}

.search-control .suggestion-icon {
    flex-shrink: 0;
    width: 20px;
    margin-right: 10px;
    color: #666;
    text-align: center;
}

.search-control .suggestion-text {
    font-size: 13px;
    line-height: 1.4;
    color: #333;
    word-break: break-word;
}

.search-control .search-no-results {
    padding: 12px;
    font-size: 13px;
    color: #999;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ==========================================================================
   B-Plan Popup
   ========================================================================== */
.bplan-popup {
    background-color: white;
    padding: 12px 15px;
    border-radius: 4px;
    border: 1px solid #666;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    min-width: 200px;
    max-width: 350px;
    position: relative;
}

.bplan-popup.hidden {
    display: none;
}

.bplan-popup::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid white;
}

.bplan-popup-close {
    position: absolute;
    top: 5px;
    right: 8px;
    cursor: pointer;
    color: #666;
    font-size: 18px;
    background: none;
    border: none;
    padding: 0;
    line-height: 1;
}

.bplan-popup-close:hover {
    color: #b00707;
}

.bplan-popup-title {
    display: block;
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 6px;
    padding-right: 20px;
}


/* ==========================================================================
   Legende
   ========================================================================== */
.baugebiete-legende {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    justify-content: center;
    padding: 6px 12px;
    font-size: 13px;
    color: #666;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 4px 4px 0 0;
    z-index: 1;
}

.legende-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legende-color {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   Loading Indicator
   ========================================================================== */
.ol-loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    display: none;
}

.ol-loading-indicator.visible {
    display: block;
}

.ol-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #b00707;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */
.hidden {
    display: none !important;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 768px) {
    #baugebiete-map {
        height: 350px;
    }

    .ol-zoom button,
    .ol-zoom button.ol-zoom-in,
    .ol-zoom button.ol-zoom-out {
        width: 28px !important;
        height: 28px !important;
        font-size: 13px !important;
    }

    .ol-layer-button button {
        --btn-size: 36px;
    }

    .ol-layer-panel {
        bottom: 55px;
    }

    .layer-preview-image {
        width: 40px;
        height: 40px;
    }

    .layer-preview-name {
        font-size: 11px;
    }

    .search-control {
        width: 250px;
        max-width: calc(100% - 90px);
    }

    .search-control .search-input {
        padding: 8px 5px;
    }

    .baugebiete-legende {
        font-size: 12px;
        flex-wrap: wrap;
        gap: 10px;
    }

    .legende-color {
        width: 14px;
        height: 14px;
    }

    .bplan-popup {
        max-width: 300px;
    }

    .bplan-popup-title {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .ol-zoom button,
    .ol-zoom button.ol-zoom-in,
    .ol-zoom button.ol-zoom-out {
        width: 26px !important;
        height: 26px !important;
        font-size: 12px !important;
    }

    .ol-layer-button button {
        --btn-size: 32px;
    }

    .ol-layer-panel {
        bottom: 50px;
    }

    .layer-preview-image {
        width: 35px;
        height: 35px;
        margin-right: 6px;
    }

    .layer-preview-name {
        font-size: 10px;
    }

    .search-control {
        width: 180px;
        max-width: calc(100% - 70px);
    }

    .search-control .search-input {
        font-size: 16px;
        padding: 4px 4px;
    }

    .search-control .search-icon {
        padding: 0 6px;
    }

    .search-control .search-clear {
        width: 28px;
    }

    .search-control .suggestion-text {
        font-size: 12px;
    }

    .search-control .search-suggestion-item {
        padding: 8px 10px;
    }

    .baugebiete-legende {
        font-size: 11px;
        padding: 4px 8px;
        gap: 6px;
    }

    .legende-item {
        gap: 4px;
    }

    .legende-color {
        width: 12px;
        height: 12px;
    }

    .bplan-popup {
        min-width: 160px;
        max-width: 260px;
        padding: 8px 10px;
    }

    .bplan-popup-title {
        font-size: 12px;
        padding-right: 16px;
    }

    .bplan-popup-close {
        font-size: 16px;
    }
}

@media (max-width: 375px) {
    #baugebiete-map {
        height: 280px;
    }

    .search-control {
        width: 150px;
        max-width: calc(100% - 60px);
    }

    .search-control .search-input {
        font-size: 16px;
        padding: 3px 3px;
    }

    .search-control .suggestion-text {
        font-size: 11px;
    }

    .baugebiete-legende {
        font-size: 10px;
        padding: 3px 6px;
        gap: 4px;
    }

    .legende-color {
        width: 10px;
        height: 10px;
    }
}
