/**
 * LIGHTBOX CSS - Shared Styles für galerie.php und orders.php
 * Extrahiert aus galerie.php für bessere Wiederverwendbarkeit
 */

/* LIGHTBOX Base */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    flex-direction: column;
}

.lightbox.active {
    display: flex;
}

/* KRITISCH: Header + Wave verstecken wenn Lightbox aktiv */
.lightbox.active ~ .header,
.lightbox.active ~ .color-wave-container {
    display: none;
}

/* Alternative: Body-Klasse für globales Verstecken */
body.lightbox-mode .header,
body.lightbox-mode .color-wave-container {
    display: none;
}

.lightbox-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: transparent;
    z-index: 1001;
    position: relative;
    transition: opacity 0.3s;
    width: 100%;
}

.lightbox-left-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.lightbox-right-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.lightbox-toggles {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.lightbox-close {
    color: white;
    font-size: 1rem;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: background 0.3s;
    backdrop-filter: blur(4px);
}

.lightbox-close:hover {
    background: rgba(0, 0, 0, 0.85);
}

/* Hide back button when autoplay is active */
body.autoplay-active .lightbox-close {
    display: none !important;
}

.lightbox-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: white;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.7);
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
}

.lightbox-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.lightbox-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 0.5rem;
}

/* Crossfade Container */
.lightbox-image-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.lightbox-image {
    position: absolute;
    max-width: 100vw;
    max-height: 100vh;
    width: auto;
    height: auto;
    object-fit: contain;
    opacity: 0;
    transition: opacity 1.0s ease;
}

/* Im normalen Lightbox-Modus Platz für Controls reservieren */
.lightbox:not(:fullscreen) .lightbox-image,
.lightbox:not(:-webkit-full-screen) .lightbox-image,
.lightbox:not(:-moz-full-screen) .lightbox-image,
.lightbox:not(:-ms-fullscreen) .lightbox-image {
    max-width: calc(100vw - 1rem);
    max-height: calc(100vh - 140px);
}

.lightbox-image.active {
    opacity: 1;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 2rem;
    width: 60px;
    height: 60px;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.3s, opacity 0.3s;
    z-index: 1001;
    backdrop-filter: blur(4px);
}

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

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-info-panel {
    background: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 1rem 2rem;
    display: none;
}

.lightbox-info-panel.active {
    display: block;
}

.lightbox-info-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.lightbox-info-description {
    font-size: 0.95rem;
    line-height: 1.6;
}

/* ✨ ADVANCED LIGHTBOX FEATURES */

/* Auto-hiding UI */
.lightbox.controls-hidden .lightbox-controls,
.lightbox.controls-hidden .zoom-controls,
.lightbox.controls-hidden .interval-selector,
.lightbox.controls-hidden .lightbox-nav,
.lightbox.controls-hidden .lightbox-info-panel,
.lightbox.controls-hidden .hint-text {
    opacity: 0;
    pointer-events: none;
}

/* Keep navigation arrows visible in non-autoplay mode */
body:not(.autoplay-active) .lightbox.controls-hidden .lightbox-prev,
body:not(.autoplay-active) .lightbox.controls-hidden .lightbox-next {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Info-Panel bleibt IMMER sichtbar wenn aktiv - unabhängig vom Auto-Hide */
.lightbox.controls-hidden .lightbox-info-panel.active {
    opacity: 1 !important;
    pointer-events: auto !important;
}

.lightbox-controls,
.zoom-controls,
.interval-selector,
.lightbox-nav,
.lightbox-info-panel {
    transition: opacity 0.3s ease;
}

/* Audio-Toggle Button */
.lightbox-audio-toggle {
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.2rem;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    margin-right: 0.5rem;
    backdrop-filter: blur(4px);
}

.lightbox-audio-toggle:hover {
    background: rgba(0, 0, 0, 0.85);
}

/* Zoom-Controls */
.zoom-controls {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(0, 0, 0, 0.7);
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    color: white;
    font-size: 1rem;
    z-index: 1001;
    transition: opacity 0.3s;
}

.zoom-controls button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.zoom-controls button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.zoom-controls span {
    min-width: 60px;
    text-align: center;
    user-select: none;
}

/* Intervall-Selector Button-Group */
.interval-selector {
    display: flex;
    gap: 0.25rem;
    margin-right: 0.5rem;
}

.interval-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    font-weight: 500;
}

.interval-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.interval-btn.active {
    background: rgba(15, 91, 157, 0.9);
    border-color: rgba(15, 91, 157, 1);
}

/* Hint Text Styling */
.hint-text {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.2rem !important;
    font-style: italic;
    font-weight: 500;
    transition: opacity 0.3s ease;
}

.autoplay-hint {
    flex-basis: 100%;
    width: 100%;
    margin-top: 0.35rem;
    text-align: right;
}

.zoom-hint {
    flex-basis: 100%;
    width: 100%;
    margin-top: 0.35rem;
    text-align: right;
}

/* Lightbox Image Transform Support */
.lightbox-image {
    transition: transform 0.2s ease, opacity 0.6s ease;
    cursor: default;
}

.lightbox-image[style*="scale"] {
    cursor: grab;
}

.lightbox-image[style*="scale"]:active {
    cursor: grabbing;
}

/* Fullscreen Mode - Bilder nutzen VOLLE Breite UND Höhe (keine Offsets!) */
.lightbox:fullscreen .lightbox-image,
.lightbox:-webkit-full-screen .lightbox-image,
.lightbox:-moz-full-screen .lightbox-image,
.lightbox:-ms-fullscreen .lightbox-image {
    max-height: 100vh;
    max-width: 100vw;
}

/* Fullscreen Mode - Controls oben minimal */
.lightbox:fullscreen .lightbox-controls,
.lightbox:-webkit-full-screen .lightbox-controls,
.lightbox:-moz-full-screen .lightbox-controls,
.lightbox:-ms-fullscreen .lightbox-controls {
    padding: 0.5rem 1rem;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .lightbox-nav {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }
    
    /* Reduzierte Abstände für kleine Bildschirme */
    .lightbox-controls {
        padding: 0.75rem 0.75rem 0.75rem 0.5rem;
    }
    
    .lightbox-left-controls,
    .lightbox-right-controls,
    .lightbox-toggles {
        gap: 0.5rem;
    }
    
    .lightbox-checkbox,
    .lightbox-audio-toggle {
        padding: 0.35rem 0.6rem;
    }
    
    .lightbox-toggles {
        flex-wrap: nowrap;
    }
    
    /* Zeiteinstellung unter die Buttons platzieren */
    .lightbox-right-controls {
        flex-wrap: wrap;
    }
    
    .interval-selector {
        flex-basis: 100%;
        width: 100%;
        margin-top: 0.35rem;
        justify-content: center;
    }
}

/* TOUCH-DEVICES: Vollbild-Modus mit Overlay-Controls (Handy Portrait/Landscape, Tablet) */
@media (pointer: coarse) {
    /* Lightbox nutzt ganzen Bildschirm */
    .lightbox {
        height: 100dvh;
    }
    
    /* Bild-Container ohne Padding, volle Höhe */
    .lightbox-main {
        flex: 1;
        min-height: 0;
        padding: 0;
    }
    
    .lightbox-image-container {
        height: 100%;
        width: 100%;
    }
    
    /* Bilder nutzen vollen Bildschirm ohne Abschneiden */
    .lightbox-image {
        max-width: 100vw;
        max-height: 100dvh;
    }
    
    /* Auf Touch-Devices: Bilder komplett bis zum Rand */
    .lightbox:not(:fullscreen) .lightbox-image,
    .lightbox:not(:-webkit-full-screen) .lightbox-image,
    .lightbox:not(:-moz-full-screen) .lightbox-image,
    .lightbox:not(:-ms-fullscreen) .lightbox-image {
        max-width: 100vw;
        max-height: 100dvh;
    }
    
    /* Controls als Overlay über dem Bild - OBEN */
    .lightbox-controls {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0) 100%);
        padding-top: max(env(safe-area-inset-top), 0.75rem);
        padding-bottom: 2rem;
    }
    
    /* Info-Panel als Overlay unten */
    .lightbox-info-panel {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0) 100%);
        padding: 2rem 1rem max(env(safe-area-inset-bottom), 1rem) 1rem;
    }
    
    /* Zoom-Controls auch als Overlay */
    .zoom-controls {
        bottom: max(calc(env(safe-area-inset-bottom) + 20px), 40px);
    }
    
    /* Navigation-Pfeile etwas kleiner */
    .lightbox-nav {
        width: 50px;
        height: 50px;
        font-size: 1.75rem;
    }
    
    .lightbox-prev {
        left: 10px;
    }
    
    .lightbox-next {
        right: 10px;
    }
}
