/* ==========================================================================
   Main Map Container
   ========================================================================== */
#map {
    height: 600px;
    width: auto;
    max-width: 1200px;
    margin: 0 auto 30px auto;
    border: 2px solid #666;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
}

/* ==========================================================================
   Button Styles - Global
   ========================================================================== */
.map-button,
.help-button,
.style-control-container a {
    background-color: #ffffff;
    border: 1px solid #666;
    padding: 8px 16px;
    text-align: center;
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    color: #666;
}

/* Button Hover States */
.map-button:hover,
.help-button:hover,
.style-control-container a:hover {
    background-color: #b00707 !important;
    border-color: #b00707 !important;
    color: #ffffff !important;
}

/* Disabled and Hidden States */
.map-button:disabled {
    background-color: #ebebeb;
    border-color: #666;
    color: #999999;
    cursor: not-allowed;
    opacity: 1;
    pointer-events: none;
}

.map-button:disabled:hover {
    background-color: #ebebeb !important;
    border-color: #666 !important;
    color: #999999 !important;
}

.map-button.hidden {
    display: none !important;
}

/* Success State */
.map-button.success {
    background-color: #28a745;
    border-color: #28a745;
    color: #ffffff;
}

.map-button.success:hover {
    background-color: #218838 !important;
    border-color: #1e7e34 !important;
}

/* ==========================================================================
   Button Container
   ========================================================================== */
#button-container {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    gap: 10px;
}

/* ==========================================================================
   Help Button
   ========================================================================== */
.help-button {
    width: 31px;
    height: 31px;
    line-height: 31px;
    padding: 0;
    position: absolute;
    left: 10px;
    top: 122px;
    margin: 0;
    z-index: 1000;
    font-weight: bold;
}

/* ==========================================================================
   Style Control Container
   ========================================================================== */
.style-control-container a {
    width: 31px;
    height: 31px;
    line-height: 31px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.style-control-container a:hover .fa-palette {
    color: #ffffff;
}

.style-control-container .fa-palette {
    color: #666;
    transition: color 0.3s ease;
}

/* ==========================================================================
   OpenLayers Zoom Control Styles
   ========================================================================== */
.ol-zoom {
    position: absolute;
    top: 10px;
    left: 10px;
}

.ol-zoom {
    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: 18px !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;
}

.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: 0;
    right: 0;
    background: rgba(255,255,255,0.8);
    padding: 2px 5px;
    font-size: 10px;
}

.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;
}

/* ==========================================================================
   OpenLayers Layer Control (Basemap Switcher)
   ========================================================================== */

/* Layer Button - unten links, gleiche Abstände wie Zoom-Buttons */
.ol-layer-button {
    position: absolute;
    bottom: 10px;
    left: 10px;
}

.ol-layer-button button {
    background-color: #ffffff;
    border: 1px solid #666;
    width: 40px;
    height: 40px;
    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: 18px;
}

.ol-layer-button button:hover,
.ol-layer-button button.active {
    background-color: #b00707;
    border-color: #b00707;
    color: #ffffff;
}

/* Layer Panel - schwebt über dem Button */
.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-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.layer-preview-name {
    font-size: 12px;
    color: #333;
}

/* ==========================================================================
   OpenLayers Draw Toolbar
   ========================================================================== */
.draw-toolbar {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.draw-toolbar.hidden {
    display: none !important;
}

.draw-toolbar button {
    background-color: #ffffff;
    border: 1px solid #666;
    width: 31px;
    height: 31px;
    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: 14px;
}

.draw-toolbar button:hover,
.draw-toolbar button.active {
    background-color: #b00707;
    border-color: #b00707;
    color: #ffffff;
}

.draw-toolbar button:disabled {
    background-color: #ebebeb;
    border-color: #666;
    color: #999999;
    cursor: not-allowed;
}

/* ==========================================================================
   OpenLayers Search Control (Autocomplete)
   ========================================================================== */
.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,
.search-control .search-loading {
    padding: 0 10px;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    background: none;
    border: none;
    transition: color 0.2s ease;
}

.search-control .search-clear:hover {
    color: #b00707;
}

.search-control .search-clear.hidden,
.search-control .search-loading.hidden {
    display: none;
}

.search-control .search-loading {
    cursor: default;
    color: #b00707;
}

/* Vorschlagsliste */
.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 .search-suggestion-item.active {
    background-color: #e8e8e8;
}

.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,
.search-control .search-error {
    padding: 12px;
    font-size: 13px;
    color: #999;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-control .search-error {
    color: #b00707;
}

/* Search Popup */
.search-popup {
    background-color: white;
    padding: 10px 30px 10px 10px;
    border-radius: 4px;
    border: 1px solid #666;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    min-width: 150px;
    max-width: 300px;
    font-size: 12px;
}

.search-popup.hidden {
    display: none;
}

.search-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;
}

.search-popup-content {
    position: relative;
}

.search-popup-text {
    display: block;
    word-wrap: break-word;
}

.search-popup-close {
    position: absolute;
    top: -5px;
    right: -20px;
    cursor: pointer;
    color: #666;
    font-size: 14px;
    background: none;
    border: none;
    padding: 0;
}

.search-popup-close:hover {
    color: #b00707;
}

/* ==========================================================================
   OpenLayers Popup/Overlay
   ========================================================================== */
.ol-popup {
    position: absolute;
    background-color: white;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #666;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    min-width: 150px;
    max-width: 300px;
}

.ol-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;
}

.ol-popup-close {
    position: absolute;
    top: 5px;
    right: 5px;
    cursor: pointer;
    color: #666;
    font-size: 14px;
}

.ol-popup-close:hover {
    color: #b00707;
}

/* ==========================================================================
   Information Panel
   ========================================================================== */
.info-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    background: white;
    padding: 10px;
    border: 1px solid #666;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 1000;
    min-width: 200px;
    transition: opacity 0.3s ease;
}

.info-panel.hidden {
    opacity: 0;
    pointer-events: none;
}

.info-content {
    font-size: 12px;
    line-height: 1.4;
}

/* ==========================================================================
   Parcel Labels (OpenLayers Overlay)
   ========================================================================== */
.parcel-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 10px;
    font-weight: bold;
    text-shadow:
        -1px -1px 0 #000000,
        1px -1px 0 #000000,
        -1px 1px 0 #000000,
        1px 1px 0 #000000,
        0 0 3px #fff,
        0 0 3px #fff;
    color: #ffffff;
    pointer-events: none;
    white-space: nowrap;
}

.parcel-label .zaehler {
    border-bottom: 1px solid #ffffff;
    padding-bottom: 1px;
    text-shadow:
        -1px -1px 0 #000000,
        1px -1px 0 #000000,
        -1px 1px 0 #000000,
        1px 1px 0 #000000;
}

.parcel-label .nenner {
    padding-top: 1px;
}

.parcel-label-hover {
    font-size: 14px;
    font-weight: bold;
    z-index: 1000;
}

/* ==========================================================================
   Custom Logo
   ========================================================================== */
.custom-logo-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.custom-logo-marker img {
    width: 128px;
    height: 128px;
}

/* ==========================================================================
   Instruction Panel
   ========================================================================== */
.instruction-panel {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 15px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 1000;
    font-size: 14px;
    transition: opacity 0.3s ease;
    border: 2px solid #666;
    min-width: 200px;
    max-width: 600px;
}

.instruction-content {
    position: relative;
    padding: 15px;
}

.instruction-panel p {
    margin: 0 0 10px 0;
}

.instruction-panel ul {
    margin: 0;
    padding-left: 20px;
}

.instruction-panel li {
    margin-bottom: 5px;
}

.drawing-instruction {
    top: 10px;
    right: 60px;
    left: auto;
    transform: none;
}

.instruction-panel.hidden {
    opacity: 0;
    pointer-events: none;
}

.drawing-instruction::after {
    content: '';
    position: absolute;
    right: -15px;
    top: 50%;
    transform: translateY(-50%);
    border-left: 15px solid white;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
}

/* ==========================================================================
   Form Elements (Bootstrap übernimmt diese Klassen)
   ========================================================================== */
/* .row, .col-*, .form-label, .form-control, .invalid-feedback
   werden von Bootstrap bereitgestellt und hier NICHT überschrieben */

/* ==========================================================================
   Help Popup
   ========================================================================== */
.help-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 2000;
    max-width: 400px;
    width: 90%;
}

.help-popup.hidden {
    display: none;
}

/* Close Buttons */
.close-button,
.help-popup-close {
    position: absolute;
    right: -10px;
    top: -10px;
    width: 31px;
    height: 31px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 18px;
    background: none;
    border: none;
    box-shadow: none;
    color: #666;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close-button:hover,
.help-popup-close:hover {
    color: #b00707;
    background: none;
    border: none;
}

/* ==========================================================================
   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); }
}

/* ==========================================================================
   Miscellaneous
   ========================================================================== */
.message-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-circle {
    font-size: 20px;
    color: #b00707;
    font-style: normal;
}

.message-container p {
    margin: 0;
}

.style-select {
    padding: 4px;
    border: 1px solid #666;
    border-radius: 4px;
    background-color: white;
    font-size: 14px;
}

/* Text input for drawing */
.map-text-input {
    min-width: 100px;
    padding: 5px;
    border: 1px solid #b00707;
    border-radius: 4px;
    background: white;
    font-size: 14px;
    outline: none;
}

.map-text-input:focus {
    box-shadow: 0 0 3px rgba(176, 7, 7, 0.5);
}

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
    .ol-control,
    .ol-overlaycontainer-stopevent {
        display: none !important;
    }

    .map-button,
    .help-button,
    .instruction-panel,
    .info-panel,
    .draw-toolbar,
    .ol-layer-button,
    .ol-layer-panel {
        display: none !important;
    }

    #map {
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
    }
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */
.hidden {
    display: none !important;
}

.transparent {
    opacity: 0 !important;
}

.no-pointer-events {
    pointer-events: none !important;
}

.clickable {
    cursor: pointer;
}

/* ==========================================================================
   Responsive Styles
   ========================================================================== */
@media (max-width: 768px) {
    #map {
        height: 400px;
    }

    .ol-layer-panel {
        bottom: 60px;
    }

    .layer-preview-image {
        width: 40px;
        height: 40px;
    }

    .layer-preview-name {
        font-size: 11px;
    }

    .draw-toolbar {
        top: 60px;
    }

    .instruction-panel {
        max-width: 90%;
        font-size: 12px;
    }
}

@media (max-width: 375px) {
    #map {
        height: 350px;
    }

    .search-control {
        width: 200px;
        max-width: calc(100% - 80px);
    }

    .search-control .search-input {
        font-size: 13px;
        padding: 8px 5px;
    }

    .search-control .suggestion-text {
        font-size: 12px;
    }
}
