/* File: public/assets/css/style.css | Version: v4.2.1-PopupFix */

/* --- Base & Reset --- */
html, body { 
    margin: 0; padding: 0; 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
    background: #fafafa; color: #111; 
    height: 100dvh; overflow: hidden;
    -webkit-text-size-adjust: 100%;
}

/* --- Header --- */
#header { 
    position: absolute; top: 0; left: 0; width: 100%;
    z-index: 1000;
    padding: 20px 20px 12px 20px; 
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #eaeaea; 
    display: flex; justify-content: space-between; align-items: flex-end; 
    height: 72px; box-sizing: border-box;
}
#header-left { display: flex; flex-direction: column; align-items: flex-start; }
#header-logo { height: 32px; width: auto; display: block; margin-bottom: 4px; }
#counter-sub { margin: 0; color: #666; font-size: 13px; line-height: 1.3; }

#refresh-box { display: flex; align-items: flex-end; gap: 8px; }
#refresh-text { display: flex; flex-direction: column; text-align: right; line-height: 1.3; }
#refresh-label { font-size: 12px; color: #888; font-weight: 500; }
#timestamp-container { font-size: 13px; color: #333; font-weight: 600; white-space: nowrap; }

#refresh-btn { background: transparent; color: #888; border: none; padding: 0; margin-bottom: -1px; font-size: 26px; line-height: 1; cursor: pointer; transition: color 0.2s, transform 0.2s; display: flex; align-items: center; justify-content: center; }
#refresh-btn:hover { color: #111; transform: rotate(45deg); }

/* --- Content & Map --- */
#content-container { height: 100dvh; width: 100%; position: relative; }
#map { position: absolute; top: 0; left: 0; width: 100%; height: 100dvh; z-index: 1; }

/* --- In-Browser Fullscreen Mode --- */
#content-container.browser-fullscreen-mode {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    z-index: 2000 !important;
}
#content-container.browser-fullscreen-mode #map {
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100dvh !important;
    border-radius: 0 !important;
    margin: 0 !important;
}
#content-container.browser-fullscreen-mode #liste {
    display: none !important;
}
#content-container.browser-fullscreen-mode .site-footer {
    display: none !important;
}

/* --- Livetrafik Custom Map Controls --- */
.livetrafik-control {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    border-radius: 14px !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12) !important;
    overflow: hidden;
    margin-right: 20px !important;
    margin-bottom: 70px !important;
}
.livetrafik-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 40px !important;
    height: 40px !important;
    background: #ffffff !important;
    color: #444444 !important;
    border-bottom: 1px solid #f0f0f0 !important;
    text-decoration: none !important;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.livetrafik-btn:last-child {
    border-bottom: none !important;
}
.livetrafik-btn:hover {
    background: #f8f9fa !important;
    color: #007aff !important;
}

/* --- Overlay Liste (Desktop) --- */
#liste { 
    position: absolute;
    top: 92px; left: 20px;
    width: 400px;
    height: calc(100dvh - 165px);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    z-index: 900;
    display: flex; flex-direction: column;
    box-sizing: border-box;
    padding: 24px 20px;
}
#liste-eintraege { flex-grow: 1; overflow-y: auto; padding-right: 5px; }

/* --- List Header & Sorting --- */
.liste-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.liste-header h3 { font-size: 13px; font-weight: 600; color: #888; text-transform: uppercase; letter-spacing: 0.5px; margin: 0; }

.sort-toggle, 
.sort-toggle:link, 
.sort-toggle:visited, 
.sort-toggle:focus, 
.sort-toggle:active { 
    font-size: 13px; 
    font-weight: 600; 
    color: #888888 !important; 
    cursor: pointer; 
    user-select: none; 
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent !important; 
    transition: color 0.2s; 
    text-decoration: none; 
}
@media (hover: hover) {
    .sort-toggle:hover { color: #111111 !important; }
}

.category-title { font-size: 13px !important; font-weight: 600 !important; color: #888888 !important; text-transform: uppercase !important; letter-spacing: 0.5px !important; margin: 24px 0 10px 4px !important; }
.section-divider { border: 0; border-top: 1px solid #e5e7eb; margin: 28px 0; }

/* --- BSW Accordion --- */
.bsw-accordion-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent !important; margin: 24px 0 10px 4px; }
.bsw-accordion-header:hover .category-title { color: #111 !important; }
.bsw-toggle-icon { font-size: 12px; color: #888; font-weight: 600; transition: transform 0.2s; }
.bsw-toggle-icon.open { transform: rotate(90deg); }
.bsw-content-wrapper { display: none; }
.bsw-content-wrapper.open { display: block; }

/* --- Einsatz Rows --- */
.einsatz-row { 
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px 16px; 
    font-size: 14px; 
    cursor: pointer; 
    transition: all 0.2s ease; 
    display: flex; 
    flex-direction: column; 
    gap: 8px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    box-sizing: border-box;
}
.einsatz-row:hover { 
    background: #fff; 
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    transform: translateY(-1px);
}
.einsatz-row:hover .einsatz-main-line { color: #007aff; }
.einsatz-row.active {
    background: #fff;
    border-color: #94a3b8;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.einsatz-main-line { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.einsatz-forces-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-height: 18px; font-size: 13px; color: #555; }
.einsatz-forces-line span { cursor: help; user-select: none; }
.badge { padding: 3px 6px; border-radius: 4px; font-weight: 600; font-size: 11px; color: white; min-width: 28px; text-align: center; }

/* --- Leaflet Popups (Ultra-kompakt & Kollisionsfrei) --- */
.custom-popup .leaflet-popup-content-wrapper { 
    border-radius: 12px; 
    padding: 12px 14px !important; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.08); 
    border: none; 
    background: #fff; 
}
.custom-popup .leaflet-popup-content { margin: 0; width: 230px !important; }
.custom-popup .leaflet-popup-tip { background: #fff; box-shadow: none; border: none; }
.custom-popup .leaflet-popup-close-button { 
    position: absolute !important; 
    top: 10px !important; 
    right: 10px !important; 
    color: #bbb !important; 
    font-size: 16px !important; 
    font-weight: 400 !important; 
    background: none !important; 
    border: none !important; 
    text-decoration: none !important; 
    z-index: 10;
}
.custom-popup .leaflet-popup-close-button:hover { color: #111 !important; }

/* padding-right schafft Platz für den Schließen-Button, damit die Uhrzeit nicht kollidiert */
.popup-top-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 2px; padding-right: 22px; }
.popup-stufe { font-size: 18px; font-weight: 800; color: #111; line-height: 1.1; letter-spacing: -0.5px; }
.popup-zeit { font-size: 12px; font-weight: 600; color: #666; }
.popup-art { font-size: 13px; font-weight: 500; color: #555; margin-bottom: 6px; }
.popup-meta-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #333; margin: 2px 0; font-weight: 500; }
.popup-divider-line { border-top: 1px solid #f0f0f0; margin: 8px 0; }

.unit-box-modern { font-size: 12px; color: #444; max-height: 110px; overflow-y: auto; line-height: 1.4; padding-right: 2px; }
.unit-feuerwehr-header { font-weight: 700; color: #222; margin-top: 6px; margin-bottom: 2px; display: flex; align-items: center; gap: 4px; }
.unit-feuerwehr-header:first-child { margin-top: 0; }
.unit-vehicle-item { font-weight: 500; color: #555; padding-left: 14px; margin: 2px 0; display: flex; align-items: center; gap: 4px; }

.popup-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; padding-top: 6px; border-top: 1px solid #f5f5f5; }
.nav-btn { background: #f8f9fa; border: 1px solid #eaeaea; font-size: 12px; color: #666; cursor: pointer; padding: 2px 8px; border-radius: 4px; transition: background 0.2s, color 0.2s; user-select: none; }
.nav-btn:hover { background: #111; color: #fff; border-color: #111; }
.nav-count { font-size: 11px; color: #aaa; font-weight: 600; letter-spacing: 0.3px; }

/* --- Site Footer --- */
.site-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 18px 20px;
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid #eaeaea;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    box-sizing: border-box;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 8px;
}
.footer-links { 
    font-size: 0.85rem; 
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}
.footer-links a { color: #6c757d; text-decoration: none; transition: color 0.2s ease; }
.footer-links a:hover { color: #212529; text-decoration: underline; }
.footer-separator { color: #ced4da; margin: 0 8px; font-size: 0.75rem; }

/* --- Legal Pages Styling --- */
.legal-body {
    background-color: #fafafa !important;
    color: #888888 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    padding: 0;
    -webkit-text-size-adjust: 100%;
}
.legal-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 30px 20px;
    line-height: 1.6;
}
.legal-container h1 {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #888888 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    margin-top: 0 !important;
    margin-bottom: 20px !important;
}
.legal-container h2 {
    font-size: 16px !important;
    font-weight: 600 !important;
    color: #888888 !important;
    margin: 32px 0 12px 0 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}
.legal-container p,
.legal-container li,
.legal-container div,
.legal-container strong,
.legal-meta {
    font-size: 15px !important;
    color: #888888 !important;
}
.legal-container ul,
.legal-container ol {
    padding-left: 20px;
    margin-bottom: 16px;
}
.legal-container li {
    margin-bottom: 6px;
}
.header-back-btn {
    color: #007aff !important;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    transition: opacity 0.2s;
}
.header-back-btn:hover {
    opacity: 0.7;
}
.bottom-nav {
    margin-top: 50px;
    padding-top: 20px;
    border-top: 1px solid #eaeaea;
}

/* --- Responsive Queries --- */
@media (max-width: 1023px) {
    html, body { overflow: auto; height: auto; }
    #header { position: sticky; }
    #content-container { height: auto; }
    
    #map { 
        position: relative; 
        height: 50vh; 
        width: calc(100% - 32px); 
        margin: 16px auto 0 auto; 
        border-radius: 16px; 
        box-shadow: 0 4px 16px rgba(0,0,0,0.1);
        box-sizing: border-box;
    }
    #liste { 
        position: relative; top: 0; left: 0; width: 100%; 
        height: auto; background: #f8f9fa; border-radius: 0; 
        box-shadow: none; padding: 24px 16px; border: none;
    }
    .site-footer {
        position: relative;
        bottom: auto;
        left: auto;
        width: 100%;
        height: auto;
        background: #f8f9fa;
        border-top: 1px solid #eaeaea;
        padding: 20px;
        box-sizing: border-box;
        flex-wrap: wrap;
    }
    .livetrafik-control {
        margin-bottom: 15px !important;
        margin-right: 15px !important;
    }
}
@media (max-width: 768px) {
    .custom-popup .leaflet-popup-content-wrapper { padding: 10px 12px !important; border-radius: 10px !important; }
    .custom-popup .leaflet-popup-content { width: 210px !important; }
    .popup-stufe { font-size: 16px !important; }
    .popup-zeit { font-size: 11px !important; }
    .popup-art { font-size: 12px !important; margin-bottom: 4px !important; }
    .popup-meta-item { font-size: 11px !important; margin: 2px 0 !important; }
    .popup-divider-line { margin: 6px 0 !important; }
    .unit-box-modern { max-height: 100px !important; font-size: 11px !important; }
    .custom-popup .leaflet-popup-close-button { top: 8px !important; right: 8px !important; }
}