/* Flohmarkt Karte - Optimierte Styles mit display_mode Support */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Helvetica', 'Arial', sans-serif;
}

body {
    background-color: #f8f8f8;
    color: #333;
    line-height: 1.6;
    padding: 10px;
    max-width: 100%;
    overflow-x: hidden;
    -webkit-user-select: none;
    user-select: none;
}

/* KOMPAKTER HEADER - ALLES IN EINER ZEILE */
.compact-header {
    text-align: center;
    margin-bottom: 10px;
    padding: 6px 8px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.compact-header h1 {
    color: #e74c3c;
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    white-space: nowrap;
}

.event-info-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #666;
    flex-wrap: wrap;
}

.event-date {
    color: #e74c3c;
    font-weight: 500;
    white-space: nowrap;
}

.event-time {
    color: #666;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.calendar-button {
    background: none;
    color: #e74c3c;
    border: none;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    padding: 2px;
    text-decoration: none;
    border-radius: 4px;
}

.calendar-button:hover {
    background-color: rgba(231, 76, 60, 0.1);
    transform: scale(1.1);
}

.calendar-button:active {
    transform: scale(0.95);
}

/* Toast Notification für Kalender-Download */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #28a745;
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.3s ease;
    max-width: 300px;
    font-size: 14px;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.error {
    background-color: #dc3545;
}

.toast.info {
    background-color: #17a2b8;
}

.filter-container {
    background-color: #fff;
    padding: 8px;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.filter-container h2 {
    font-size: 15px;
    margin-bottom: 6px;
    color: #555;
}

.categories {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 6px;
}

.category-btn {
    background-color: #e0e0e0;
    border: none;
    border-radius: 20px;
    padding: 5px 10px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    gap: 4px;
}

.category-btn.active {
    background-color: #e74c3c;
    color: white;
}

.map-container {
    position: relative;
    background-color: #fff;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    height: 80vh;
    max-height: 900px;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* *** BENUTZERSTANDORT-CONTROL *** */
.user-location-control {
    background: white;
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
    margin-top: 10px;
}

.user-location-btn {
    display: block;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    text-decoration: none;
    color: #333;
    font-size: 16px;
    border-radius: 4px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.user-location-btn:hover {
    background-color: #f4f4f4;
    color: #007bff;
}

.user-location-btn.loading {
    animation: pulse 1.5s infinite;
    pointer-events: none;
}

.user-location-btn.active {
    background-color: #007bff;
    color: white;
}

.user-location-btn.active:hover {
    background-color: #0056b3;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* *** BENUTZERSTANDORT-MARKER *** */
.user-location-marker {
    background: transparent !important;
    border: none !important;
}

.user-location-icon {
    position: relative;
    width: 24px;
    height: 24px;
}

.user-location-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background-color: #007bff;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 123, 255, 0.5);
    z-index: 2001;
}

.user-location-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    background-color: rgba(0, 123, 255, 0.3);
    border-radius: 50%;
    animation: locationPulse 2s infinite;
}

@keyframes locationPulse {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

.user-location-popup {
    text-align: center;
    font-size: 13px;
    line-height: 1.4;
}

.user-location-popup strong {
    color: #007bff;
}

.user-location-popup small {
    color: #666;
}

/* *** LEAFLET LAYER CONTROL ANPASSUNGEN *** */
.leaflet-control-layers {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.leaflet-control-layers-expanded {
    padding: 8px 12px;
}

.leaflet-control-layers-toggle {
    background-color: white;
    border-radius: 4px;
    width: 30px;
    height: 30px;
}

.leaflet-control-layers-toggle:hover {
    background-color: #f4f4f4;
}

.leaflet-control-layers label {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    padding: 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.leaflet-control-layers label:hover {
    color: #007bff;
}

.leaflet-control-layers input[type="radio"] {
    margin-right: 8px;
}

/* *** ERWEITERTE MARKER-STYLES FÜR DISPLAY_MODE *** */

/* Custom Marker Klasse - Basis für alle Marker */
.custom-numbered-marker {
    background: transparent !important;
    border: none !important;
    font-family: 'Helvetica', 'Arial', sans-serif;
}

/* Marker Elemente selbst */
.custom-numbered-marker > div {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-family: 'Helvetica', 'Arial', sans-serif !important;
    line-height: 1 !important;
    text-align: center !important;
    /* Basis-Transition für smooth Animationen */
    transition: all 0.3s ease !important;
    /* Basis-Eigenschaften */
    cursor: pointer !important;
    user-select: none !important;
}

/* Display Mode spezifische Anpassungen */

/* Color with Number Marker */
.custom-numbered-marker > div[style*="border-radius: 50%"] {
    /* Spezifische Styles für color_with_number und color_only */
}

/* Icon Only Marker - größere Touch-Targets und höherer z-index */
.custom-numbered-marker > div[style*="background: transparent"] {
    /* Icon-only Marker haben bereits optimierte Größe durch JavaScript */
    min-width: 40px !important;
    min-height: 40px !important;
    z-index: 1000 !important;
    position: relative !important;
}

/* Hover-Effekte für alle Marker-Typen */
.custom-numbered-marker:hover > div {
    transform: scale(1.2) !important;
    z-index: 1001 !important;
}

/* Marker Highlighting */
.marker-highlighted {
    transform: scale(1.3) !important;
    z-index: 1002 !important;
    filter: brightness(1.1) !important;
}

/* Leaflet Standard-Marker-Shadow ausblenden */
.leaflet-marker-shadow {
    display: none !important;
}

/* Leaflet DivIcon Container cleanen */
.leaflet-div-icon {
    background: transparent !important;
    border: none !important;
}

.info-box {
    display: none;
    position: absolute;
    bottom: 15px;
    left: 15px;
    right: 15px;
    background-color: rgba(255, 255, 255, 0.95);
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    max-height: 70%;
    overflow-y: auto;
}

.info-box h3 {
    margin-bottom: 5px;
    font-size: 16px;
    color: #e74c3c;
}

.info-box p.address {
    font-style: italic;
    margin-bottom: 8px;
    font-size: 13px;
    color: #666;
}

.info-box-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
}

.info-category {
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 3px;
}

.contact-info {
    margin-top: 8px;
    font-size: 13px;
}

.contact-info p {
    margin-bottom: 4px;
}

.contact-info a {
    color: #e74c3c;
    text-decoration: none;
}

.contact-info a:hover {
    text-decoration: underline;
}

.close-info {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: #777;
    -webkit-tap-highlight-color: transparent;
}

/* ERWEITERTE LEGENDE mit display_mode Support */
.legend {
    display: flex;
    justify-content: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 12px;
    border-radius: 8px;
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    font-size: 12px;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.legend-item:hover {
    background-color: rgba(231, 76, 60, 0.1);
}

/* Legend Color Dot - für color_with_number und color_only */
.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

/* Legend Icon - für icon_only */
.legend-icon {
    font-size: 16px;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
    flex-shrink: 0;
}

.legend-item span {
    font-weight: 500;
    color: #333;
    white-space: nowrap;
}

.error-message {
    background-color: #f8d7da;
    color: #721c24;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 5px;
    text-align: center;
    display: none;
}

.no-locations {
    text-align: center;
    color: #666;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 255, 255, 0.8);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    max-width: 80%;
}

/* FOOTER - ZURÜCK ZUM ORIGINAL MIT LOGIN */
.copyright-footer {
    text-align: center;
    font-size: 12px;
    color: #777;
    padding: 10px 0;
    margin-top: 10px;
    border-top: 1px solid #e0e0e0;
}

.login-link {
    color: #e74c3c;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.login-link:hover {
    color: #c0392b;
    text-decoration: underline;
}

.impressum-link {
    color: #777;
    cursor: pointer;
    text-decoration: underline;
}

#content {
    display: flex;
    flex-direction: column;
    max-height: 100vh;
    overflow: hidden;
}

.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #e74c3c;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 9999;
    transition: opacity 0.5s;
}

.splash-screen img {
    width: 80px;
    height: 80px;
    margin-bottom: 12px;
}

.splash-screen h1 {
    color: white;
    font-size: 20px;
    margin-bottom: 6px;
}

.splash-screen p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
}

/* *** LEAFLET POPUP ANPASSUNGEN *** */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.leaflet-popup-content {
    margin: 8px 12px;
    line-height: 1.4;
    font-size: 13px;
}

.marker-popup h3 {
    margin-bottom: 5px;
    color: #e74c3c;
}

.marker-popup p {
    margin-bottom: 5px;
}

/* *** MARKER FILTER ANIMATIONS - ERWEITERT FÜR DISPLAY_MODE *** */
.custom-numbered-marker > div {
    /* Filter-Transitions für smooth Übergänge */
    transition: all 0.3s ease, opacity 0.3s ease, transform 0.3s ease !important;
}

/* Gefilterte Marker - verschiedene Behandlung je nach display_mode */
.marker-filtered {
    opacity: 0.2 !important;
    pointer-events: none;
}

/* Für farbige Marker (color_with_number, color_only) */
.marker-filtered[style*="border-radius: 50%"] {
    transform: scale(0.7) !important;
}

/* Für Icon-Marker (icon_only) - höhere z-index Priorität */
.marker-filtered[style*="background: transparent"] {
    transform: scale(0.6) !important;
    filter: grayscale(0.8) drop-shadow(0 1px 2px rgba(0,0,0,0.3)) !important;
    z-index: 999 !important;
}

/* Highlighted Marker - verschiedene Effekte je nach display_mode */
.marker-highlighted {
    z-index: 1001 !important;
}

/* Farbige Marker Highlight */
.marker-highlighted[style*="border-radius: 50%"] {
    transform: scale(1.3) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4), 0 0 0 4px rgba(255, 255, 255, 0.8) !important;
}

/* Icon Marker Highlight - höchste Priorität */
.marker-highlighted[style*="background: transparent"] {
    transform: scale(1.4) !important;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.6)) brightness(1.1) !important;
    z-index: 1003 !important;
}

/* *** ACCESSIBILITY VERBESSERUNGEN *** */
.category-btn:focus,
.close-info:focus,
.calendar-button:focus,
.login-link:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Focus für Marker */
.custom-numbered-marker:focus > div {
    outline: 3px solid #007bff;
    outline-offset: 2px;
}

/* *** REDUCED MOTION SUPPORT *** */
@media (prefers-reduced-motion: reduce) {
    .custom-numbered-marker > div,
    .category-btn,
    .toast,
    .calendar-button,
    .login-link,
    .legend-item {
        transition: none !important;
        animation: none !important;
    }

    .marker-highlighted {
        transform: none !important;
    }
}

/* *** HIGH CONTRAST MODE SUPPORT *** */
@media (prefers-contrast: high) {
    .custom-numbered-marker > div {
        border-width: 4px !important;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9) !important;
    }
    
    .custom-numbered-marker > div[style*="background: transparent"] {
        filter: drop-shadow(0 2px 4px rgba(0,0,0,0.9)) contrast(1.5) !important;
    }

    .info-box {
        border: 3px solid #000;
        background-color: white !important;
    }

    .category-btn {
        border: 2px solid #333;
    }

    .legend {
        border: 2px solid #333;
        background-color: white !important;
    }
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 5px;
    }

    .compact-header {
        padding: 5px;
        margin-bottom: 8px;
    }

    .header-content {
        gap: 8px;
    }

    .compact-header h1 {
        font-size: 16px;
    }

    .event-info-inline {
        font-size: 12px;
        gap: 6px;
    }

    .event-time {
        font-size: 11px;
    }

    .categories {
        justify-content: center;
    }

    .category-btn {
        font-size: 12px;
        padding: 4px 8px;
    }

    /* Mobile User Location Control */
    .user-location-control {
        margin-top: 5px;
    }

    .user-location-btn {
        width: 34px;
        height: 34px;
        line-height: 34px;
        font-size: 18px;
    }

    /* Mobile Layer Control */
    .leaflet-control-layers {
        font-size: 12px;
    }

    .leaflet-control-layers-toggle {
        width: 34px;
        height: 34px;
    }

    /* Mobile Legend - kompakter */
    .legend {
        flex-direction: column;
        gap: 4px;
        padding: 6px 8px;
        left: 10px;
        right: 10px;
        transform: none;
        font-size: 11px;
        max-height: 120px;
        overflow-y: auto;
    }

    .legend-item {
        gap: 4px;
        justify-content: flex-start;
    }

    .legend-color {
        width: 10px;
        height: 10px;
    }

    .legend-icon {
        font-size: 14px;
        width: 14px;
        height: 14px;
    }

    .info-box {
        bottom: 10px;
        left: 10px;
        right: 10px;
        max-height: 50%;
    }

    /* Mobile Marker-Anpassungen - Touch-optimiert */
    .custom-numbered-marker > div {
        min-width: 28px !important;
        min-height: 28px !important;
    }

    /* Farbige Marker */
    .custom-numbered-marker > div[style*="border-radius: 50%"] {
        font-size: 11px !important;
    }

    /* Icon Marker - größer für Touch */
    .custom-numbered-marker > div[style*="background: transparent"] {
        font-size: 28px !important;
        min-width: 42px !important;
        min-height: 42px !important;
    }

    .map-container {
        height: 75vh;
    }

    .toast {
        bottom: 15px;
        right: 15px;
        left: 15px;
        max-width: none;
    }
}

@media (min-width: 768px) {
    body {
        padding: 15px;
    }

    .compact-header h1 {
        font-size: 20px;
    }

    .map-container {
        height: 75vh;
    }

    /* Desktop Legend - horizontal scrollbar falls nötig */
    .legend {
        max-width: 90%;
        overflow-x: auto;
        flex-wrap: nowrap;
    }
}

@media (max-width: 480px) {
    .header-content {
        flex-direction: column;
        gap: 4px;
    }

    /* Sehr kleine Marker für kleinste Bildschirme */
    .custom-numbered-marker > div {
        min-width: 25px !important;
        min-height: 25px !important;
    }

    .custom-numbered-marker > div[style*="border-radius: 50%"] {
        font-size: 10px !important;
    }

    .custom-numbered-marker > div[style*="background: transparent"] {
        font-size: 26px !important;
        min-width: 38px !important;
        min-height: 38px !important;
    }

    .map-container {
        height: 70vh;
    }

    .info-box {
        bottom: 5px;
        left: 5px;
        right: 5px;
        padding: 10px;
        max-height: 45%;
    }

    .legend {
        left: 5px;
        right: 5px;
        font-size: 10px;
        padding: 4px 6px;
    }
}

/* *** PRINT STYLES *** */
@media print {
    .map-controls,
    .categories,
    .copyright-footer,
    .calendar-button,
    .legend {
        display: none !important;
    }

    .map-container {
        height: 400px !important;
        border: 2px solid #000;
    }

    .info-box {
        position: relative !important;
        display: block !important;
        margin-top: 20px;
        box-shadow: none;
        border: 1px solid #000;
    }

    .compact-header {
        box-shadow: none;
        border: 1px solid #ccc;
    }

    /* Print-optimierte Marker */
    .custom-numbered-marker > div {
        border-width: 2px !important;
        font-weight: bold !important;
    }
}