/*
 * Artist Events & Tours - Style
 * Version: 5.0.2 (Korrekte X-Button Lösung)
 */

/* Event-Listen-Container - KORRIGIERT für bessere Responsivität */
.aem-event-list {
    display: grid;
    /* min() Funktion für bessere Responsivität */
    grid-template-columns: repeat(auto-fill, minmax(min(400px, 100%), 1fr));
    gap: 20px;
    padding: 20px 0;
}

/* Einzelne Event-Karte - ALLES LINKSBÜNDIG */
.aem-event-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    text-align: left !important; /* Grundsätzlich linksbündig */
}
.aem-event-card:hover {
    transform: translateY(-5px);
}

/* HIGHLIGHT ANIMATION FÜR SCROLL-TO-EVENT */
.aem-event-card.aem-highlight {
    animation: highlightPulse 3s ease-out;
    box-shadow: 0 0 20px rgba(107, 58, 160, 0.6);
}

@keyframes highlightPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(107, 58, 160, 0.6);
    }
    20% {
        transform: scale(1.02);
        box-shadow: 0 0 30px rgba(107, 58, 160, 0.8);
    }
    40% {
        transform: scale(1.01);
        box-shadow: 0 0 25px rgba(107, 58, 160, 0.7);
    }
    60% {
        transform: scale(1.005);
        box-shadow: 0 0 20px rgba(107, 58, 160, 0.6);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    }
}

/* Datumsblock - BLEIBT ZENTRIERT (ist OK so) */
.aem-date-block {
    background-color: #6b3aa0;
    color: #fff;
    padding: 15px;
    text-align: center; /* Datum bleibt zentriert */
}
.aem-day {
    font-size: 2.5em;
    font-weight: 700;
    line-height: 1;
}
.aem-month-year {
    font-size: 0.9em;
    text-transform: uppercase;
}

/* Event-Inhalte - ALLES LINKSBÜNDIG */
.aem-event-content {
    flex-grow: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-align: left !important; /* Immer linksbündig */
}

.aem-event-content * {
    text-align: left !important; /* Alle Kinder auch linksbündig */
}

.aem-event-title {
    font-size: 1.4em;
    margin: 0 0 5px 0;
    text-align: left !important;
}
.aem-location-details {
    font-size: 0.9em;
    color: #666;
    margin: 0;
    text-align: left !important;
}
.aem-location-details strong {
    text-align: left !important;
}

.aem-event-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    text-align: left !important;
}
.aem-event-time {
    font-size: 1em;
    color: #6b3aa0;
    font-weight: 600;
    text-align: left !important;
}
.aem-ticket-button {
    background-color: #6b3aa0;
    color: #fff;
    padding: 10px 20px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    text-align: center; /* Button Text kann zentriert bleiben */
}

.aem-ticket-button:hover {
    background-color: #360c63;
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
}

.aem-ticket-button.status-pending, .aem-ticket-button.status-soldout {
    background-color: #f3f4f6;
    color: #6b7280;
    cursor: default;
}
.aem-ticket-button.status-soldout {
    background-color: #e5e7eb;
}

/* Google Map */
.aem-map-container { width: 100%; margin-top: 20px; }
.aem-map { height: 500px; width: 100%; border-radius: 12px; }

/* "Mehr laden" Button - IMMER SICHTBAR */
.aem-load-more-wrapper { 
    text-align: center; 
    margin-top: 20px;
    /* Button bleibt immer sichtbar */
    display: block !important;
}

.aem-load-more-wrapper[data-always-visible="true"] {
    /* Spezielle Behandlung für immer sichtbaren Button */
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.aem-load-more-button {
    padding: 0.75rem 2rem;
    background-color: #f3f4f6;
    border: 1px solid #e5e7eb;
    color: #374151;
    font-weight: 500;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}
.aem-load-more-button:hover:not(:disabled) {
    background-color: #e5e7eb;
}
.aem-load-more-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #e5e7eb;
}

/* =============================================================================
 * SUCHFELD STYLING - KLEINER UND RECHTSBÜNDIG
 * ============================================================================= */

/* Container für Suchfeld */
.aem-map-search-container {
    margin-top: 15px;
    text-align: right;
    padding: 15px;
    background: #f9fafb;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

/* Inner Container für rechtsbündige Ausrichtung */
.aem-search-inner {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Suchfeld Input - kleiner */
.aem-city-search-input {
    padding: 8px 15px;
    width: 200px;
    border: 2px solid #6b3aa0;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.aem-city-search-input:focus {
    border-color: #5a3085;
    box-shadow: 0 0 0 3px rgba(107, 58, 160, 0.1);
}

.aem-city-search-input::placeholder {
    color: #9ca3af;
}

/* Such-Button - kleiner */
.aem-search-button {
    padding: 8px 18px;
    background-color: #6b3aa0;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.aem-search-button:hover {
    background-color: #5a3085;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(107, 58, 160, 0.3);
}

.aem-search-button:active {
    transform: translateY(0);
}

/* Reset-Button - kleiner */
.aem-reset-button {
    padding: 8px 18px;
    background-color: #f3f4f6;
    color: #374151;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.aem-reset-button:hover {
    background-color: #e5e7eb;
    border-color: #d1d5db;
}

.aem-reset-button:active {
    transform: translateY(0);
}

/* Marker-Zähler Styling */
.aem-marker-count {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 10px;
    font-weight: 500;
}

/* =============================================================================
 * GEFILTERTE EVENT-LISTE UNTER DEM SUCHFELD
 * ============================================================================= */

/* Container für gefilterte Events */
.aem-filtered-events-container {
    display: none; /* Standardmäßig versteckt */
    margin-top: 30px;
    padding: 20px;
    background: #f9fafb;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Überschrift für gefilterte Events - LINKSBÜNDIG */
.aem-filtered-events-container::before {
    content: 'Gefilterte Veranstaltungen:';
    display: block;
    font-size: 18px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 20px;
    text-align: left !important; /* Linksbündig */
}

/* Event-Liste innerhalb des gefilterten Containers - LINKSBÜNDIG */
#aem-event-list-filtered {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(350px, 100%), 1fr));
    gap: 20px;
    padding: 0;
    text-align: left !important; /* Container auch linksbündig */
}

/* Spezifisch für gefilterte Events */
#aem-event-list-filtered .aem-event-card {
    text-align: left !important;
}

#aem-event-list-filtered .aem-event-card * {
    text-align: left !important;
}

/* Nur Buttons und Datum behalten ihre Zentrierung */
#aem-event-list-filtered .aem-date-block {
    text-align: center !important;
}

#aem-event-list-filtered .aem-ticket-button {
    text-align: center !important;
}

/* =============================================================================
 * NEUE STYLES FÜR VERBESSERTE FILTERUNG
 * ============================================================================= */

/* Trennung zwischen regulärer Liste und gefilterter Liste */
.aem-event-list-container {
    transition: opacity 0.3s ease;
}

/* Gefilterte Events hervorheben */
#aem-filtered-events {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Info-Text bei leeren Suchergebnissen - LINKSBÜNDIG */
.no-events {
    text-align: left !important; /* Linksbündig statt zentriert */
    padding: 40px 20px;
    color: #6b7280;
    font-size: 16px;
    background: #f9fafb;
    border-radius: 12px;
    margin: 20px 0;
}

/* Lade-Indikator für gefilterte Events - LINKSBÜNDIG */
#aem-event-list-filtered p {
    text-align: left !important; /* Linksbündig statt zentriert */
    padding: 20px;
    color: #6b3aa0;
    font-weight: 500;
}

/* =============================================================================
 * GOOGLE MAPS INFOWINDOW STYLES - KORREKTE X-BUTTON LÖSUNG
 * ============================================================================= */

/* InfoWindow Grundstyles */
.gm-style .gm-style-iw-c {
    border-radius: 12px !important;
    overflow: hidden !important;
    box-shadow: 0 10px 40px rgba(107, 58, 160, 0.15) !important;
    max-width: 420px !important;
    min-width: 350px !important;
    padding: 0 !important;
}

.gm-style-iw-d {
    overflow: visible !important;
    padding: 0 !important;
    max-width: none !important;
}

/* =============================================================================
 * KORREKTER X-BUTTON FIX für echte Google Maps Struktur
 * ============================================================================= */

/* Der Button selbst - 48x48px ist von Google vorgegeben */
.gm-ui-hover-effect {
    /* Basis-Styles für den runden Button */
    background: rgba(255, 255, 255, 0.95) !important;
    border-radius: 50% !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    transition: all 0.2s ease !important;
    
    /* Position ist bereits durch Google gesetzt, nur Fine-tuning */
    top: 12px !important;
    right: 12px !important;
    z-index: 99999 !important;
}

/* Hover-Effekt für den Button */
.gm-ui-hover-effect:hover {
    background: rgba(255, 255, 255, 1) !important;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2) !important;
    transform: scale(1.05) !important;
}

/* Das innere Span mit dem X-Symbol */
.gm-ui-hover-effect span {
    /* Google setzt bereits margin: 12px - das sollte zentriert sein */
    /* Aber wir forcieren es nochmal zur Sicherheit */
    display: block !important;
    margin: 12px !important;
    width: 24px !important;
    height: 24px !important;
    
    /* Das SVG-Mask wird von Google gesetzt */
    background-color: #666 !important;
    -webkit-mask-size: 24px 24px !important;
    mask-size: 24px 24px !important;
    -webkit-mask-position: center !important;
    mask-position: center !important;
    -webkit-mask-repeat: no-repeat !important;
    mask-repeat: no-repeat !important;
}

/* Hover-Effekt für das X-Symbol */
.gm-ui-hover-effect:hover span {
    background-color: #333 !important;
}

/* Alternative: Falls das nicht funktioniert, Button komplett neu positionieren */
.gm-style-iw-chr {
    position: relative !important;
}

.gm-style-iw-chr .gm-ui-hover-effect {
    position: absolute !important;
    top: -24px !important; /* Button außerhalb des Headers positionieren */
    right: -24px !important;
    background: white !important;
    border-radius: 50% !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2) !important;
    border: 2px solid #fff !important;
    width: 48px !important;
    height: 48px !important;
    z-index: 99999 !important;
}

/* Container für bessere Struktur */
.aem-infowindow {
    min-width: 350px;
}

/* Header mit genug Platz für 48px Button */
.aem-infowindow-header {
    background-color: #6b3aa0;
    color: white;
    padding: 15px 60px 15px 15px !important; /* 60px Platz für 48px Button + Abstand */
    font-size: 1.1em;
    font-weight: 600;
    position: relative;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

/* Multi-Event Popup Styles - SCROLLBAR OPTIMIERT */
.aem-multi-event .aem-infowindow-body {
    max-height: 320px; /* Etwas niedriger für bessere Mobile-Ansicht */
    overflow-y: auto;
    overflow-x: hidden;
    /* Schöne Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: #6b3aa0 #f0f0f0;
}

/* Webkit Scrollbar Styling */
.aem-multi-event .aem-infowindow-body::-webkit-scrollbar {
    width: 6px;
}

.aem-multi-event .aem-infowindow-body::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 3px;
}

.aem-multi-event .aem-infowindow-body::-webkit-scrollbar-thumb {
    background: #6b3aa0;
    border-radius: 3px;
}

.aem-multi-event .aem-infowindow-body::-webkit-scrollbar-thumb:hover {
    background: #5a3085;
}

.aem-infowindow-address {
    padding: 10px 15px;
    background: #f7f3fb;
    margin: 0 -15px 15px -15px;
    font-size: 14px;
    color: #666;
    border-bottom: 2px solid #e5d9f2;
}

.aem-event-list-popup {
    padding-right: 5px; /* Platz für Scrollbar */
}

.aem-event-list-popup h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #6b3aa0;
    padding-right: 10px;
}

.aem-popup-event-item {
    padding: 12px;
    margin-bottom: 8px;
    margin-right: 5px; /* Abstand zur Scrollbar */
    background: #f9f9f9;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 5px;
    text-decoration: none !important;
    color: #333 !important;
    position: relative;
}

a.aem-popup-event-item.aem-has-tickets {
    text-decoration: none !important;
}

.aem-popup-event-item:hover {
    background: #6b3aa0;
    color: white !important;
    transform: translateX(3px); /* Weniger Bewegung */
}

.aem-popup-event-date {
    font-size: 12px;
    font-weight: 600;
    color: inherit;
}

.aem-popup-event-title {
    font-size: 14px;
    font-weight: 500;
    color: inherit;
    line-height: 1.3;
}

.aem-popup-event-status {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    display: inline-block;
    margin-top: 4px;
    align-self: flex-start;
}

.aem-popup-event-status.available {
    background: #10b981;
    color: white;
}

.aem-popup-event-status.soldout {
    background: #ef4444;
    color: white;
}

.aem-popup-event-status.pending {
    background: #f59e0b;
    color: white;
}

.aem-popup-event-item:hover .aem-popup-event-date,
.aem-popup-event-item:hover .aem-popup-event-title,
.aem-popup-event-item:hover .aem-popup-event-status {
    color: white !important;
}

.aem-popup-event-item:hover .aem-popup-event-status {
    background: rgba(255,255,255,0.2);
}

/* =============================================================================
 * RESPONSIVE DESIGN - VERBESSERT
 * ============================================================================= */

@media (max-width: 768px) {
    /* Event-Liste wird einspaltig */
    .aem-event-list,
    #aem-event-list-filtered {
        grid-template-columns: 1fr;
    }
    
    /* Suchfeld Container */
    .aem-map-search-container {
        text-align: center;
        padding: 12px;
    }
    
    .aem-search-inner {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        width: 100%;
    }
    
    .aem-city-search-input {
        width: 100%;
        max-width: 300px;
        font-size: 16px; /* Verhindert Zoom auf iOS */
    }
    
    .aem-search-button,
    .aem-reset-button {
        flex: 1;
        min-width: 120px;
        font-size: 14px;
    }
}

/* Kleinere Bildschirme */
@media (max-width: 480px) {
    .aem-map-search-container {
        padding: 10px;
    }
    
    .aem-search-button,
    .aem-reset-button {
        font-size: 13px;
        padding: 7px 14px;
    }
    
    .aem-city-search-input {
        font-size: 14px;
        padding: 7px 12px;
    }
    
    /* Event-Karten auf kleinen Bildschirmen anpassen */
    .aem-event-card {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    }
    
    .aem-event-content {
        padding: 15px;
    }
    
    .aem-event-title {
        font-size: 1.2em;
    }
    
    .aem-ticket-button {
        padding: 8px 16px;
        font-size: 14px;
    }
    
    /* Mobile InfoWindow Optimierung */
    .gm-style .gm-style-iw-c {
        max-width: 90vw !important;
        min-width: 280px !important;
    }
    
    .aem-infowindow {
        min-width: 280px;
    }
    
    .aem-multi-event .aem-infowindow-body {
        max-height: 250px; /* Niedriger auf Mobile */
    }
    
    .aem-popup-event-item {
        padding: 10px;
        margin-right: 3px;
    }
    
    /* Mobile X-Button Anpassungen */
    .gm-ui-hover-effect {
        width: 44px !important;
        height: 44px !important;
        top: 8px !important;
        right: 8px !important;
    }
    
    .gm-ui-hover-effect span {
        margin: 10px !important;
        width: 24px !important;
        height: 24px !important;
    }
    
    .aem-infowindow-header {
        padding: 12px 55px 12px 12px !important;
    }
}

/* Sehr kleine Bildschirme */
@media (max-width: 400px) {
    .aem-event-list,
    #aem-event-list-filtered {
        padding: 10px 0;
        gap: 15px;
    }
    
    .aem-date-block {
        padding: 12px;
    }
    
    .aem-day {
        font-size: 2em;
    }
    
    .aem-month-year {
        font-size: 0.8em;
    }
}