/**
 * 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;
}
/* Video Header System Styles */
.video-header-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    background: #000;
}

.video-header-container video {
    width: 100vw;
    height: 100vh;
    object-fit: cover;
    object-position: center;
}

/* Controlli video minimali */
#videoControls {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
    border-radius: 50px;
    padding: 12px 16px;
    transition: all 0.3s ease;
    opacity: 0.7;
}

#videoControls:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.5);
}

#videoControls button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

#videoControls button:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

#videoControls i {
    font-size: 18px;
}

/* Controlli semplificati - solo play/pause e mute */
#videoControls {
    min-width: 80px; /* Larghezza fissa per 2 pulsanti */
}

#videoControls button {
    flex-shrink: 0; /* Previeni shrinking dei pulsanti */
}

/* Animazioni hover migliorate per controlli essenziali */
#videoControls button:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.05);
}

/* Overlay scuro per migliorare la leggibilità del contenuto */
.video-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(
        135deg,
        rgba(0, 0, 0, 0.4) 0%,
        rgba(0, 0, 0, 0.2) 50%,
        rgba(0, 0, 0, 0.6) 100%
    );
    z-index: -1;
    pointer-events: none;
}

/* Assicuriamo che il contenuto principale sia sopra il video */
body {
    position: relative;
    z-index: 1;
}

/* Header navigation sopra il video */
.header-nav {
    position: relative;
    z-index: 100;
    background: rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

/* Hero section con video di sfondo */
.hero-section {
    position: relative;
    z-index: 10;
    background: transparent;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #videoControls {
        bottom: 16px;
        right: 16px;
        padding: 10px 14px;
        gap: 10px;
    }
    
    #videoControls button {
        width: 36px;
        height: 36px;
    }
    
    #videoControls i {
        font-size: 16px;
    }
    
    #videoControls:hover #volumeSlider {
        width: 60px;
    }
}

/* Auto-hide controls after inactivity */
@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0.3; }
}

@keyframes fadeIn {
    from { opacity: 0.3; }
    to { opacity: 1; }
}

.controls-auto-hide {
    animation: fadeOut 0.3s ease forwards;
}

.controls-show {
    animation: fadeIn 0.3s ease forwards;
}

/* Fallback background animations */
@keyframes slideRight {
    0% {
        transform: translateX(-100%) skewX(-12deg);
    }
    100% {
        transform: translateX(100vw) skewX(-12deg);
    }
}

.video-header-container .animate-pulse {
    animation: slideRight 8s ease-in-out infinite;
}

/* Ottimizzazioni video per rendering vivido e fluido */
.video-optimized {
    /* Hardware acceleration */
    transform: translate3d(0, 0, 0);
    will-change: transform, opacity, filter;
    backface-visibility: hidden;
    
    /* Rendering optimization */
    -webkit-font-smoothing: subpixel-antialiased;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    
    /* Vivacità colori */
    filter: contrast(1.1) saturate(1.1) brightness(1.05) hue-rotate(0deg);
    
    /* Smooth transitions */
    transition: filter 0.3s ease, transform 0.3s ease;
}

.video-optimized:hover {
    filter: contrast(1.15) saturate(1.15) brightness(1.08);
}

/* Ottimizzazioni performance specifiche per video */
@supports (backdrop-filter: blur(10px)) {
    .video-header-container {
        backdrop-filter: blur(0px);
    }
}

/* GPU rendering hints */
.video-header-container {
    contain: layout style paint;
    transform-style: preserve-3d;
}

/* Preload hints per performance */
.video-header-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 48%, rgba(255,255,255,0.03) 50%, transparent 52%);
    animation: shimmer 3s infinite;
    pointer-events: none;
    opacity: 0;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); opacity: 1; }
    50% { opacity: 0.5; }
    100% { transform: translateX(100%); opacity: 0; }
}

/* Ottimizzazioni cache e compressione */
.video-header-container video {
    /* Cache hints per browser */
    cache: force-cache;
    
    /* Compressione e ottimizzazioni */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
    
    /* Smooth playback */
    -webkit-transform-style: preserve-3d;
    transform-style: preserve-3d;
}

/* Loading indicator per video */
.video-loading {
    position: relative;
}

.video-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    margin: -25px 0 0 -25px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top: 3px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Ottimizzazioni per dispositivi ad alta densità */
@media (-webkit-min-device-pixel-ratio: 2),
       (min-resolution: 192dpi) {
    .video-optimized {
        filter: contrast(1.05) saturate(1.05) brightness(1.02);
    }
}