/* Interactive Map – full-viewport layout, upload zone, legend, modal. Depends on global.css. */

body.interactive-map-app {
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.wm-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.wm-header-center {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    min-width: 0;
}

.wm-map-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.wm-label-text {
    font-size: 0.875rem;
    color: var(--text-light);
    white-space: nowrap;
}

.wm-map-select {
    padding: 0.35rem 0.5rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text);
    min-width: 140px;
    cursor: pointer;
}

.wm-map-select:hover,
.wm-map-select:focus {
    border-color: var(--primary-color);
    outline: none;
}

.wm-search-wrap {
    flex: 1;
    min-width: 160px;
    position: relative;
}

.wm-search-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    position: relative;
}

.wm-search-icon {
    position: absolute;
    left: 0.5rem;
    color: var(--text-light);
    pointer-events: none;
}

.wm-search {
    width: 100%;
    padding: 0.35rem 0.5rem 0.35rem 1.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text);
}

.wm-search:focus {
    border-color: var(--primary-color);
    outline: none;
}

.wm-search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.25rem;
    max-height: 200px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px var(--shadow);
    z-index: 1000;
}

.wm-search-dropdown.hidden {
    display: none;
}

.wm-search-dropdown-item {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
    width: 100%;
    text-align: left;
    background: transparent;
    color: var(--text);
}

.wm-search-dropdown-item:hover,
.wm-search-dropdown-item:focus {
    background: var(--input-bg);
    outline: none;
}

.wm-search-dropdown-item-name {
    font-weight: 500;
}

.wm-search-dropdown-item-type {
    font-size: 0.75rem;
    color: var(--text-light);
}

.wm-admin-link {
    font-size: 0.875rem;
    color: var(--primary-color);
    text-decoration: none;
    white-space: nowrap;
}

.wm-admin-link:hover {
    text-decoration: underline;
}

.wm-main {
    flex: 1;
    display: flex;
    min-height: 0;
}

.wm-sidebar-left {
    width: 280px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1rem;
    overflow-y: auto;
}

.wm-panel-title {
    font-size: 1rem;
    color: var(--primary-color);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.wm-detail-content {
    font-size: 0.9rem;
    color: var(--text);
}

.wm-detail-placeholder {
    color: var(--text-light);
    font-style: italic;
}

.wm-detail-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.wm-detail-type {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.wm-detail-description {
    white-space: pre-wrap;
}

.wm-detail-image-wrap {
    margin-top: 1rem;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.wm-detail-image {
    display: block;
    max-width: 100%;
    height: auto;
    max-height: 240px;
    object-fit: cover;
}

.wm-detail-image-clickable {
    cursor: pointer;
}

/* Image lightbox – enlarged view with overlay */
.wm-image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.wm-image-lightbox.hidden {
    display: none;
}

.wm-image-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    cursor: pointer;
}

.wm-image-lightbox-img {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.wm-image-lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 2;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    font-size: 1.5rem;
    line-height: 1;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
}

.wm-image-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.wm-image-hint {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 0.35rem;
}

.wm-marker-image-input {
    width: 100%;
    font-size: 0.875rem;
}

.wm-marker-image-preview {
    position: relative;
    margin-top: 0.5rem;
    display: inline-block;
}

.wm-marker-image-preview.hidden {
    display: none;
}

.wm-marker-image-preview-img {
    display: block;
    max-width: 160px;
    max-height: 120px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.wm-marker-image-clear {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    font-size: 1.25rem;
    line-height: 1;
    border: none;
    border-radius: 4px;
    background: var(--error);
    color: white;
    cursor: pointer;
    opacity: 0.9;
}

.wm-marker-image-clear:hover {
    opacity: 1;
}

.wm-map-wrap {
    flex: 1;
    position: relative;
    min-width: 0;
    background: var(--background);
}

.wm-upload-zone {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: 2px dashed var(--border);
    border-radius: 8px;
    margin: 0.5rem;
    background: var(--card-bg);
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.wm-upload-zone:hover,
.wm-upload-zone.wm-drag-over {
    border-color: var(--primary-color);
    background: var(--surface);
}

.wm-file-input {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.wm-upload-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
}

.wm-upload-hint {
    font-size: 0.875rem;
    color: var(--text-light);
}

.wm-upload-zone.hidden {
    display: none;
}

.wm-map-container {
    position: absolute;
    inset: 0;
    background: var(--background);
}

/* Leaflet adds .leaflet-container to the map div; keep background in sync with theme */
.interactive-map-app .wm-map-container.leaflet-container {
    background: var(--background);
}

.wm-map-container[aria-hidden="true"] {
    visibility: hidden;
    pointer-events: none;
}

/* Legend and + button overlay on top of map */
.wm-map-overlays {
    position: absolute;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: row-reverse;
    align-items: flex-end;
    gap: 0.5rem;
    z-index: 1000;
    pointer-events: none;
}

.wm-map-overlays > * {
    pointer-events: auto;
}

.wm-legend-overlay {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    box-shadow: 0 2px 12px var(--shadow);
    max-height: 70vh;
    overflow-y: auto;
}

.wm-legend-overlay[open] .wm-legend-list {
    margin-top: 0.5rem;
}

.wm-map-overlays .wm-fab {
    position: relative;
    bottom: auto;
    right: auto;
    flex-shrink: 0;
}

.wm-ruler-btn {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: 50%;
    border: none;
    background: var(--surface);
    color: var(--text);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 8px var(--shadow);
    border: 1px solid var(--border);
    transition: background 0.2s ease, transform 0.2s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wm-ruler-btn:hover {
    background: var(--input-bg);
    transform: scale(1.05);
}

.wm-ruler-btn[aria-pressed="true"] {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.wm-ruler-btn[aria-pressed="true"]:hover {
    background: var(--primary-light);
    border-color: var(--primary-light);
}

.wm-ruler-btn.wm-fab-hidden {
    display: none;
}

.wm-ruler-menu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 2px 8px var(--shadow);
    flex-shrink: 0;
    z-index: 1000;
}

.wm-ruler-menu.wm-ruler-menu-hidden {
    display: none;
}

.wm-ruler-menu-label {
    font-size: 0.875rem;
    color: var(--text);
    white-space: nowrap;
}

.wm-ruler-menu-select {
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    min-width: 10rem;
}

.wm-ruler-label {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    box-shadow: 0 1px 4px var(--shadow);
    white-space: nowrap;
    pointer-events: none;
}

.wm-ruler-label-text {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text);
}

.wm-legend-summary {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    list-style: none;
}

.wm-legend-summary::-webkit-details-marker {
    display: none;
}

.wm-legend-summary::before {
    content: "▼ ";
    font-size: 0.7rem;
}

.wm-legend[open] .wm-legend-summary::before {
    content: "▲ ";
}

.wm-legend-list {
    list-style: none;
    margin-top: 0.5rem;
}

.wm-legend-list li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text);
    margin-bottom: 0.35rem;
}

.wm-legend-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0;
    border: none;
    background: transparent;
    font-size: inherit;
    color: inherit;
    cursor: pointer;
    text-align: left;
    border-radius: 4px;
}

.wm-legend-btn:hover {
    background: var(--input-bg);
}

.wm-legend-item--off .wm-legend-btn {
    opacity: 0.5;
}

.wm-legend-item--off .wm-legend-swatch {
    opacity: 0.6;
}

.wm-legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.wm-fab {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: 50%;
    border: none;
    background: var(--primary-color);
    color: white;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 8px var(--shadow);
    transition: background 0.2s ease, transform 0.2s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wm-fab:hover {
    background: var(--primary-light);
    transform: scale(1.05);
}

.wm-fab:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.wm-fab.wm-fab-hidden {
    display: none;
}

/* Modal */
.wm-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.wm-modal[aria-hidden="true"] {
    display: none;
}

.wm-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.wm-modal-content {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 4px 20px var(--shadow);
}

.wm-modal-title {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.wm-modal-form .wm-form-group {
    margin-bottom: 1rem;
}

.wm-modal-form label {
    display: block;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    color: var(--text);
}

.wm-modal-form input,
.wm-modal-form textarea,
.wm-modal-form select {
    width: 100%;
    padding: 0.5rem;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text);
}

.wm-modal-form input:focus,
.wm-modal-form textarea:focus,
.wm-modal-form select:focus {
    border-color: var(--primary-color);
    outline: none;
}

.wm-modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
}

.wm-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid var(--border);
}

.wm-btn-secondary {
    background: var(--input-bg);
    color: var(--text);
}

.wm-btn-secondary:hover {
    background: var(--card-bg);
    border-color: var(--primary-color);
}

.wm-btn-primary {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.wm-btn-primary:hover {
    background: var(--primary-light);
    border-color: var(--primary-light);
}

/* Mobile */
@media (max-width: 768px) {
    .wm-main {
        flex-direction: column;
    }

    .wm-sidebar-left {
        width: 100%;
        max-height: 180px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .wm-map-overlays {
        bottom: 1rem;
        right: 1rem;
        flex-direction: column-reverse;
        align-items: flex-end;
    }

    .wm-legend-overlay {
        max-height: 50vh;
    }
}
