/**
 * Lightbox Styles.
 * Update v5.1.0: Komplette Überarbeitung - Overlay-Click funktioniert jetzt korrekt
 *
 * @package FourSystem_ECards
 */

/* Lightbox Container */
.fsec-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    flex-direction: column;
}

/* Update v5.1.0: Overlay als klickbarer Hintergrund */
.fsec-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    cursor: pointer;
}

/* Header - z-index höher als Overlay */
.fsec-lightbox-header {
    position: relative;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.3);
}

.fsec-lightbox-share {
    display: flex;
    gap: 10px;
}

.fsec-lightbox-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fsec-lightbox-close {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
}

.fsec-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.fsec-lightbox-send {
    padding: 10px 20px;
    background: #2271b1;
    border: none;
    border-radius: 4px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.fsec-lightbox-send:hover {
    background: #135e96;
}

/* Update v5.1.0: Hauptinhalt - pointer-events none um Klicks zum Overlay durchzulassen */
.fsec-lightbox-content {
    position: relative;
    z-index: 5;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: auto;
    pointer-events: none;
}

/* Navigation Pfeile - müssen klickbar sein */
.fsec-lightbox-prev,
.fsec-lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.3);
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    z-index: 10;
    pointer-events: auto;
}

.fsec-lightbox-prev { left: 20px; }
.fsec-lightbox-next { right: 20px; }

.fsec-lightbox-prev:hover,
.fsec-lightbox-next:hover {
    background: rgba(0, 0, 0, 0.5);
    transform: translateY(-50%) scale(1.1);
}

.fsec-lightbox-prev:disabled,
.fsec-lightbox-next:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.fsec-lightbox-prev:disabled:hover,
.fsec-lightbox-next:disabled:hover {
    transform: translateY(-50%);
}

/* Media Container - muss klickbar sein */
.fsec-lightbox-media {
    position: relative;
    max-width: 95vw;
    max-height: 85vh;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease, min-width 0.3s ease, height 0.3s ease;
    pointer-events: auto;
}

/* Formular-Modus mit Mindestbreite */
.fsec-lightbox-media.foursys-form-mode {
    min-width: 1100px;
    height: calc(100vh - 240px);
    max-height: calc(100vh - 240px);
}

.fsec-lightbox-image-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    background: #000;
}

.fsec-lightbox-image-wrap img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
}

/* Update v5.1.2: Video-Styles in Lightbox - YouTube größer */
.fsec-lightbox-video-wrap {
    width: 100%;
    max-width: 900px;
    min-width: 640px;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fsec-lightbox-video-wrap video {
    width: 100%;
    max-height: 70vh;
    object-fit: contain;
}

.fsec-lightbox-video-wrap iframe {
    width: 100%;
    min-height: 400px;
    aspect-ratio: 16/9;
    border: none;
}

/* Update v5.1.2: YouTube-spezifische Größe */
.fsec-lightbox-image-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    background: #000;
    width: 100%;
}

.fsec-lightbox-image-wrap .fsec-lightbox-video-wrap {
    width: 80vw;
    max-width: 1000px;
    min-width: 640px;
}

/* Formular-Bereich */
.fsec-lightbox-form {
    padding: 20px;
    background: #f6f7f7;
    border-top: 1px solid #ddd;
}

/* Loading Indicator */
.fsec-lightbox-loading {
    color: #fff;
    font-size: 16px;
    text-align: center;
    padding: 40px;
}

/* Animation */
.fsec-lightbox.fsec-opening {
    animation: fsec-fade-in 0.3s ease;
}

.fsec-lightbox.fsec-closing {
    animation: fsec-fade-out 0.3s ease forwards;
}

@keyframes fsec-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fsec-fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Body Lock */
body.fsec-lightbox-open {
    overflow: hidden;
}

/* Mobile */
@media (max-width: 1200px) {
    .fsec-lightbox-media.foursys-form-mode {
        min-width: auto;
        width: 100%;
        height: auto;
        max-height: 100vh;
    }
}

@media (max-width: 768px) {
    /* Update v5.5.7: Mobile Lightbox - Bild-Ansicht */
    
    .fsec-lightbox-content {
        padding: 0;
    }
    
    /* Media Container passt sich an Bildgröße an */
    .fsec-lightbox-media {
        max-width: calc(100vw - 40px);
        max-height: 80vh;
        width: auto;
        height: auto;
        border-radius: 8px;
        margin: 80px 20px 100px;
    }
    
    /* Bild-Wrap passt sich an */
    .fsec-lightbox-image-wrap {
        min-height: auto;
        height: auto;
    }
    
    .fsec-lightbox-image-wrap img {
        max-height: 70vh;
    }
    
    /* Header schwebt über Overlay - Buttons getauscht */
    .fsec-lightbox-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        padding: 15px;
        background: transparent;
        z-index: 30;
        flex-direction: row-reverse;
    }
    
    /* Actions: Send links, Close rechts */
    .fsec-lightbox-actions {
        width: 100%;
        display: flex;
        justify-content: space-between;
        flex-direction: row-reverse;
    }
    
    /* Send-Button links - leicht abgerundet */
    .fsec-lightbox-send {
        border-radius: 6px;
        padding: 10px 18px;
        font-size: 13px;
        background: #2271b1;
        order: 2;
    }
    
    /* Close-Button rechts */
    .fsec-lightbox-close {
        width: 40px;
        height: 40px;
        background: rgba(0, 0, 0, 0.5);
        border-radius: 50%;
        order: 1;
    }
    
    /* Share-Buttons unten zentriert über Overlay */
    .fsec-lightbox-share {
        position: fixed;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 30;
        background: rgba(0, 0, 0, 0.6);
        padding: 12px 18px;
        border-radius: 30px;
    }
    
    /* Navigation Pfeile */
    .fsec-lightbox-prev,
    .fsec-lightbox-next {
        width: 44px;
        height: 44px;
        z-index: 25;
    }
    
    .fsec-lightbox-prev { left: 10px; }
    .fsec-lightbox-next { right: 10px; }
    
    /* === Formular-Modus: Vollbild mit scrollbarem Inhalt === */
    .fsec-lightbox.foursys-form-active .fsec-lightbox-header,
    .fsec-lightbox.foursys-form-active .fsec-lightbox-share,
    .fsec-lightbox.foursys-form-active .fsec-lightbox-prev,
    .fsec-lightbox.foursys-form-active .fsec-lightbox-next {
        display: none !important;
    }
    
    .fsec-lightbox.foursys-form-active .fsec-lightbox-content {
        padding: 0;
        align-items: stretch;
    }
    
    .fsec-lightbox-media.foursys-form-mode {
        max-width: 100vw;
        max-height: 100vh;
        width: 100vw;
        height: 100vh;
        margin: 0;
        border-radius: 0;
        border: none !important;
        display: block;
        overflow-y: auto;
    }
    
    /* Bild-Bereich im Formular ausblenden */
    .foursys-form-mode .fsec-lightbox-image-wrap {
        display: none;
    }
    
    /* Formular nimmt volle Höhe */
    .foursys-form-mode .fsec-send-form {
        display: block !important;
        width: 100%;
        min-height: 100vh;
    }
}

/* Touch-friendly */
@media (hover: none) {
    .fsec-lightbox-prev,
    .fsec-lightbox-next,
    .fsec-lightbox-close,
    .fsec-share-btn {
        opacity: 0.8;
    }
}

/* Share Buttons */
.fsec-share-buttons {
    display: flex;
    gap: 8px;
}

.fsec-share-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
}

.fsec-share-btn:hover {
    background: rgba(255,255,255,0.35);
    transform: scale(1.1);
}

.fsec-share-btn svg {
    width: 18px;
    height: 18px;
}

.fsec-share-facebook:hover { background: #1877f2; }
.fsec-share-twitter:hover { background: #000; }
.fsec-share-pinterest:hover { background: #e60023; }
.fsec-share-linkedin:hover { background: #0a66c2; }
.fsec-share-whatsapp:hover { background: #25d366; }
.fsec-share-download:hover { background: #2271b1; }
.fsec-share-native:hover { background: #2271b1; }

/* Mobile-only Buttons */
.fsec-share-mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .fsec-share-mobile-only {
        display: flex;
    }
}
