/* Egonex Website - Innovation Section Styles */
/* Stili specifici per la sezione Innovation e box espandibili */

/* Innovation Section Title */
#innovation h2 {
    color: #4472C4;
}

/* Innovation Section Cards with Background Images */
#innovation .card {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: var(--bg-white);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); /* Ombra ridotta e più sottile */
}

/* ===== HOVER EFFECTS RIMOSSI - PULIZIA COMPLETA ===== */

/* ===== MOBILE IN-PLACE EXPANSION ===== */
@media (max-width: 768px) {
    /* Box espanso in-place per mobile */
    .innovation-box.expanded-mobile {
        height: auto !important;
        min-height: auto !important;
    }
    
    /* Contenuto espanso mobile */
    .innovation-box.expanded-mobile .expanded-content {
        display: block !important;
        padding: var(--spacing-md);
        background: rgba(255, 255, 255, 0.7) !important;
        border-radius: 8px;
        margin-top: var(--spacing-sm);
        color: var(--text-dark);
        text-shadow: none;
    }
    
    /* Close button mobile in-place - SOLO IN BASSO */
    .innovation-box .close-btn {
        position: fixed;
        bottom: 1rem;
        left: 50%;
        transform: translateX(-50%);
        width: 50px;
        height: 50px;
        background: linear-gradient(135deg, rgba(239, 68, 68, 0.8) 0%, rgba(220, 38, 38, 0.6) 100%);
        backdrop-filter: blur(8px);
        border: 1px solid rgba(255, 255, 255, 0.3);
        color: white;
        border-radius: 50%;
        display: none;
        align-items: center;
        justify-content: center;
        font-size: 22px;
        font-weight: bold;
        cursor: pointer;
        z-index: 10003;
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    }
    
    .innovation-box .close-btn:hover {
        background: linear-gradient(135deg, rgba(239, 68, 68, 0.9) 0%, rgba(220, 38, 38, 0.7) 100%);
        transform: translateX(-50%) scale(1.05);
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
        border: 1px solid rgba(255, 255, 255, 0.5);
    }
}


/* ===== MOBILE SCROLL HORIZONTAL - HERO STYLE ===== */
@media (max-width: 768px) {
    /* Container grid diventa flexbox scroll */
    #innovation .grid {
        display: flex !important;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        gap: var(--spacing-lg);
        padding: 0 var(--spacing-sm) var(--spacing-sm) var(--spacing-sm);
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    #innovation .grid::-webkit-scrollbar {
        display: none;
    }
    
    /* Card dimensioni fisse per scroll */
    #innovation .card {
        flex: 0 0 280px;
        scroll-snap-align: start;
        height: 300px;
        min-height: unset;
        background-size: cover;
        background-position: center;
    }
    
    /* Tipografia mobile ottimizzata - PIÙ GRANDE */
    #innovation .card h2 {
        font-size: 1.5rem !important; /* Ripristinato alla dimensione originale */
        margin-left: 16px; /* Ridotto da 24px a 16px per mobile */
        margin-bottom: 0.75rem; /* Ridotto per mobile */
    }
    
    #innovation .card p {
        font-size: 0.9rem !important; /* Ripristinato alla dimensione originale */
        margin-left: 20px; /* Ridotto da 32px a 20px per mobile */
        margin-top: 8px; /* Ridotto da 12px a 8px per mobile */
        line-height: 1.4; /* Migliorato per mobile */
        max-width: 85%; /* Ridotto per mobile */
    }
}

/* First card - AI Operativa */
#innovation .card:first-child {
    background-image: url('../../images/ai-operativa-bg.jpg');
    opacity: 1; /* Immagine al 100% - identica a Canva */
}

/* Second card - Pattern di Sviluppo */
#innovation .card:nth-child(2) {
    background-image: url('../../images/pattern-sviluppo-bg-desktop.jpg');
    opacity: 1; /* Immagine al 100% - identica a Canva */
}

/* Third card - Scalabilità Intelligente */
#innovation .card:nth-child(3) {
    background-image: url('../../images/scalabilita-intelligente-bg-desktop.jpg');
    opacity: 1; /* Immagine al 100% - identica a Canva */
}

/* Mobile: immagini ottimizzate per 280x300 */
@media (max-width: 768px) {
    #innovation .card:first-child {
        background-image: url('../../images/ai-operativa-bg-mobile.jpg');
        opacity: 1; /* Immagine al 100% - identica a Canva */
    }
    
    #innovation .card:nth-child(2) {
        background-image: url('../../images/pattern-sviluppo-bg-mobile.jpg');
        opacity: 1; /* Immagine al 100% - identica a Canva */
    }
    
    #innovation .card:nth-child(3) {
        background-image: url('../../images/scalabilita-intelligente-bg-mobile.jpg');
        opacity: 1; /* Immagine al 100% - identica a Canva */
    }
}

/* Card overlay removed - full background visibility */
#innovation .card::before {
    display: none;
}

/* Card content positioning */
#innovation .card h2 {
    font-size: var(--font-size-3xl); /* Aumentato da 2xl a 3xl */
    font-weight: 700;
    margin-bottom: var(--spacing-md);
    margin-left: 24px; /* 12px + 12px = 24px a destra per desktop */
    text-align: center;
}

/* AI Operativa card - Now identical to other cards */

/* Expand Button - Enterprise Design */
.expand-button {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border: 2px solid var(--egonex-orange);
    background-color: transparent;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.expand-button:hover {
    background-color: var(--egonex-orange);
    transform: scale(1.1);
}

.expand-button:focus {
    /* RIMOSSO: outline che causava doppio cerchio */
    outline: none;
}

.expand-icon {
    color: var(--egonex-orange);
    font-size: 20px;
    font-weight: bold;
    line-height: 1;
    transition: color 0.3s ease;
}

.expand-button:hover .expand-icon {
    color: var(--bg-white);
}

#innovation .card p {
    font-size: var(--font-size-lg);
    margin-bottom: var(--spacing-lg);
    margin-left: 32px; /* 24px + 8px = 32px a destra per desktop */
    margin-top: 12px; /* Spostato 12px più in basso */
    opacity: 0.9;
    max-width: 90%;
}

#innovation .card a {
    color: var(--bg-white);
    text-decoration: none;
    font-weight: 600;
    padding: var(--spacing-sm) var(--spacing-lg);
    border: 2px solid var(--bg-white);
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
}

#innovation .card a:hover {
    background-color: var(--bg-white);
    color: var(--primary-blue);
}

/* ===== BOX ESPANDIBILI - NUOVO APPROCCIO PORTAL ===== */

/* Innovation Box Base - rimane nel grid, NON si modifica */
.innovation-box {
    position: relative;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.innovation-box:hover {
    transform: translateY(-2px);
}

/* Quando è attivo l'overlay, box originale resta invariato */
/* .innovation-box.has-overlay-open - Nessuna modifica visuale necessaria */

/* ===== OVERLAY PORTAL SEPARATO ===== */

/* Container overlay principale */
.innovation-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 2rem;
    box-sizing: border-box;
}

/* Overlay visibile */
.innovation-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* Sfondo scuro */
.overlay-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(2px);
    animation: fadeIn 0.3s ease;
}

/* Container contenuto */
.overlay-content {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideInScale 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Box contenuto overlay */
.overlay-box {
    background: var(--bg-white);
    border-radius: 16px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    border: 2px solid var(--primary-blue);
    padding: 2rem;
    position: relative;
}

/* TRASPARENZA SOLO PER MARKET DESKTOP - Usa selettore specifico */
@media (min-width: 769px) {
    /* Solo per popup Market desktop - distingue da Innovation */
    .overlay-box:has([data-translate*="market."]) {
        background: rgba(255, 255, 255, 0.8) !important;
        backdrop-filter: blur(2px) !important;
    }
    
    /* Solo per titolo "Come Funziona" Market desktop */
    .overlay-box:has([data-translate*="market."]) h4 {
        background: rgba(255, 255, 255, 0.8) !important;
        backdrop-filter: blur(2px) !important;
        border-radius: 8px;
        padding: 1rem 1.5rem;
        margin-bottom: 1rem;
    }
    
    /* Solo per benefits-section Market desktop */
    .overlay-box:has([data-translate*="market."]) .benefits-section {
        background: rgba(255, 255, 255, 0.8) !important;
        backdrop-filter: blur(2px) !important;
        border-radius: 8px;
        padding: 1.5rem;
    }
}

/* Overlay semi-trasparente per sottotitoli problematici (solo desktop) */
@media (min-width: 769px) {
    .overlay-box p {
        position: relative;
        /* Forza stabilità dell'overlay */
        isolation: isolate;
    }
    
    .overlay-box p::before {
        content: '';
        position: absolute;
        top: -8px;
        left: -12px;
        right: -12px;
        bottom: -8px;
        background: rgba(255, 255, 255, 0.8) !important;
        border-radius: 8px;
        z-index: -1;
        backdrop-filter: blur(2px);
        /* Forza visibilità stabile */
        opacity: 1 !important;
        pointer-events: none;
        /* Previene interferenze hover */
        transition: none !important;
    }
    
    /* Previeni interferenze da altri stili */
    .overlay-box p:hover::before,
    .overlay-box p:focus::before,
    .overlay-box p:active::before {
        opacity: 1 !important;
        background: rgba(255, 255, 255, 0.8) !important;
    }
}

/* Desktop: dimensioni più ampie */
@media (min-width: 769px) {
    .overlay-content {
        max-width: 800px;
    }
    
    .overlay-box {
        padding: 3rem;
    }
}

/* Mobile: adattamento */
@media (max-width: 768px) {
    .innovation-overlay {
        padding: 1rem;
    }
    
    .overlay-content {
        max-height: 90vh;
        /* Scroll semplice senza conflitti */
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }
    
    .overlay-box {
        padding: 1.5rem;
        border-radius: 12px;
    }
    
    /* Contenuto espanso mobile - scroll gestito dal container principale */
    .overlay-content .expanded-content {
        /* Scroll gestito da .overlay-content */
        overflow: visible;
    }
}

/* DISABILITA SCROLL GLOBALE QUANDO POPUP APERTO - SOLUZIONE SEMPLICE */
body.popup-open {
    overflow: hidden !important;
    /* RIMOSSO: position: fixed - causava scroll indesiderato */
}

html.popup-open {
    overflow: hidden !important;
    height: 100% !important;
}

/* SCROLL CONTAINMENT PER MOBILE - SOLUZIONE SEMPLICE */
@media (max-width: 768px) {
    .innovation-overlay.visible {
        /* Popup a schermo intero */
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        z-index: 10001 !important;
    }
    
    .innovation-overlay.visible .overlay-content {
        /* Scroll contenuto nel popup */
        max-height: 90vh !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
    }
}

/* CLASSE BASE COMUNE PER PULSANTI CHIUSURA - DRY PRINCIPLE */
.overlay-close-base {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.8) 0%, rgba(220, 38, 38, 0.6) 100%);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    font-size: 22px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 20;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.overlay-close-base:hover {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.9) 0%, rgba(220, 38, 38, 0.7) 100%);
    transform: scale(1.05);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.overlay-close-base:focus {
    outline: 2px solid #ef4444;
    outline-offset: 2px;
}

/* Overlay Close Button (desktop - top right) */
.overlay-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 10002;
}

/* Overlay Close Button Mobile (bottom center) */
.overlay-close-mobile {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: none; /* Hidden by default */
}

.overlay-close:hover {
    transform: scale(1.05);
}

.overlay-close-mobile:hover {
    transform: translateX(-50%) scale(1.05);
}

/* Mobile: Mostra X button mobile, nascondi quello desktop */
@media (max-width: 768px) {
    .overlay-close {
        display: none !important;
    }
    
    .overlay-close-mobile {
        display: flex !important;
        position: fixed !important;
        bottom: 1rem !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        z-index: 10003 !important;
        width: 50px !important;
        height: 50px !important;
        background: linear-gradient(135deg, rgba(239, 68, 68, 0.8) 0%, rgba(220, 38, 38, 0.6) 100%) !important;
        backdrop-filter: blur(8px) !important;
        border: 1px solid rgba(255, 255, 255, 0.3) !important;
        font-size: 22px !important;
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2) !important;
    }
    
    .overlay-close-mobile:hover,
    .overlay-close-mobile:active {
        background: linear-gradient(135deg, rgba(239, 68, 68, 0.9) 0%, rgba(220, 38, 38, 0.7) 100%) !important;
        transform: translateX(-50%) scale(1.05) !important;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3) !important;
        border: 1px solid rgba(255, 255, 255, 0.5) !important;
    }
}

/* Expand Button Updates */
.innovation-box.expanded .expand-button {
    display: none;
}

/* RIMOSSO: .innovation-box.expanded .expand-icon - causava doppio cerchio */

/* Expanded Content */
.expanded-content {
    padding: 2rem 1.5rem 1.5rem;
    animation: slideIn 0.4s ease;
}

.innovation-box.expanded .expanded-content {
    display: block !important;
}

/* Benefits Section */
.benefits-section {
    margin-bottom: 2rem;
}

.benefits-section h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    text-align: center;
}

/* TITOLI MARKET DESKTOP - Più specifico per .expanded-content */
.expanded-content h4 {
    font-size: 1rem !important;
    text-align: center !important;
}

/* TITOLI VISION DESKTOP - Aumentati a 18px */
#democratizzazione-tecnologica-box .expanded-content h4,
#sostenibilita-ambientale-box .expanded-content h4,
#innovazione-sociale-box .expanded-content h4 {
    font-size: 1.125rem !important; /* Aumentato a 18px (1.125rem) */
    text-align: center !important;
}

.benefit-item {
    display: flex;
    align-items: flex-start;
    margin-bottom: 1.2rem;
    text-align: left;
}

.benefit-icon {
    width: 20px;
    height: 20px;
    background: var(--success-green);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.8rem;
    color: white;
    font-size: 12px;
    flex-shrink: 0;
    margin-top: 2px;
}

/* Unifica icone per popup Market - stesso stile di Innovation */
.benefits-list li {
    position: relative;
    padding-left: 2rem;
    margin-bottom: 0.5rem;
    list-style: none; /* Rimuove pallini di paragrafo */
}

/* Centra metriche Market nei box e popup */
#market .card-footer {
    text-align: center;
}

#market .badge {
    display: inline-block;
    text-align: center;
}

/* Centra metriche Market anche nei popup overlay */
.overlay-box .card-footer {
    text-align: center;
}

.overlay-box .badge {
    display: inline-block;
    text-align: center;
}

.benefits-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    top: 0;
    width: 20px;
    height: 20px;
    background: var(--success-green);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.benefit-content {
    flex: 1;
}

.benefit-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
    font-size: 0.95rem;
    line-height: 1.3;
}

.benefit-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.4;
    font-style: italic;
}

/* Metrics Section */
.metrics-section {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.metric-item {
    flex: 1;
    text-align: center;
    padding: 1.2rem 1rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(248, 250, 252, 0.8) 100%);
    border-radius: 12px;
    border: 1px solid rgba(226, 232, 240, 0.6);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(4px);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.metric-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent 0%, var(--gradient-color, #4472C4) 50%, transparent 100%);
    opacity: 0.7;
}

.metric-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    border-color: rgba(68, 114, 196, 0.3);
}

/* First metric: 60% - Blue to Teal gradient */
.metric-item:first-child {
    --gradient-color: #4472C4;
}

.metric-item:first-child .metric-number {
    background: linear-gradient(135deg, #4472C4 0%, #0891b2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Second metric: 100% - Green to Emerald gradient */
.metric-item:last-child {
    --gradient-color: #059669;
}

.metric-item:last-child .metric-number {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.metric-number {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.3rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.metric-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes slideInScale {
    from { 
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to { 
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Focus Management */
.innovation-box.expanded {
    outline: none;
}

.innovation-box.expanded:focus-within {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
}

/* Mobile Responsive - Scroll + Overlay */
@media (max-width: 768px) {
    /* Scroll horizontal già implementato sopra */
    
    /* Overlay mobile ottimizzato */
    .expanded-content {
        padding: 1.5rem 1rem;
    }
    
    /* FORZA OPACITÀ MOBILE - Sovrascrive qualsiasi altro CSS */
    .innovation-box.expanded-mobile .expanded-content {
        background: rgba(255, 255, 255, 0.7) !important;
        backdrop-filter: blur(5px) !important;
    }
    
    .metrics-section {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .benefit-item {
        margin-bottom: 1rem;
    }
    
    .benefits-section h4 {
        font-size: 1rem;
        text-align: center;
    }
    
    /* TITOLI MARKET MOBILE - Più specifico per .expanded-content */
    .expanded-content h4 {
        font-size: 1rem !important;
        text-align: center !important;
    }
    
    /* TITOLI VISION MOBILE - Aumentati a 18px */
    #democratizzazione-tecnologica-box .expanded-content h4,
    #sostenibilita-ambientale-box .expanded-content h4,
    #innovazione-sociale-box .expanded-content h4 {
        font-size: 1.125rem !important; /* Aumentato a 18px (1.125rem) */
        text-align: center !important;
    }
}
