/* ==========================================================================
   FUNNEL ENHANCEMENTS - UX/UI ADDITIONS
   Da aggiungere DOPO style.css esistente
   ========================================================================== */

/* ==========================================================================
   1. FLOATING CTA BAR (appare dopo scroll della hero)
   ========================================================================== */

.floating-cta-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #0E3C52 0%, #1a5570 100%);
    padding: 15px 20px;
    z-index: 999;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
}

.floating-cta-bar.visible {
    transform: translateY(0);
}

.floating-cta-bar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.floating-cta-bar .cta-text {
    color: white;
    font-weight: 600;
}

.floating-cta-bar .cta-text strong {
    color: #10b981;
}

.floating-cta-bar .btn {
    white-space: nowrap;
    background: white;
    color: #0E3C52;
    padding: 12px 30px;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.3);
}

.floating-cta-bar .btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(255, 255, 255, 0.4);
}

@media (max-width: 768px) {
    .floating-cta-bar .container {
        flex-direction: column;
        gap: 12px;
    }
    
    .floating-cta-bar .cta-text {
        font-size: 0.9rem;
        text-align: center;
    }
    
    .floating-cta-bar .btn {
        width: 100%;
    }
}


/* ==========================================================================
   2. EXIT-INTENT POPUP (recupera visitatori in uscita)
   ========================================================================== */

.exit-intent-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.exit-intent-overlay.active {
    display: flex;
}

.exit-intent-modal {
    background: white;
    border-radius: 20px;
    max-width: 600px;
    width: 100%;
    padding: 50px 40px;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUpBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: 90vh;
    overflow-y: auto;
}

.exit-intent-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 28px;
    color: #6b7280;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    z-index: 10;
}

.exit-intent-close:hover {
    background: #f3f4f6;
    color: #0E3C52;
}

.exit-intent-modal h3 {
    font-size: 2rem;
    color: #0E3C52;
    margin-bottom: 15px;
    text-align: center;
    line-height: 1.2;
}

.exit-intent-modal .highlight {
    color: #10b981;
}

.exit-intent-modal p {
    font-size: 1.1rem;
    color: #4b5563;
    text-align: center;
    margin-bottom: 30px;
    line-height: 1.6;
}

.exit-intent-benefits {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.exit-benefit-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f0f9ff;
    border-radius: 8px;
}

.exit-benefit-item svg {
    width: 24px;
    height: 24px;
    color: #10b981;
    flex-shrink: 0;
}

.exit-benefit-item span {
    font-weight: 500;
    color: #0E3C52;
    font-size: 0.95rem;
}

.exit-intent-cta {
    text-align: center;
}

.exit-intent-cta .btn {
    font-size: 1.1rem;
    margin-bottom: 15px;
    /* width: 100%; */
    display: block;
}

.exit-intent-cta .disclaimer {
    font-size: 0.85rem;
    color: #6b7280;
}

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

@keyframes slideUpBounce {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Animazione mobile specifica (slide up dal basso) */
@keyframes slideUpMobile {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* EXIT INTENT - RESPONSIVE MOBILE */
@media (max-width: 768px) {
    .exit-intent-overlay {
        padding: 15px;
        align-items: flex-end; /* Posiziona in basso come bottom sheet */
    }
    
    .exit-intent-modal {
        padding: 35px 25px 25px;
        border-radius: 20px 20px 0 0; /* Arrotonda solo sopra */
        max-height: 85vh;
        animation: slideUpMobile 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    }
    
    .exit-intent-close {
        top: 15px;
        right: 15px;
        width: 32px;
        height: 32px;
        font-size: 24px;
    }
    
    .exit-intent-modal h3 {
        font-size: 1.5rem;
        margin-bottom: 12px;
        padding-right: 30px; /* Spazio per il bottone close */
    }
    
    .exit-intent-modal p {
        font-size: 1rem;
        margin-bottom: 25px;
    }
    
    .exit-intent-benefits {
        gap: 12px;
        margin-bottom: 25px;
    }
    
    .exit-benefit-item {
        padding: 10px 12px;
        gap: 10px;
    }
    
    .exit-benefit-item svg {
        width: 20px;
        height: 20px;
    }
    
    .exit-benefit-item span {
        font-size: 0.9rem;
    }
    
    .exit-intent-cta .btn {
        font-size: 1rem;
        padding: 16px 30px;
    }
    
    .exit-intent-cta .disclaimer {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .exit-intent-overlay {
        padding: 0;
    }
    
    .exit-intent-modal {
        border-radius: 16px 16px 0 0;
        padding: 30px 20px 20px;
        max-height: 90vh;
    }
    
    .exit-intent-close {
        top: 12px;
        right: 12px;
        width: 30px;
        height: 30px;
        font-size: 22px;
    }
    
    .exit-intent-modal h3 {
        font-size: 1.35rem;
        margin-bottom: 10px;
        padding-right: 35px;
    }
    
    .exit-intent-modal p {
        font-size: 0.95rem;
        margin-bottom: 20px;
    }
    
    .exit-intent-benefits {
        gap: 10px;
        margin-bottom: 20px;
    }
    
    .exit-benefit-item {
        padding: 10px;
        gap: 8px;
    }
    
    .exit-benefit-item svg {
        width: 18px;
        height: 18px;
    }
    
    .exit-benefit-item span {
        font-size: 0.85rem;
        line-height: 1.4;
    }
    
    .exit-benefit-item strong {
        display: block;
        margin-bottom: 2px;
    }
    
    .exit-intent-cta .btn {
        font-size: 0.95rem;
        padding: 14px 25px;
    }
    
    .exit-intent-cta .disclaimer {
        font-size: 0.75rem;
        line-height: 1.4;
    }
}

/* ==========================================================================
   3. LIVE ACTIVITY FEED (social proof dinamico)
   ========================================================================== */

.live-activity-feed {
    position: fixed;
    bottom: 100px;
    left: 20px;
    z-index: 998;
    max-width: 350px;
}

.activity-notification {
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    transform: translateX(-400px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    border-left: 4px solid #10b981;
}

.activity-notification.show {
    transform: translateX(0);
    opacity: 1;
}

.activity-notification.hide {
    transform: translateX(-400px);
    opacity: 0;
}

.activity-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0E3C52, #10b981);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.activity-content {
    flex: 1;
}

.activity-name {
    font-weight: 700;
    color: #0E3C52;
    margin-bottom: 4px;
}

.activity-action {
    font-size: 0.9rem;
    color: #6b7280;
}

.activity-time {
    font-size: 0.8rem;
    color: #9ca3af;
    margin-top: 4px;
}

@media (max-width: 768px) {
    .live-activity-feed {
        bottom: 80px;
        left: 10px;
        right: 10px;
        max-width: calc(100% - 20px);
    }
    
    .activity-notification {
        padding: 12px 16px;
    }
}

/* ==========================================================================
    4. TRUST BADGES CAROUSEL 
   ========================================================================== */

.trust-carousel-wrapper {
    overflow: hidden;
    padding: 20px 0;
    background: linear-gradient(135deg, #f8fafc, #e0f2fe);
    border-top: 1px solid #cbd5e1;
    border-bottom: 1px solid #cbd5e1;
    overflow: hidden !important;
    width: 100%;
}

.trust-carousel {
    display: flex !important;
    flex-wrap: nowrap !important;
    animation: scrollTrust 20s linear infinite !important;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    gap: 40px !important;
}

.trust-carousel:hover {
    animation-play-state: paused;
}

.trust-badge-card {
    min-width: 280px;
    background: white;
    padding: 20px 25px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: transform 0.3s ease;
    flex-shrink: 0;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.trust-badge-card:hover {
    transform: translateY(-5px);
}

.trust-badge-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #e0f2fe;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.trust-badge-icon svg {
    width: 24px;
    height: 24px;
    color: #0E3C52;
}

.trust-badge-content h4 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #0E3C52;
    margin-bottom: 4px;
}

.trust-badge-content p {
    font-size: 0.85rem;
    color: #6b7280;
    margin: 0;
}

@keyframes scrollTrust {
    0% { 
        transform: translate3d(0, 0, 0); 
    }
    100% { 
        transform: translate3d(-50%, 0, 0); 
    }
}

/* ==========================================================================
   5. STICKY PRICING COMPARISON (compare mentre scrolli)
   ========================================================================== */

.sticky-price-compare {
    position: fixed;
    bottom: -300px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.2);
    padding: 25px 30px;
    z-index: 997;
    max-width: 600px;
    width: 90%;
    transition: bottom 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.sticky-price-compare.visible {
    bottom: 0;
}

.sticky-price-compare-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.sticky-price-compare-header h4 {
    font-size: 1.3rem;
    color: #0E3C52;
    margin: 0;
}

.sticky-price-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sticky-price-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.sticky-plan-card {
    background: #f8fafc;
    padding: 15px;
    border-radius: 10px;
    border: 2px solid transparent;
    transition: all 0.3s;
    cursor: pointer;
}

.sticky-plan-card.selected {
    border-color: #0E3C52;
    background: #e0f2fe;
}

.sticky-plan-card.recommended {
    background: linear-gradient(135deg, #e0f2fe, #bae6fd);
}

.sticky-plan-name {
    font-weight: 700;
    color: #0E3C52;
    margin-bottom: 8px;
}

.sticky-plan-price {
    font-size: 1.8rem;
    font-weight: 800;
    color: #0E3C52;
    margin-bottom: 5px;
}

.sticky-plan-period {
    font-size: 0.9rem;
    color: #6b7280;
}

.sticky-plan-features {
    list-style: none;
    padding: 0;
    margin: 10px 0 0 0;
}

.sticky-plan-features li {
    font-size: 0.85rem;
    color: #4b5563;
    margin-bottom: 5px;
    padding-left: 20px;
    position: relative;
}

.sticky-plan-features li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #10b981;
    font-weight: 700;
}

.sticky-price-cta {
    text-align: center;
}

.sticky-price-cta .btn {
    width: 100%;
    padding: 16px;
    font-size: 1.05rem;
}

@media (max-width: 640px) {
    .sticky-price-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   6. PROGRESS BAR (mostra avanzamento nel funnel)
   ========================================================================== */

.funnel-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    z-index: 1001;
    opacity: 0;
    transition: opacity 0.3s;
}

.funnel-progress-bar.visible {
    opacity: 1;
}

.funnel-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #059669);
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

/* ==========================================================================
   7. INLINE TESTIMONIALS (micro-testimonials nei bottoni CTA)
   ========================================================================== */

.cta-with-testimonial {
    position: relative;
}

.inline-testimonial {
    position: absolute;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 10px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    font-size: 0.85rem;
    color: #4b5563;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.cta-with-testimonial:hover .inline-testimonial {
    opacity: 1;
}

.inline-testimonial::before {
    content: "";
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid white;
}

/* ==========================================================================
   8. COUNTDOWN TIMER (urgency etica per trial)
   ========================================================================== */

.urgency-timer {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 2px solid #f59e0b;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    margin: 30px auto;
    max-width: 500px;
}

.urgency-timer h4 {
    font-size: 1.2rem;
    color: #92400e;
    margin-bottom: 15px;
}

.timer-display {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
}

.timer-unit {
    background: white;
    padding: 15px;
    border-radius: 8px;
    min-width: 70px;
}

.timer-value {
    display: block;
    font-size: 2rem;
    font-weight: 800;
    color: #0E3C52;
    line-height: 1;
}

.timer-label {
    display: block;
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 5px;
    text-transform: uppercase;
}

.urgency-timer p {
    font-size: 0.9rem;
    color: #92400e;
    margin: 0;
}

/* ==========================================================================
   9. TOOLTIP ENHANCEMENTS (explain complex features)
   ========================================================================== */

.has-tooltip {
    position: relative;
    display: inline-block;
    border-bottom: 1px dotted #0E3C52;
    cursor: help;
}

.tooltip-content {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    background: #1e293b;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    line-height: 1.5;
    max-width: 250px;
    width: max-content;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s;
    z-index: 1000;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.tooltip-content::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1e293b;
}

.has-tooltip:hover .tooltip-content {
    opacity: 1;
    transform: translateX(-50%) translateY(-5px);
}

/* ==========================================================================
   10. SCROLL-TRIGGERED HIGHLIGHTS (attira attenzione su features chiave)
   ========================================================================== */

.scroll-highlight {
    position: relative;
}

.scroll-highlight::before {
    content: "";
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(8, 145, 178, 0.1));
    border-radius: 16px;
    opacity: 0;
    z-index: -1;
    transition: opacity 0.5s;
}

.scroll-highlight.highlighted::before {
    opacity: 1;
    animation: pulseGlow 2s ease-in-out;
}

@keyframes pulseGlow {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

/* ==========================================================================
   11. SMART STICKY HEADER CTA (appare quando pricing è visibile)
   ========================================================================== */

.main-header .header-cta-sticky {
    display: none;
}

.main-header.show-sticky-cta .header-cta-sticky {
    display: inline-block;
    animation: slideInRight 0.4s ease;
}

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

/* ==========================================================================
   12. MICRO-INTERACTIONS - Button Ripple Effect
   ========================================================================== */

.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-ripple:active::after {
    width: 300px;
    height: 300px;
}

/* ==========================================================================
   13. PRICING CARD HOVER COMPARISON
   ========================================================================== */

.pricing-card-enhanced {
    position: relative;
}

.pricing-comparison-popup {
    position: absolute;
    top: 50%;
    left: 105%;
    transform: translateY(-50%) scale(0.9);
    background: white;
    border: 2px solid #0E3C52;
    border-radius: 12px;
    padding: 20px;
    min-width: 250px;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s;
    z-index: 100;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.pricing-card-enhanced:hover .pricing-comparison-popup {
    opacity: 1;
    transform: translateY(-50%) scale(1);
}

.pricing-comparison-popup h5 {
    font-size: 1rem;
    color: #0E3C52;
    margin-bottom: 10px;
}

.pricing-comparison-popup ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.pricing-comparison-popup ul li {
    font-size: 0.85rem;
    color: #4b5563;
    margin-bottom: 8px;
    padding-left: 20px;
    position: relative;
}

.pricing-comparison-popup ul li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: #10b981;
}

@media (max-width: 1024px) {
    .pricing-comparison-popup {
        display: none; /* Hide on smaller screens */
    }
}

/* ==========================================================================
   14. BENEFIT ICONS ANIMATION (animate on scroll)
   ========================================================================== */

.benefit-item svg,
.mini-benefit svg,
.feature-list-enhanced svg {
    transition: transform 0.3s ease;
}

.benefit-item:hover svg,
.mini-benefit:hover svg,
.feature-list-enhanced li:hover svg {
    transform: scale(1.2) rotate(10deg);
}

/* ==========================================================================
   15. ENHANCED FOCUS STATES (accessibility + visual feedback)
   ========================================================================== */

.btn:focus-visible,
.pricing-card-enhanced:focus-within,
.faq-question:focus-visible {
    outline: 3px solid #10b981;
    outline-offset: 4px;
}

/* ==========================================================================
   16. LOADING STATE for ASYNC ACTIONS
   ========================================================================== */

.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   RESPONSIVE ADJUSTMENTS - TRUST CAROUSEL
   ========================================================================== */

@media (max-width: 768px) {
    .trust-carousel {
        animation: scrollTrust 15s linear infinite !important;
        gap: 20px;
    }
    
    .trust-badge-card {
        min-width: 240px;
        padding: 15px 20px;
    }
    
    .trust-badge-icon {
        width: 40px;
        height: 40px;
    }
    
    .trust-badge-icon svg {
        width: 20px;
        height: 20px;
    }
    
    .trust-badge-content h4 {
        font-size: 0.9rem;
    }
    
    .trust-badge-content p {
        font-size: 0.8rem;
    }
    
    .urgency-timer {
        padding: 15px;
    }
    
    .timer-display {
        gap: 10px;
    }
    
    .timer-unit {
        padding: 10px;
        min-width: 60px;
    }
    
    .timer-value {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .trust-carousel {
        animation: scrollTrust 12s linear infinite !important;
        gap: 15px;
    }
    
    .trust-badge-card {
        min-width: 200px;
        padding: 12px 16px;
    }
}

/* ==========================================================================
   ACCESSIBILITY - Prefers Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .trust-carousel {
        animation: none;
    }
    
    .activity-notification,
    .floating-cta-bar,
    .exit-intent-modal {
        animation: none;
        transition: none;
    }
    
    .scroll-highlight.highlighted::before {
        animation: none;
    }
}