/**
 * Robust System CSS - Stili per sistema robusto e gestione iframe
 * Garantisce posizionamento corretto e menu sempre attivo
 */

/* Assicura che l'header principale abbia sempre priorità */
header[role="banner"] {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 999998 !important;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%) !important;
    backdrop-filter: blur(10px) !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5) !important;
    border-bottom: 2px solid #D4AF37 !important;
}

/* Navbar principale sempre visibile */
nav[role="navigation"] {
    position: relative !important;
    z-index: 999999 !important;
}

/* Menu dropdown con z-index superiore */
.dropdown-menu {
    z-index: 1000000 !important;
}

/* Stili per container iframe robusto */
#robust-iframe-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 999999 !important;
    background: rgba(0,0,0,0.95) !important;
    backdrop-filter: blur(10px) !important;
}

.robust-iframe-overlay {
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
}

.robust-iframe-header {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%) !important;
    border-bottom: 2px solid #D4AF37 !important;
    padding: 10px 20px !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5) !important;
    z-index: 1000000 !important;
    flex-shrink: 0 !important;
}

.robust-header-content {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    max-width: 1200px !important;
    margin: 0 auto !important;
}

.robust-logo img {
    filter: brightness(1.2) !important;
    height: 40px !important;
}

.robust-title {
    color: #D4AF37 !important;
    font-size: 18px !important;
    font-weight: 600 !important;
    text-align: center !important;
    flex: 1 !important;
    margin: 0 20px !important;
}

.robust-controls {
    display: flex !important;
    gap: 10px !important;
}

.robust-home-btn, .robust-close-btn {
    background: linear-gradient(135deg, #D4AF37 0%, #B8941F 100%) !important;
    color: #000 !important;
    border: none !important;
    padding: 8px 16px !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    font-weight: 600 !important;
    transition: all 0.3s ease !important;
    white-space: nowrap !important;
    font-size: 14px !important;
}

.robust-home-btn:hover, .robust-close-btn:hover {
    background: linear-gradient(135deg, #B8941F 0%, #D4AF37 100%) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.4) !important;
}

.robust-iframe-content {
    flex: 1 !important;
    position: relative !important;
    overflow: hidden !important;
    background: white !important;
}

.robust-iframe-content iframe {
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    background: white !important;
}

/* Assicura che il contenuto della pagina principale stia sotto l'header */
main {
    margin-top: 80px !important;
    position: relative !important;
    z-index: 1 !important;
}

/* Correzione per dispositivi mobili */
@media (max-width: 768px) {
    .robust-iframe-header {
        padding: 8px 15px !important;
    }
    
    .robust-title {
        font-size: 14px !important;
        margin: 0 10px !important;
    }
    
    .robust-home-btn, .robust-close-btn {
        padding: 6px 12px !important;
        font-size: 12px !important;
    }
    
    .robust-logo img {
        height: 30px !important;
    }
}

/* Correzione per tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .robust-title {
        font-size: 16px !important;
    }
}

/* Animazioni per apertura/chiusura iframe */
#robust-iframe-container {
    opacity: 0;
    animation: fadeInIframe 0.3s ease-out forwards;
}

@keyframes fadeInIframe {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Stili per pulsanti di azione sempre attivi */
[data-tool], [data-library], [data-projects] {
    cursor: pointer !important;
    transition: all 0.3s ease !important;
}

[data-tool]:hover, [data-library]:hover, [data-projects]:hover {
    background-color: rgba(212, 175, 55, 0.1) !important;
    transform: translateY(-1px) !important;
}

/* Correzione pulsanti lingua sempre visibili */
.language-btn {
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    pointer-events: auto !important;
}

.language-btn.active {
    background: #D4AF37 !important;
    color: #000 !important;
}

.language-btn.inactive {
    background: transparent !important;
    color: #D4AF37 !important;
}

/* Assicura che i dropdown rimangano sempre sopra tutto */
[data-dropdown-content] {
    z-index: 1000001 !important;
}

/* Correzione per compatibilità con altri CSS */
* {
    box-sizing: border-box;
}

/* Prevenzione sovrapposizioni indesiderate */
.fullscreen-iframe-container {
    z-index: 999997 !important;
}

/* Assicura che gli overlay siano sempre sopra */
.robust-iframe-overlay {
    position: relative !important;
    z-index: 999998 !important;
}