/* ==========================================================================
   Galerie Seite (galerie.php)
   ========================================================================== */

.gallery-section {
    padding: 40px 0;
    text-align: center;
}

.gallery-section .section-intro {
    max-width: 800px;
    margin: 20px auto 40px auto;
    font-size: 1.1em;
    color: #555;
    line-height: 1.6;
}

.gallery-filters {
    background-color: #f8f8f8;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 40px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.gallery-filters label {
    font-weight: bold;
    color: #333;
    margin-right: 5px;
    align-self: center; /* Zentriert Label vertikal */
}

.gallery-filters select,
.gallery-filters button {
    padding: 10px 15px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.gallery-filters select:focus,
.gallery-filters button:hover {
    border-color: #a0c4ff; /* Helle Blau für Fokus/Hover */
    box-shadow: 0 0 5px rgba(160, 196, 255, 0.5);
}

.gallery-filters .button {
    text-decoration: none; /* Für den Reset-Link */
    display: inline-block;
    padding: 10px 15px;
    border-radius: 5px;
    font-size: 1em;
    margin-left: 10px; /* Abstand zum Filter-Button */
}

/* Galerie Kapitel (Themenbereiche) */
.gallery-chapter {
    margin-bottom: 60px;
    text-align: left; /* Überschrift linksbündig */
}

.gallery-chapter h2 {
    font-size: 2.2em;
    color: #333;
    margin-bottom: 30px;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 10px;
    display: inline-block; /* Für die Linie unter der Überschrift */
    text-align: left;
}

.gallery-grid {
    display: grid;
    /* Angepasst: Versucht 4 Spalten von gleicher Breite zu erstellen, falls genug Platz ist. */
    /* Fällt auf weniger Spalten zurück, wenn der Bildschirm kleiner wird. */
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); /* Min-Breite etwas reduziert für 4 Spalten */
    gap: 25px;
    justify-content: center; /* Zentriert bei weniger als voller Zeile */
}

@media (min-width: 1200px) { /* Beispiel: Für Bildschirme ab 1200px Breite, 4 Spalten erzwingen */
    .gallery-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}


.gallery-item {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    height: 100%; /* Wichtig für konsistente Höhe im Grid */
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.12);
}

.gallery-item img {
    width: 100%;
    height: 200px; /* Feste Höhe für alle Bilder */
    object-fit: contain; /* Bilder werden passend skaliert, nicht beschnitten */
    display: block;
    border-bottom: 1px solid #eee;
    background-color: #e9e9e9; /* Hintergrundfarbe für leere Räume hinzufügen */
}

.placeholder-image {
    width: 100%;
    height: 200px;
    background-color: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-style: italic;
    border-bottom: 1px solid #eee;
}

.image-caption {
    padding: 15px;
    font-size: 0.95em;
    color: #666;
    line-height: 1.5;
    flex-grow: 1; /* Beschriftung füllt den Rest des Platzes aus */
    display: flex; /* Für vertikale Zentrierung, falls nötig */
    align-items: center; /* Vertikale Zentrierung */
    justify-content: center; /* Horizontale Zentrierung */
}

.no-images-message {
    padding: 50px 0;
    font-size: 1.2em;
    color: #888;
    text-align: center;
}


/* Responsive Anpassungen */
@media (max-width: 768px) {
    .gallery-filters form {
        flex-direction: column;
        align-items: stretch;
    }

    .gallery-filters label,
    .gallery-filters select,
    .gallery-filters button,
    .gallery-filters .button {
        width: 100%;
        margin-left: 0;
        margin-bottom: 10px; /* Abstand zwischen den Elementen */
    }

    .gallery-filters button:last-child,
    .gallery-filters .button:last-child {
        margin-bottom: 0;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: 1fr; /* Einzelspalte auf sehr kleinen Bildschirmen */
    }
    .gallery-item img,
    .placeholder-image {
        height: 180px;
    }
    .gallery-chapter h2 {
        font-size: 1.8em;
    }
}

/* ==========================================================================
   Benutzerdefinierte Lightbox-Stile
   ========================================================================== */

.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9); /* Dunkler, leicht transparenter Hintergrund */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000; /* Stellt sicher, dass das Overlay über allem liegt */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lightbox-overlay.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.lightbox-image {
    max-width: 100%;
    max-height: 80vh; /* Maximal 80% der Viewport-Höhe */
    object-fit: contain; /* Bild wird passend skaliert, nicht beschnitten */
    display: block;
    border-radius: 5px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

.lightbox-caption {
    color: #fff;
    margin-top: 15px;
    font-size: 1.1em;
    text-align: center;
    max-width: 80%; /* Beschränkung der Breite für längere Texte */
}

.lightbox-nav-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    padding: 10px 15px;
    font-size: 1.8em;
    cursor: pointer;
    border-radius: 5px;
    transition: background-color 0.3s ease;
    z-index: 1001; /* Über dem Bild */
}

.lightbox-nav-button:hover {
    background-color: rgba(0, 0, 0, 0.7);
}

.lightbox-nav-button.prev {
    left: 20px;
}

.lightbox-nav-button.next {
    right: 20px;
}

.lightbox-close-button {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.5em;
    cursor: pointer;
    transition: background-color 0.3s ease;
    z-index: 1002; /* Über allem */
    display: flex;
    justify-content: center;
    align-items: center;
}

.lightbox-close-button:hover {
    background-color: rgba(0, 0, 0, 0.7);
}

/* Responsive Anpassungen für die Lightbox */
@media (max-width: 768px) {
    .lightbox-nav-button {
        padding: 8px 12px;
        font-size: 1.2em;
    }
    .lightbox-nav-button.prev {
        left: 5px;
    }
    .lightbox-nav-button.next {
        right: 5px;
    }
    .lightbox-close-button {
        top: 10px;
        right: 10px;
        width: 30px;
        height: 30px;
        font-size: 1.2em;
    }
}

@media (max-width: 480px) {
    .lightbox-nav-button {
        padding: 5px 8px;
        font-size: 1em;
    }
    .lightbox-nav-button.prev {
        left: 0px;
    }
    .lightbox-nav-button.next {
        right: 0px;
    }
    .lightbox-caption {
        font-size: 0.9em;
        margin-top: 8px;
    }
}