/* ========================================
   GUIDED TOUR STYLES
   ======================================== */

/* Tour Overlay */
.tour-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
}

/* Welcome overlay with blur background */
.tour-overlay.welcome-overlay {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Step overlay with lighter semi-transparent background */
.tour-overlay.step-overlay {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    pointer-events: none; /* Allow clicks through the overlay */
}

/* Only the popover itself should capture clicks */
.popover-container {
    pointer-events: all;
}

.tour-overlay.active {
    display: flex;
}

/* Welcome Modal */
.welcome-modal {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    width: 90%;
    max-width: 400px;
    padding: 32px 24px;
    padding-bottom: 0;
    text-align: center;
    font-family: 'DM Sans', Arial, sans-serif;
    animation: modalSlideIn 0.3s ease-out;
}

.welcome-modal h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: #1a202c;
}

.welcome-modal p {
    font-size: 1rem;
    color: #4a5568;
    margin-bottom: 24px;
    line-height: 1.5;
}

.welcome-modal .buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.welcome-modal .btn {
    padding: 12px 24px;
    border: none;
    border-radius: 2rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.welcome-modal .btn-primary {
    background-color: #24D07E;
    color: white;
    font-size: 0.75rem;
    border-radius: 0.5rem;
}

.welcome-modal .btn-primary:hover {
    background-color: #1fa86a;
    transform: translateY(-1px);
}

.welcome-modal .btn-secondary {
    background-color: #7A55F7;
    color: white;
    font-size: 0.75rem;
    border-radius: 0.5rem;
}

.welcome-modal .btn-secondary:hover {
    background-color: #673fce;
    transform: translateY(-1px);
}

/* Popover System */
.popover-container {
    position: absolute;
    width: 300px;
    z-index: 10001;
    pointer-events: none;
}

.popover-box {
    background: linear-gradient(135deg, #574BE0, #7A55F7);
    color: white;
    border-radius: 12px;
    box-shadow: 
        0 10px 40px rgba(87, 75, 224, 0.3),
        0 4px 16px rgba(87, 75, 224, 0.2),
        0 1px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    pointer-events: all;
    animation: popoverFadeIn 0.3s ease-out;
    backdrop-filter: blur(8px);
}

.popover-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.popover-content {
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 16px;
}

.popover-box-actions {
    background: linear-gradient(135deg, rgba(87, 75, 224, 0.9), rgba(122, 85, 247, 0.8));
    border-radius: 0 0 12px 12px;
    backdrop-filter: blur(4px);
}

.popover-actions {
    display: flex;
    gap: 8px;
    justify-content: space-between;
    align-items: center;
}

.popover-btn {
    padding: 8px 16px !important;
    border: none !important;
    border-radius: 4px !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    min-height: 36px !important; /* Touch target per mobile */
}

.popover-btn.btn-next {
    background: linear-gradient(135deg, #24D07E, #1fa86a) !important;
    color: white !important;
    font-weight: 600 !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    padding: 8px 16px !important;
    border-radius: 4px !important;
    font-size: 0.9rem !important;
}

.popover-btn.btn-next:hover {
    background: linear-gradient(135deg, #1fa86a, #188a5a) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(36, 208, 126, 0.3) !important;
}

.popover-btn.btn-skip {
    background-color: #122999 !important;
    color: #4a5568 !important;
    padding: 8px 16px !important;
    border-radius: 4px !important;
    font-size: 0.9rem !important;
}

.popover-btn.btn-skip:hover {
    background-color: #122999 !important;
}

.tour-close-link {
    font-size: 0.8rem !important;
    color: white !important;
    text-decoration: underline !important;
    cursor: pointer !important;
    transition: color 0.2s ease !important;
}

.tour-close-link:hover {
    color: #4a5568 !important;
    text-decoration: underline !important;
}

/* Popover Arrows */
.popover-arrow {
    position: absolute;
    width: 0;
    height: 0;
    border: 8px solid transparent;
}

/* Arrow positions */
.popover-container.position-top .popover-arrow {
    bottom: -16px;
    left: 50%;
    transform: translateX(-50%);
    border-top-color: #574BE0;
}

.popover-container.position-bottom .popover-arrow {
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    border-bottom-color: #574BE0;
}

.popover-container.position-left .popover-arrow {
    right: -16px;
    top: 50%;
    transform: translateY(-50%);
    border-left-color: #574BE0;
}

.popover-container.position-right .popover-arrow {
    left: -16px;
    top: 50%;
    transform: translateY(-50%);
    border-right-color: #574BE0;
}

/* Element highlighting - Clean effect without zoom */
.tour-highlight {
    position: relative;
    z-index: 10002;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    border-radius: 12px !important;
    box-shadow: 
        0 0 0 2px rgba(255, 255, 255, 0.9),
        0 8px 32px rgba(0, 0, 0, 0.3) !important;
    background: rgba(255, 255, 255, 0.95) !important;
}

/* Specific styling for list item highlights */
#tour-categories.tour-highlight,
#tour-products.tour-highlight,
#tour-templates.tour-highlight,
#tour-qrcode.tour-highlight,
#tour-customize.tour-highlight {
    background: rgba(255, 255, 255, 0.98) !important;
    border-radius: 16px !important;
    box-shadow: 
        0 0 0 3px rgba(255, 255, 255, 1),
        0 12px 40px rgba(0, 0, 0, 0.4),
        0 4px 16px rgba(0, 0, 0, 0.2) !important;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Enhanced highlighting for list item links - keep text readable */
#tour-categories.tour-highlight a,
#tour-products.tour-highlight a,
#tour-templates.tour-highlight a,
#tour-qrcode.tour-highlight a,
#tour-customize.tour-highlight a {
    background: transparent !important;
    border-radius: 12px !important;
    transition: all 0.3s ease !important;
    color: inherit !important;
}

/* Tour styling optimizations - no more interaction blocking needed */

/* Ensure popover elements work */
.popover-container,
.popover-box,
.popover-btn,
.tour-close-link {
    pointer-events: all !important;
}

/* Animations */
@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes popoverFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Miglioramenti CSS per il tour su mobile */
@media (max-width: 768px) {
    .popover-container {
        /* Assicura che il popover non sia mai più largo dello schermo */
        max-width: calc(100vw - 24px) !important;
        width: auto !important;
    }
    
    .popover-box {
        /* Rendi il popover più adatto al mobile */
        min-width: 280px;
        max-width: calc(100vw - 32px);
        font-size: 14px;
        border-radius: 12px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    }
    
    .popover-title {
        font-size: 16px !important;
        font-weight: 600;
        line-height: 1.3;
    }
    
    .popover-content {
        font-size: 14px !important;
        line-height: 1.4;
    }
    
    .popover-btn {
        /* Mantieni stili desktop anche su mobile */
        padding: 8px 16px;
        border: none;
        border-radius: 4px;
        font-size: 0.9rem;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s ease;
        min-height: 44px; /* Touch target raccomandato per mobile */
    }
    
    .tour-close-link {
        /* Mantieni stili desktop anche su mobile */
        font-size: 0.8rem;
        color: white;
        text-decoration: underline;
        cursor: pointer;
        transition: color 0.2s ease;
        padding: 8px 4px;
        min-height: 32px;
        display: flex;
        align-items: center;
    }
    
    .popover-actions {
        /* Migliore spacing sui pulsanti */
        gap: 12px !important;
        align-items: center;
    }
    
    /* Arrows più piccole su mobile */
    .popover-arrow {
        width: 16px !important;
        height: 16px !important;
    }
    
    /* Highlight più evidente su mobile */
    .tour-highlight {
        box-shadow: 0 0 0 3px rgba(18, 41, 153, 0.3) !important;
        border-radius: 8px !important;
        position: relative;
        z-index: 9998 !important;
    }
    
    /* Overlay meno invasivo su mobile */
    .tour-overlay.step-overlay {
        background-color: rgba(0, 0, 0, 0.4) !important;
    }
    
    /* Assicura che il modal di benvenuto sia mobile-friendly */
    .welcome-modal {
        max-width: calc(100vw - 32px) !important;
        margin: 16px !important;
        border-radius: 16px;
    }
    
    .welcome-modal .buttons {
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    .welcome-modal .btn {
        max-width: 100% !important;
        flex: none !important;
        min-height: 48px;
        border-radius: 12px;
    }
}

/* Smooth scroll per il tour */
html {
    scroll-behavior: smooth;
}

/* Durante il tour, previeni zoom accidentali su mobile */
.tour-overlay.active ~ * {
    touch-action: manipulation;
}

@media (max-width: 480px) {
    .welcome-modal {
        width: 98%;
        padding: 20px 16px;
        padding-bottom: 0;
    }

    .popover-container {
        width: 260px;
    }

    .popover-actions {
        gap: 8px;
    }

    .popover-btn {
        /* Mantieni stili desktop uniformi */
        text-align: center;
        padding: 8px 16px;
        border: none;
        border-radius: 4px;
        font-size: 0.9rem;
        font-weight: 500;
    }

    .tour-close-link {
        /* Mantieni stili desktop uniformi */
        color: white;
        text-align: center;
        font-size: 0.8rem;
        text-decoration: underline;
    }
}

/* AGGIUNGI QUESTE REGOLE CSS AL TUO FILE ESISTENTE */

/* Evidenziazione migliorata per tutti i dispositivi */
.tour-highlight {
    position: relative !important;
    z-index: 10002 !important;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    border-radius: 12px !important;
    
    /* Effetto glow più evidente */
    box-shadow: 
        0 0 0 3px rgba(255, 255, 255, 1),
        0 0 0 6px rgba(87, 75, 224, 0.4),
        0 12px 40px rgba(87, 75, 224, 0.3),
        0 4px 16px rgba(0, 0, 0, 0.2) !important;
    
    /* Background più evidente */
    background: rgba(255, 255, 255, 0.98) !important;
    
    /* Animazione pulsante per attirare l'attenzione */
    animation: tourHighlightPulse 2s ease-in-out infinite;
}

/* Animazione pulsante per l'evidenziazione */
@keyframes tourHighlightPulse {
    0%, 100% {
        box-shadow: 
            0 0 0 3px rgba(255, 255, 255, 1),
            0 0 0 6px rgba(87, 75, 224, 0.4),
            0 12px 40px rgba(87, 75, 224, 0.3),
            0 4px 16px rgba(0, 0, 0, 0.2);
    }
    50% {
        box-shadow: 
            0 0 0 3px rgba(255, 255, 255, 1),
            0 0 0 8px rgba(87, 75, 224, 0.6),
            0 16px 50px rgba(87, 75, 224, 0.4),
            0 6px 20px rgba(0, 0, 0, 0.3);
    }
}

/* Evidenziazione specifica per workflow items */
#tour-categories.tour-highlight,
#tour-products.tour-highlight,
#tour-templates.tour-highlight,
#tour-qrcode.tour-highlight,
#tour-customize.tour-highlight {
    background: rgba(255, 255, 255, 0.98) !important;
    border-radius: 16px !important;
    transform: scale(1.02) !important; /* Leggero ingrandimento */
    
    box-shadow: 
        0 0 0 3px rgba(255, 255, 255, 1),
        0 0 0 6px rgba(87, 75, 224, 0.5),
        0 16px 50px rgba(87, 75, 224, 0.4),
        0 8px 24px rgba(0, 0, 0, 0.3) !important;
}

/* Mobile e Tablet specifici */
@media (max-width: 1024px) {
    .tour-highlight {
        /* Su mobile/tablet, evidenziazione ancora più forte */
        transform: scale(1.03) !important;
        
        box-shadow: 
            0 0 0 4px rgba(255, 255, 255, 1),
            0 0 0 8px rgba(87, 75, 224, 0.6),
            0 20px 60px rgba(87, 75, 224, 0.4),
            0 8px 24px rgba(0, 0, 0, 0.3) !important;
        
        /* Background ancora più evidente */
        background: rgba(255, 255, 255, 1) !important;
    }
    
    /* Workflow items su mobile/tablet */
    #tour-categories.tour-highlight,
    #tour-products.tour-highlight,
    #tour-templates.tour-highlight,
    #tour-qrcode.tour-highlight,
    #tour-customize.tour-highlight {
        transform: scale(1.04) !important;
        border-radius: 20px !important;
        
        box-shadow: 
            0 0 0 4px rgba(255, 255, 255, 1),
            0 0 0 8px rgba(87, 75, 224, 0.7),
            0 24px 70px rgba(87, 75, 224, 0.5),
            0 12px 30px rgba(0, 0, 0, 0.4) !important;
    }
    
    /* Assicurati che il testo rimanga leggibile */
    .tour-highlight * {
        color: inherit !important;
        text-shadow: none !important;
    }
}

/* Solo mobile (sotto 768px) */
@media (max-width: 768px) {
    .tour-highlight {
        /* Su mobile, evidenziazione massima */
        transform: scale(1.05) !important;
        border-radius: 16px !important;
        
        /* Animazione più evidente su mobile */
        animation: tourHighlightPulseMobile 1.5s ease-in-out infinite;
    }
    
    /* Animazione speciale per mobile */
    @keyframes tourHighlightPulseMobile {
        0%, 100% {
            box-shadow: 
                0 0 0 4px rgba(255, 255, 255, 1),
                0 0 0 8px rgba(87, 75, 224, 0.7),
                0 20px 60px rgba(87, 75, 224, 0.4),
                0 8px 24px rgba(0, 0, 0, 0.3);
            transform: scale(1.05);
        }
        50% {
            box-shadow: 
                0 0 0 4px rgba(255, 255, 255, 1),
                0 0 0 12px rgba(87, 75, 224, 0.8),
                0 28px 80px rgba(87, 75, 224, 0.5),
                0 12px 32px rgba(0, 0, 0, 0.4);
            transform: scale(1.06);
        }
    }
    
    /* Workflow items evidenziazione massima su mobile */
    #tour-categories.tour-highlight,
    #tour-products.tour-highlight,
    #tour-templates.tour-highlight,
    #tour-qrcode.tour-highlight,
    #tour-customize.tour-highlight {
        transform: scale(1.06) !important;
        border-radius: 20px !important;
        margin: 8px 0 !important; /* Spazio extra per l'effetto scale */
    }
}

/* Popover inizialmente nascosto per evitare flash */
.popover-container {
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

/* Miglioramenti per l'overlay su mobile */
@media (max-width: 1024px) {
    .tour-overlay.step-overlay {
        background-color: rgba(0, 0, 0, 0.5) !important;
        backdrop-filter: blur(3px) !important;
    }
}

@media (max-width: 768px) {
    .tour-overlay.step-overlay {
        background-color: rgba(0, 0, 0, 0.6) !important;
        backdrop-filter: blur(4px) !important;
    }
}

/* === REGOLE CSS DEFINITIVE PER TOUR MOBILE === */

/* Forza visibilità degli elementi tour su TUTTI i dispositivi */
#tour-categories,
#tour-products,
#tour-templates,
#tour-qrcode,
#tour-customize {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    min-height: 60px !important;
    min-width: 200px !important;
}

/* Forza visibilità del container workflow */
.workflow-container {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    overflow: visible !important;
}

/* Forza visibilità di tutti i workflow-item */
.workflow-item {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    min-height: 60px !important;
    min-width: 200px !important;
    margin-bottom: 8px !important;
}

/* Assicura che nessun parent nasconda gli elementi del tour */
.card-listino,
.card-listino .workflow-container,
.card-listino .workflow-item {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    overflow: visible !important;
}

/* Mobile specifico - regole ancora più forti */
@media (max-width: 768px) {
    
    /* Forza tutti i contenitori parent */
    .workflow-container,
    .card-listino,
    .dashboard-content,
    .main-content {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        overflow: visible !important;
    }
    
    /* Assicura che i workflow-item abbiano dimensioni visibili */
    .workflow-item {
        min-height: 70px !important;
        min-width: 280px !important;
        padding: 12px !important;
        margin: 8px 0 !important;
        box-sizing: border-box !important;
    }
    
    /* Forza visibilità del contenuto interno */
    .workflow-content,
    .workflow-text,
    .workflow-title {
        visibility: visible !important;
        opacity: 1 !important;
    }
}

/* DURANTE IL TOUR - regole speciali */
body.tour-active [id^="tour-"] {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 2 !important;
    min-height: 70px !important;
}

/* Evidenziazione potenziata per mobile - MOLTO più visibile */
@media (max-width: 768px) {
    .tour-highlight {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
        z-index: 10002 !important;
        
        /* Evidenziazione super forte */
        background: rgba(255, 255, 255, 1) !important;
        border: 4px solid #574BE0 !important;
        border-radius: 16px !important;
        
        /* Scaling più evidente */
        transform: scale(1.08) !important;
        
        /* Shadow molto evidente */
        box-shadow: 
            0 0 0 4px rgba(255, 255, 255, 1),
            0 0 0 8px rgba(87, 75, 224, 0.8),
            0 0 30px rgba(87, 75, 224, 0.6),
            0 10px 40px rgba(0, 0, 0, 0.4) !important;
        
        /* Animazione ancora più evidente */
        animation: tourHighlightPulseMobileStrong 1.2s ease-in-out infinite !important;
        
        /* Margini per compensare il scaling */
        margin: 16px 8px !important;
    }
    
    @keyframes tourHighlightPulseMobileStrong {
        0%, 100% {
            transform: scale(1.08);
            box-shadow: 
                0 0 0 4px rgba(255, 255, 255, 1),
                0 0 0 8px rgba(87, 75, 224, 0.8),
                0 0 30px rgba(87, 75, 224, 0.6),
                0 10px 40px rgba(0, 0, 0, 0.4);
        }
        50% {
            transform: scale(1.12);
            box-shadow: 
                0 0 0 4px rgba(255, 255, 255, 1),
                0 0 0 12px rgba(87, 75, 224, 1),
                0 0 40px rgba(87, 75, 224, 0.8),
                0 15px 50px rgba(0, 0, 0, 0.5);
        }
    }
}

/* ========================================
   STILI UNIFORMI BOTTONI PER TUTTI I DISPOSITIVI
   ======================================== */

/* Override COMPLETO per mantenere stili desktop su mobile */
@media (max-width: 768px) {
    .popover-btn,
    .popover-btn.btn-next,
    .popover-btn.btn-skip {
        /* Forza stili desktop anche su mobile */
        padding: 8px 16px !important;
        border-radius: 4px !important;
        font-size: 0.9rem !important;
        font-weight: 500 !important;
        min-height: 36px !important;
        border: none !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
    }
    
    .popover-btn.btn-next {
        background: linear-gradient(135deg, #24D07E, #1fa86a) !important;
        color: white !important;
        font-weight: 600 !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
    }
    
    .popover-btn.btn-skip {
        background-color: #122999 !important;
        color: #4a5568 !important;
    }
    
    .tour-close-link {
        font-size: 0.8rem !important;
        color: white !important;
        text-decoration: underline !important;
        padding: 4px !important;
        min-height: 24px !important;
    }
    
    /* Forza anche gli hover su mobile */
    .popover-btn.btn-next:hover,
    .popover-btn.btn-next:active {
        background: linear-gradient(135deg, #1fa86a, #188a5a) !important;
        transform: translateY(-1px) !important;
        box-shadow: 0 4px 12px rgba(36, 208, 126, 0.3) !important;
    }
    
    .tour-close-link:hover,
    .tour-close-link:active {
        color: #4a5568 !important;
    }
}