/**
 * EventHub Filter Styles
 *
 * Minimales CSS für die Filter-Leiste im Event-Archiv.
 * Nutzt CSS-Variablen aus eventhub-variables.css.
 *
 * @package EventHub
 * @since 1.0.0
 */

/* ==========================================================================
   FILTER CONTAINER
   Zwei unabhängige Flex-Zeilen statt starrem Grid
   ========================================================================== */

.eventhub-filter {
    display: flex;
    flex-direction: column;
    gap: var(--eventhub-spacing-md, 1rem);
    padding: var(--eventhub-spacing-md, 1rem);
    margin-block-end: var(--eventhub-spacing-lg, 1.5rem);
    background: var(--eventhub-color-bg-alt, #f9f9f9);
    border-radius: var(--eventhub-border-radius, 4px);
}

/* Erste Zeile: Suche + Dropdowns */
.eventhub-filter__row--top {
    display: flex;
    gap: var(--eventhub-spacing-md, 1rem);
    align-items: end;
}

/* Zweite Zeile: Zeitraum + Checkboxen + Reset */
.eventhub-filter__row--bottom {
    display: flex;
    gap: var(--eventhub-spacing-md, 1rem);
    align-items: end;
    flex-wrap: wrap;
}

/* ==========================================================================
   FILTER GROUPS
   ========================================================================== */

.eventhub-filter__group {
    display: flex;
    flex-direction: column;
    gap: var(--eventhub-spacing-xs, 0.25rem);
}

/* Suche: Bekommt mehr Platz */
.eventhub-filter__group--search {
    flex: 2;
    min-width: 200px;
}

/* Kategorie und Stadtteil: Gleicher Platz */
.eventhub-filter__group--category,
.eventhub-filter__group--district {
    flex: 1;
    min-width: 150px;
}

/* Zeitraum: Nimmt Platz den es braucht */
.eventhub-filter__group--timeframe {
    flex: 1 1 auto;
    border: none;
    padding: 0;
    margin: 0;
}

/* Actions: Rechts ausgerichtet */
.eventhub-filter__group--actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--eventhub-spacing-md, 1rem);
    margin-left: auto;
}

/* ==========================================================================
   LABELS
   ========================================================================== */

.eventhub-filter__label {
    font-size: var(--eventhub-font-size-sm, 0.875rem);
    font-weight: 500;
    color: var(--eventhub-color-text-muted, #666);
}

/* ==========================================================================
   SEARCH INPUT
   ========================================================================== */

.eventhub-search {
    position: relative;
    width: 100%;
}

.eventhub-search__input {
    height: var(--eventhub-input-height);
    width: 100%;
    padding: 0 var(--eventhub-spacing-md, 1rem);
    border: 1px solid var(--eventhub-color-border-input);
    border-radius: var(--eventhub-border-radius, 4px);
    background-color: var(--eventhub-color-bg-input);
    font-family: inherit;
    font-size: inherit;
}

.eventhub-search__input:hover {
    border-color: var(--eventhub-color-primary, #0073aa);
}

.eventhub-search__input:focus {
    outline: 2px solid var(--eventhub-color-primary, #0073aa);
    outline-offset: 2px;
    border-color: var(--eventhub-color-primary, #0073aa);
}

/* ==========================================================================
   SELECT DROPDOWNS
   ========================================================================== */

.eventhub-filter__select {
    height: var(--eventhub-input-height); /* Explizite Höhe für Konsistenz. */
    padding: 0 var(--eventhub-spacing-md, 1rem);
    border: 1px solid var(--eventhub-color-border-input); /* WordPress-Admin-Grau. */
    border-radius: var(--eventhub-border-radius, 4px);
    background-color: var(--eventhub-color-bg-input);
    font-family: inherit;
    font-size: inherit;
    width: 100%; /* Nutzt volle Grid-Spaltenbreite. */
    max-width: 100%;
    cursor: pointer;
}

.eventhub-filter__select:hover {
    border-color: var(--eventhub-color-primary, #0073aa);
}

.eventhub-filter__select:focus {
    outline: 2px solid var(--eventhub-color-primary, #0073aa);
    outline-offset: 2px;
    border-color: var(--eventhub-color-primary, #0073aa);
}

/* ==========================================================================
   QUICK-FILTER CHIPS
   Minimales Basis-Styling für Funktionalität.
   Design (Farben, Schatten, Animationen) sollte im Theme erfolgen.
   ========================================================================== */

.eventhub-filter__chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--eventhub-spacing-sm, 0.5rem);
    margin: var(--eventhub-spacing-xs, 0.25rem) 0;
}

.eventhub-quick-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25em;
    padding: var(--eventhub-spacing-sm, 0.5rem) var(--eventhub-spacing-md, 1rem);
    border: 1px solid var(--eventhub-color-border-input);
    border-radius: var(--eventhub-border-radius, 4px);
    background: var(--eventhub-color-bg-input);
    color: inherit;
    font: inherit;
    font-size: var(--eventhub-font-size-sm, 0.875rem);
    cursor: pointer;
    transition: border-color var(--eventhub-transition-fast);
}

/* Hover - blauer Rand wie Zeitraum-Buttons */
.eventhub-quick-chip:hover {
    border-color: var(--eventhub-color-primary, #0073aa);
    background: var(--eventhub-color-bg-input);
    color: inherit;
}

/* Aktiver Zustand - wie aktive Zeitraum-Buttons */
.eventhub-quick-chip.is-active {
    background: var(--eventhub-color-primary, #0073aa);
    border-color: var(--eventhub-color-primary, #0073aa);
    color: var(--eventhub-color-text-light);
}

/* Fokus-Ring nur bei Tastaturnavigation (Accessibility) */
.eventhub-quick-chip:focus-visible {
    outline: 2px solid var(--eventhub-color-primary, #0073aa);
    outline-offset: 2px;
}

.eventhub-quick-chip:focus:not(:focus-visible) {
    outline: none;
}

/* Icon im Chip */
.eventhub-quick-chip__icon {
    display: inline-flex;
}

.eventhub-quick-chip__icon svg {
    width: 1em;
    height: 1em;
}

/* ==========================================================================
   ZEITRAUM-BUTTONS
   ========================================================================== */

.eventhub-filter__buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--eventhub-spacing-xs, 0.25rem);
}

.eventhub-filter__button {
    cursor: pointer;
    margin: 0;
}

.eventhub-filter__button input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.eventhub-filter__button span {
    display: inline-block;
    padding: var(--eventhub-spacing-sm, 0.5rem) var(--eventhub-spacing-md, 1rem);
    border: 1px solid var(--eventhub-color-border-input);
    border-radius: var(--eventhub-border-radius, 4px);
    background-color: var(--eventhub-color-bg-input);
    font-size: var(--eventhub-font-size-sm, 0.875rem);
    transition:
        background-color var(--eventhub-transition-fast),
        border-color var(--eventhub-transition-fast),
        color var(--eventhub-transition-fast);
}

.eventhub-filter__button:hover span {
    border-color: var(--eventhub-color-primary, #0073aa);
}

/* Checked/Active State */
.eventhub-filter__button input:checked + span,
.eventhub-filter__button--active span {
    background-color: var(--eventhub-color-primary, #0073aa);
    border-color: var(--eventhub-color-primary, #0073aa);
    color: var(--eventhub-color-text-light);
}

/* Focus State für Accessibility */
.eventhub-filter__button input:focus-visible + span {
    outline: 2px solid var(--eventhub-color-primary, #0073aa);
    outline-offset: 2px;
}

/* ==========================================================================
   DATEPICKER
   Als Button inline mit den Zeitraum-Buttons, konsistentes Styling.
   Versteckter nativer Input + sichtbares Label mit Icon.
   ========================================================================== */

.eventhub-filter__datepicker {
    display: inline-flex;
    align-items: center;
    position: relative;
}

/* Nativer Date-Input: Unsichtbar, aber volle Größe für Klick-Erkennung */
.eventhub-filter__date-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
    margin: 0;
    padding: 0;
    border: none;
}

/* Sichtbares Label mit Icon und Text */
.eventhub-filter__date-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: var(--eventhub-spacing-sm, 0.5rem) var(--eventhub-spacing-md, 1rem);
    border: 1px solid var(--eventhub-color-border-input);
    border-radius: var(--eventhub-border-radius, 4px);
    background-color: var(--eventhub-color-bg-input);
    font-family: inherit;
    font-size: var(--eventhub-font-size-sm, 0.875rem);
    cursor: pointer;
    transition:
        border-color var(--eventhub-transition-fast),
        background-color var(--eventhub-transition-fast),
        color var(--eventhub-transition-fast);
    box-sizing: border-box;
    white-space: nowrap;
}

.eventhub-filter__date-icon {
    flex-shrink: 0;
    width: 0.875em;
    height: 0.875em;
}

.eventhub-filter__date-text {
    /* Erbt font-weight vom Theme (label span Selektoren) */
}

/* Hover-State */
.eventhub-filter__datepicker:hover .eventhub-filter__date-label {
    border-color: var(--eventhub-color-primary, #0073aa);
}

/* Focus-State (wenn nativer Input fokussiert) */
.eventhub-filter__date-input:focus + .eventhub-filter__date-label,
.eventhub-filter__date-input:focus-visible + .eventhub-filter__date-label {
    outline: 2px solid var(--eventhub-color-primary, #0073aa);
    outline-offset: 2px;
    border-color: var(--eventhub-color-primary, #0073aa);
}

/* Aktiv-State: Wenn Datum ausgewählt */
.eventhub-filter__date-label.is-active {
    background-color: var(--eventhub-color-primary, #0073aa);
    border-color: var(--eventhub-color-primary, #0073aa);
    color: var(--eventhub-color-text-light, #fff);
}

/* ==========================================================================
   CHECKBOX
   ========================================================================== */

.eventhub-filter__checkbox {
    display: flex;
    align-items: center;
    gap: var(--eventhub-spacing-sm, 0.5rem);
    cursor: pointer;
    font-size: var(--eventhub-font-size-sm, 0.875rem);
}

.eventhub-filter__checkbox input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--eventhub-color-primary, #0073aa);
}

.eventhub-filter__checkbox input:focus-visible {
    outline: 2px solid var(--eventhub-color-primary, #0073aa);
    outline-offset: 2px;
}

/* ==========================================================================
   RESET-BUTTON
   Konsistent mit anderen Filter-Elementen gestaltet.
   ========================================================================== */

.eventhub-filter__reset {
    display: inline-block;
    padding: var(--eventhub-spacing-sm, 0.5rem) var(--eventhub-spacing-md, 1rem);
    border-radius: var(--eventhub-border-radius, 4px);
    font-family: inherit;
    font-size: var(--eventhub-font-size-sm, 0.875rem);
    white-space: nowrap;
    cursor: pointer;
    transition:
        background-color var(--eventhub-transition-fast),
        border-color var(--eventhub-transition-fast),
        color var(--eventhub-transition-fast);
}

.eventhub-filter__reset:focus-visible {
    outline: 2px solid var(--eventhub-color-primary, #0073aa);
    outline-offset: 2px;
}

/* ==========================================================================
   LOADING-STATE
   ========================================================================== */

/* Halbtransparentes Overlay über den Inhalten während des Ladens */
.eventhub-loading {
    position: relative;
    min-height: 200px;
    pointer-events: none;
}

.eventhub-loading::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    z-index: 10;
    border-radius: var(--eventhub-border-radius, 4px);
}

/* Globaler Loading-Indicator (zentriertes Overlay) */
.eventhub-loading-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--eventhub-spacing-md);
    padding: var(--eventhub-spacing-xl);
    background: var(--eventhub-color-bg-input);
    border-radius: var(--eventhub-border-radius-lg);
    box-shadow: var(--eventhub-dropdown-shadow);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition:
        opacity var(--eventhub-transition),
        visibility var(--eventhub-transition);
}

.eventhub-loading-indicator.is-visible {
    opacity: 1;
    visibility: visible;
}

.eventhub-loading-indicator__spinner {
    width: 3rem;
    height: 3rem;
    border: 4px solid var(--eventhub-color-border, #e0e0e0);
    border-top-color: var(--eventhub-color-primary, #0073aa);
    border-radius: 50%;
    animation: eventhub-spinner 0.7s linear infinite;
}

.eventhub-loading-indicator__text {
    font-size: var(--eventhub-font-size-sm);
    color: var(--eventhub-color-text-muted, #666);
}

@keyframes eventhub-spinner {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   NO RESULTS / ERROR
   ========================================================================== */

.eventhub-no-results,
.eventhub-error {
    padding: var(--eventhub-spacing-xl, 2rem);
    text-align: center;
    color: var(--eventhub-color-text-muted, #666);
    /* Volle Breite im Grid (alle Spalten überspannen) */
    grid-column: 1 / -1;
    width: 100%;
}

.eventhub-error {
    color: var(--eventhub-color-cancelled, #dc3545);
    background-color: var(--eventhub-color-error-bg);
    border-radius: var(--eventhub-border-radius, 4px);
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

/* Tablet: Suche volle Breite, Dropdowns nebeneinander */
@media (max-width: 900px) {
    .eventhub-filter__row--top {
        flex-wrap: wrap;
    }

    .eventhub-filter__group--search {
        flex: 1 1 100%;
    }

    .eventhub-filter__group--category,
    .eventhub-filter__group--district {
        flex: 1 1 calc(50% - 0.5rem);
    }

    .eventhub-filter__group--actions {
        flex-wrap: wrap;
        margin-left: 0;
    }
}

/* Mobile: Alles untereinander */
@media (max-width: 600px) {
    .eventhub-filter__row--top,
    .eventhub-filter__row--bottom {
        flex-direction: column;
    }

    .eventhub-filter__group--search,
    .eventhub-filter__group--category,
    .eventhub-filter__group--district {
        flex: 1 1 auto;
        width: 100%;
    }

    .eventhub-filter__select,
    .eventhub-search__input {
        width: 100%;
    }

    .eventhub-filter__buttons {
        flex-wrap: wrap;
    }

    .eventhub-filter__group--actions {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .eventhub-filter__reset {
        width: 100%;
    }
}

/* Kleine Bildschirme: Buttons noch kompakter */
@media (max-width: 480px) {
    .eventhub-filter__button span {
        padding: var(--eventhub-spacing-xs, 0.25rem)
            var(--eventhub-spacing-sm, 0.5rem);
        font-size: 0.8125rem;
    }

    .eventhub-filter__date-label {
        padding: var(--eventhub-spacing-xs, 0.25rem)
            var(--eventhub-spacing-sm, 0.5rem);
        font-size: 0.8125rem;
    }
}

/* ==========================================================================
   "MEHR LADEN" BUTTON (Phase 8.4)
   ========================================================================== */

/**
 * Klassische Pagination ausblenden wenn JavaScript aktiv ist.
 * Der "Mehr laden" Button wird via JS eingefügt.
 */
.eventhub-pagination-fallback {
    display: none;
}

/* Fallback: Wenn JS deaktiviert ist, Pagination anzeigen. */
.no-js .eventhub-pagination-fallback {
    display: block;
}

.eventhub-load-more {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--eventhub-spacing-sm, 0.5rem);
    width: 100%;
    max-width: 300px;
    margin: var(--eventhub-spacing-xl, 2rem) auto;
    padding: var(--eventhub-spacing-md, 1rem) var(--eventhub-spacing-lg, 1.5rem);
    background: var(--eventhub-color-primary, #0073aa);
    color: var(--eventhub-color-primary-contrast, #fff);
    border: none;
    border-radius: var(--eventhub-border-radius, 4px);
    font-family: inherit;
    font-size: inherit;
    font-weight: var(--eventhub-font-weight-medium);
    cursor: pointer;
    transition:
        background-color var(--eventhub-transition),
        opacity var(--eventhub-transition);
}

.eventhub-load-more:hover:not(:disabled) {
    background: var(--eventhub-color-primary-dark, #005a87);
}

.eventhub-load-more:focus-visible {
    outline: 2px solid var(--eventhub-color-primary, #0073aa);
    outline-offset: 2px;
}

.eventhub-load-more:disabled {
    opacity: 0.7;
    cursor: wait;
}

/* Spinner */
.eventhub-load-more__spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: eventhub-spin 0.8s linear infinite;
}

@keyframes eventhub-spin {
    to {
        transform: rotate(360deg);
    }
}
