/**
 * Language Switcher - MENU INTEGRATION V2.4.0 (ELEMENTOR-SECTION FIX)
 * Unterstützt BEIDE Methoden:
 *   1. Multilingual Content Widget (.estelle-lang-content)
 *   2. Normale Elementor-Sektionen mit CSS-Klassen (lang-de / lang-en / lang-fr)
 * 
 * @package Estelle
 * @since 2.4.0
 */

/* ==========================================
   FLAGGEN IM MENÜ
   ========================================== */

.nav-menu .nav-flags {
    display: inline-flex !important;
    align-items: center !important;
    margin-left: 20px !important;
    list-style: none !important;
}

.nav-menu .nav-flags .estelle-menu-language-switcher {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

.estelle-menu-flag-btn {
    position: relative !important;
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    min-height: 24px !important;
    max-width: 24px !important;
    max-height: 24px !important;
    border-radius: 50% !important;
    border: 2px solid transparent !important;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    background: #fff !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1) !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    outline: none !important;
}

.estelle-menu-flag-btn img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    pointer-events: none !important;
    display: block !important;
}

.estelle-menu-flag-btn:hover {
    transform: translateY(-2px) scale(1.15) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
    border-color: rgba(184, 149, 106, 0.4) !important;
}

.estelle-menu-flag-btn.active {
    border-color: #B8956A !important;
    box-shadow: 0 0 0 3px rgba(184, 149, 106, 0.2), 0 3px 10px rgba(0, 0, 0, 0.15) !important;
    transform: scale(1.08) !important;
}

.estelle-menu-flag-btn.active::before {
    content: '' !important;
    position: absolute !important;
    top: -3px !important;
    right: -3px !important;
    width: 8px !important;
    height: 8px !important;
    background: #B8956A !important;
    border-radius: 50% !important;
    border: 2px solid #fff !important;
    z-index: 10 !important;
    display: block !important;
}

.estelle-menu-flag-btn:focus {
    outline: 2px solid #B8956A !important;
    outline-offset: 2px !important;
}
.estelle-menu-flag-btn:focus:not(:focus-visible) {
    outline: none !important;
}

/* ==========================================
   METHODE 1: MULTILINGUAL CONTENT WIDGET
   ========================================== */

.estelle-multilingual-content {
    position: relative !important;
    min-height: 50px !important;
}

.estelle-lang-content {
    display: none !important;
    opacity: 0 !important;
    transition: opacity 0.4s ease !important;
}

.estelle-lang-content.active {
    display: block !important;
    opacity: 1 !important;
}

html[data-estelle-lang="de"] .estelle-lang-content[data-lang="de"] {
    display: block !important; opacity: 1 !important;
}
html[data-estelle-lang="en"] .estelle-lang-content[data-lang="en"] {
    display: block !important; opacity: 1 !important;
}
html[data-estelle-lang="fr"] .estelle-lang-content[data-lang="fr"] {
    display: block !important; opacity: 1 !important;
}

/* ==========================================
   METHODE 2: ELEMENTOR-SEKTIONEN MIT CSS-KLASSEN
   
   Anwendung in Elementor:
   Sektion auswählen → Erweitert → CSS-Klassen → "lang-de" eingeben
   (oder lang-en / lang-fr für die anderen Sprachen)
   ========================================== */

/* Alle sprachspezifischen Sektionen standardmäßig ausblenden */
.elementor-section.lang-de,
.elementor-section.lang-en,
.elementor-section.lang-fr,
.e-container.lang-de,
.e-container.lang-en,
.e-container.lang-fr,
.e-flex.lang-de,
.e-flex.lang-en,
.e-flex.lang-fr,
.elementor-widget.lang-de,
.elementor-widget.lang-en,
.elementor-widget.lang-fr,
.elementor-column.lang-de,
.elementor-column.lang-en,
.elementor-column.lang-fr {
    display: none !important;
}

/* Richtige Sprache einblenden per html-Attribut */
html[data-estelle-lang="de"] .elementor-section.lang-de,
html[data-estelle-lang="de"] .e-container.lang-de,
html[data-estelle-lang="de"] .e-flex.lang-de,
html[data-estelle-lang="de"] .elementor-widget.lang-de,
html[data-estelle-lang="de"] .elementor-column.lang-de {
    display: revert !important;
    animation: fadeInSection 0.35s ease forwards !important;
}

html[data-estelle-lang="en"] .elementor-section.lang-en,
html[data-estelle-lang="en"] .e-container.lang-en,
html[data-estelle-lang="en"] .e-flex.lang-en,
html[data-estelle-lang="en"] .elementor-widget.lang-en,
html[data-estelle-lang="en"] .elementor-column.lang-en {
    display: revert !important;
    animation: fadeInSection 0.35s ease forwards !important;
}

html[data-estelle-lang="fr"] .elementor-section.lang-fr,
html[data-estelle-lang="fr"] .e-container.lang-fr,
html[data-estelle-lang="fr"] .e-flex.lang-fr,
html[data-estelle-lang="fr"] .elementor-widget.lang-fr,
html[data-estelle-lang="fr"] .elementor-column.lang-fr {
    display: revert !important;
    animation: fadeInSection 0.35s ease forwards !important;
}

/* Fallback: kein data-estelle-lang → Deutsch zeigen */
html:not([data-estelle-lang]) .elementor-section.lang-de,
html:not([data-estelle-lang]) .e-container.lang-de,
html:not([data-estelle-lang]) .e-flex.lang-de,
html:not([data-estelle-lang]) .elementor-widget.lang-de,
html:not([data-estelle-lang]) .elementor-column.lang-de {
    display: revert !important;
}

@keyframes fadeInSection {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Im Elementor-Editor: alle Sprachsektionen sichtbar zeigen */
body.elementor-editor-active .elementor-section.lang-de,
body.elementor-editor-active .elementor-section.lang-en,
body.elementor-editor-active .elementor-section.lang-fr,
body.elementor-editor-active .e-container.lang-de,
body.elementor-editor-active .e-container.lang-en,
body.elementor-editor-active .e-container.lang-fr,
body.elementor-editor-active .elementor-widget.lang-de,
body.elementor-editor-active .elementor-widget.lang-en,
body.elementor-editor-active .elementor-widget.lang-fr {
    display: block !important;
    opacity: 0.65 !important;
    outline: 2px dashed rgba(184, 149, 106, 0.6) !important;
    outline-offset: 3px !important;
}

/* ==========================================
   ANIMATIONEN
   ========================================== */

.estelle-multilingual-content[data-animation="fade"] .estelle-lang-content.active {
    animation: fadeInContent 0.4s ease forwards !important;
}
@keyframes fadeInContent {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: translateY(0); }
}

.estelle-multilingual-content[data-animation="slide"] .estelle-lang-content.active {
    animation: slideInContent 0.4s ease forwards !important;
}
@keyframes slideInContent {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

@media (max-width: 768px) {
    .nav-menu .nav-flags {
        margin-left: 0 !important;
        margin-top: 15px !important;
        width: 100% !important;
        justify-content: center !important;
    }
    .nav-menu .nav-flags .estelle-menu-language-switcher {
        justify-content: center !important;
        gap: 12px !important;
    }
    .estelle-menu-flag-btn {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
        min-height: 28px !important;
        max-width: 28px !important;
        max-height: 28px !important;
    }
}

/* ==========================================
   ELEMENTOR EDITOR - WIDGET STILE
   ========================================== */

body.elementor-editor-active .estelle-lang-content {
    display: block !important;
    opacity: 0.5 !important;
    border: 2px dashed rgba(184, 149, 106, 0.3) !important;
    padding: 1rem !important;
    margin-bottom: 1rem !important;
    border-radius: 5px !important;
}
body.elementor-editor-active .estelle-lang-content.active {
    opacity: 1 !important;
    border-color: #B8956A !important;
}

/* ==========================================
   ACCESSIBILITY
   ========================================== */

@media (prefers-reduced-motion: reduce) {
    .estelle-menu-flag-btn,
    .estelle-lang-content,
    .elementor-section.lang-de,
    .elementor-section.lang-en,
    .elementor-section.lang-fr,
    .e-container.lang-de,
    .e-container.lang-en,
    .e-container.lang-fr {
        transition: none !important;
        animation: none !important;
    }
}

/* ==========================================
   DEBUG (?debug=lang in URL)
   ========================================== */

html[data-debug-lang="true"] .elementor-section.lang-de,
html[data-debug-lang="true"] .elementor-section.lang-en,
html[data-debug-lang="true"] .elementor-section.lang-fr {
    outline: 3px solid orange !important;
    outline-offset: 5px !important;
}
html[data-debug-lang="true"] .estelle-lang-content {
    outline: 3px solid red !important;
}
html[data-debug-lang="true"] .estelle-lang-content.active {
    outline-color: green !important;
}
