/* ── App-Container (Fullscreen-Anker) ────────────────────────────────────── */
#app-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}
#app-container:-webkit-full-screen { width: 100%; height: 100%; }
#app-container:fullscreen           { width: 100%; height: 100%; }

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100vh; width: 100vw;
    overflow: hidden;
    font-family: 'Helvetica Neue', Arial, sans-serif;
}

/* ── MapLibre-Container ──────────────────────────────────────────────────── */
#map {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
}

/* ── Titel ───────────────────────────────────────────────────────────────── */
.map-title {
    position: fixed;
    top: 12px; left: 12px;
    z-index: 100;
    background: none;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    pointer-events: none;
    line-height: 0;
}

.map-logo {
    display: block;
    width: 188px;
    height: 188px;
    object-fit: contain;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.25));
    pointer-events: auto;
    cursor: pointer;
    transition: transform .15s, filter .15s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}
.map-logo:active {
    transform: scale(0.93);
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.25)) brightness(1.1);
}

/* Kleinere Screens: Logo verkleinern */
@media (max-width: 768px) {
    .map-logo {
        width: 120px;
        height: 120px;
    }
}
@media (max-width: 430px) {
    .map-logo {
        width: 80px;
        height: 80px;
    }
}

/* ── Gruppen-Panel ───────────────────────────────────────────────────────── */
#group-panel {
    position: fixed;
    top: 12px; right: 12px;
    z-index: 200;
    background: rgba(255,255,255,0.96);
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.18);
    min-width: 150px;
    max-width: 220px;
    overflow: visible;
    user-select: none;
    max-height: calc(100vh - 24px);
    display: flex;
    flex-direction: column;
}
#group-panel > #group-header {
    border-radius: 8px 8px 0 0;
    flex-shrink: 0;
}

#group-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    cursor: pointer;
    background: rgba(240,240,240,0.98);
    border-bottom: 1px solid #ddd;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    color: #444;
    transition: background .12s;
}
#group-header:hover { background: #e4e4e4; }

#group-toggle-icon {
    font-size: 13px;
    line-height: 1;
    transition: transform .2s;
    display: inline-block;
}
#group-panel.collapsed #group-toggle-icon {
    transform: rotate(-90deg);
}

#group-title { flex: 1; }

#group-all-btn {
    font-size: 15px;
    cursor: pointer;
    padding: 0 2px;
    border-radius: 3px;
    transition: color .15s, background .15s;
    color: #3a7fd4;
    line-height: 1;
}
#group-all-btn:hover { background: rgba(58,127,212,.15); }
#group-all-btn.all-off { color: #bbb; }

/* ── Sort-Buttons in der Gruppen-Header-Zeile ────────────────────────────── */
.sort-btns {
    display: flex;
    gap: 2px;
    align-items: center;
    flex-shrink: 0;
}
.sort-btn {
    background: none;
    border: 1px solid transparent;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 600;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    color: #888;
    cursor: pointer;
    padding: 1px 4px;
    line-height: 1.4;
    letter-spacing: .02em;
    transition: color .12s, background .12s, border-color .12s;
    user-select: none;
    white-space: nowrap;
}
.sort-btn:hover {
    color: #444;
    background: rgba(0,0,0,.06);
    border-color: #ccc;
}
.sort-btn.active {
    color: #2c72c7;
    background: rgba(44,114,199,.10);
    border-color: rgba(44,114,199,.30);
}

/* Datum-Hinweis im chronologischen Sort-Modus */
.group-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 4px;
}
.group-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.group-date {
    font-size: 8px;
    color: #aaa;
    white-space: nowrap;
    flex-shrink: 0;
    font-weight: 400;
}

#group-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #aaa transparent;
    transition: max-height .2s ease, padding .2s ease, opacity .2s ease;
    border-radius: 0 0 8px 8px;
    font-size: 10px;
}
#group-panel.collapsed #group-list {
    max-height: 0 !important;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    overflow: hidden;
}

.group-item {
    padding: 4px 6px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 10px !important;
    font-weight: 500;
    line-height: 1.4;
    min-height: 22px;
    transition: background-color .12s, color .12s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border: 1px solid transparent;
    flex-shrink: 0;
}
.group-item.active   { background: #e9e5b6; border-color: #d4c800; color: #333; }
.group-item.inactive { background: #e8e8e8; border-color: #ccc;    color: #999; }
.group-item:hover    { filter: brightness(.94); }

/* ── Layer-Switcher ──────────────────────────────────────────────────────── */
#layer-switcher {
    position: fixed;
    bottom: 8px;
    left: 130px;
    z-index: 100;
    display: flex;
    flex-direction: row;
    gap: 4px;
    align-items: center;
}
.layer-btn {
    background: rgba(255,255,255,0.94);
    border: 1px solid #bbb;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 11px;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    cursor: pointer;
    transition: background .12s, border-color .12s;
    box-shadow: 0 1px 3px rgba(0,0,0,.12);
    white-space: nowrap;
    line-height: 1.4;
}
.layer-btn:hover  { background: #e8e8e8; }
.layer-btn.active { background: #2c72c7; color: #fff; border-color: #1a5caa; }

/* ── Custom Marker ───────────────────────────────────────────────────────── */
.marker-dot {
    width: 14px; height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.9);
    box-shadow: 0 1px 3px rgba(0,0,0,0.45);
    cursor: pointer;
    transition: transform .12s;
}
.marker-dot:hover { transform: scale(1.35); }

/* ── Popup ───────────────────────────────────────────────────────────────── */
#popup {
    position: fixed;
    bottom: 24px; left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.22);
    max-width: 700px;
    width: calc(100vw - 32px);
    max-height: 90vh;
    overflow-y: auto;
    scrollbar-width: thin;
    transition: opacity .18s, left .3s ease, bottom .3s ease;
}
#popup.hidden { display: none; }

#popup-close {
    position: absolute;
    top: 8px; right: 10px;
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: #888;
    line-height: 1;
    z-index: 1;
}
#popup-close:hover { color: #333; }

#popup-content { padding: 14px 16px 14px; }

.popup-name  { font-size: 15px; font-weight: 700; color: #1a1a1a; margin-bottom: 3px; padding-right: 20px; }
.popup-desc  { font-size: 13px; color: #444; margin-bottom: 6px; }
.popup-meta  { font-size: 12px; color: #777; margin-bottom: 2px; }
.popup-bemerkung {
    font-size: 12px;
    color: #444;
    margin-top: 6px;
    line-height: 1.5;
    white-space: pre-wrap;   /* Zeilenumbrueche im Text beibehalten */
    word-break: break-word;
}

/* ── Bilder-Galerie im Popup ─────────────────────────────────────────────── */
.popup-images {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
    align-items: flex-start;
}

.images-loading {
    font-size: 11px;
    color: #aaa;
    font-style: italic;
}

.images-more {
    font-size: 11px;
    color: #888;
    align-self: center;
    padding: 0 4px;
}

/* Jedes Thumbnail direkt im Container */
.thumb-item {
    display: none; /* nicht mehr verwendet, Thumbnails direkt als img */
}

/* Das kleine Vorschau-Bild */
.popup-thumbnail {
    width: 86px;
    height: 64px;
    object-fit: cover;
    border-radius: 5px;
    border: 1px solid #ddd;
    cursor: zoom-in;
    display: block;
    transition: border-color .15s, box-shadow .15s;
}
.popup-thumbnail:hover {
    border-color: #3a7fd4;
    box-shadow: 0 0 0 2px rgba(58,127,212,0.25);
}

/* ── Zoom-Overlay (direkt in body, per JS positioniert) ──────────────────── */
#zoom-overlay {
    display: none;
    position: fixed;
    z-index: 600;
    background: rgba(10, 10, 10, 0.93);
    border-radius: 10px;
    box-shadow: 0 10px 44px rgba(0,0,0,0.6);
    padding: 10px 48px;    /* seitliches Padding fuer Pfeil-Platz */
    pointer-events: auto;
    align-items: center;
    justify-content: center;
    gap: 0;
    max-width: min(560px, 92vw);
    /* Position wird per JS gesetzt: bottom dockt an Popup-Oberkante */
    bottom: auto;
    top: auto;
}
#zoom-overlay.active {
    display: flex;
}

/* Das vergroesserte Bild */
#zoom-overlay .zoom-img {
    display: block;
    max-width: min(460px, 80vw);
    max-height: 62vh;
    object-fit: contain;
    border-radius: 6px;
    background: #111;
}

/* Navigations-Pfeile */
#zoom-overlay .zoom-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.13);
    border: none;
    color: #fff;
    font-size: 2.6rem;
    line-height: 1;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, transform .12s;
    user-select: none;
    padding: 0;
    z-index: 1;
}
#zoom-overlay .zoom-nav:hover {
    background: rgba(255,255,255,0.30);
    transform: translateY(-50%) scale(1.12);
}
#zoom-overlay .zoom-prev { left: 6px; }
#zoom-overlay .zoom-next { right: 6px; }

/* Bild-Zaehler */
#zoom-overlay .zoom-counter {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 11px;
    padding: 2px 9px;
    border-radius: 10px;
    pointer-events: none;
    white-space: nowrap;
}

/* ── Lightbox ────────────────────────────────────────────────────────────── */
#lightbox {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.88);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}
#lightbox.open { display: flex; }
#lightbox img {
    max-width: 90vw; max-height: 88vh;
    border-radius: 8px;
    box-shadow: 0 16px 64px rgba(0,0,0,.7);
}
#lb-close {
    position: absolute; top: 18px; right: 22px;
    color: #fff; font-size: 2rem;
    cursor: pointer; opacity: .7; line-height: 1;
    user-select: none;
}
#lb-close:hover { opacity: 1; }

/* ── MapLibre control override ───────────────────────────────────────────── */
.maplibregl-ctrl-bottom-left  { bottom: 8px; left: 8px; }
.maplibregl-ctrl-bottom-right { bottom: 0;   right: 0;  }
.maplibregl-ctrl-bottom-left .maplibregl-ctrl {
    float: left;
    margin: 0 4px 0 0;
}
.maplibregl-ctrl-attrib { font-size: 10px !important; }
.maplibregl-ctrl-group  { box-shadow: 0 1px 4px rgba(0,0,0,.18) !important; }

.maplibregl-ctrl-fullscreen,
.maplibregl-ctrl-shrink {
    background-color: rgba(255,255,255,0.94) !important;
}
.maplibregl-ctrl-fullscreen:hover,
.maplibregl-ctrl-shrink:hover {
    background-color: #f0f0f0 !important;
}

/* ── Fullscreen ──────────────────────────────────────────────────────────── */
:-webkit-full-screen #group-panel,
:-webkit-full-screen #layer-switcher,
:-webkit-full-screen .map-title,
:-webkit-full-screen #popup,
:-webkit-full-screen #lightbox,
:-webkit-full-screen #zoom-overlay {
    z-index: 2147483647;
}
:fullscreen #group-panel,
:fullscreen #layer-switcher,
:fullscreen .map-title,
:fullscreen #popup,
:fullscreen #lightbox,
:fullscreen #zoom-overlay {
    z-index: 2147483647;
}
