/* Table Price Plugin Styles - Versione Corretta Senza Sovrapposizioni */

/* ==========================================================================
   TOOLTIP MIGLIORATO - SOLUZIONE SEMPLICE SENZA JAVASCRIPT
   ========================================================================== */

.tooltip {
    position: relative;
    cursor: help;
    color: #204b90;
    font-weight: bold;
    z-index: 999999; /* Z-index molto alto sull'elemento stesso */
}

.tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 15px); /* Aumentato lo spazio */
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: normal;
    line-height: 1.4;
    max-width: 300px;
    width: max-content;
    text-align: left;
    z-index: 9999999; /* Z-index estremamente alto */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.tooltip:hover::before {
    content: "";
    position: absolute;
    bottom: calc(100% + 9px);
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #333;
    z-index: 9999998;
}

/* Forza tutti i container a non nascondere i tooltip */
.pricing-card * {
    overflow: visible !important;
}

/* ==========================================================================
   CONTAINER E LAYOUT PRINCIPALE
   ========================================================================== */

.table-price-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin: 20px 0;
    justify-content: flex-start;
    width: 100%;
    align-items: stretch; /* Tutte le card hanno la stessa altezza */
}

.pricing-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: visible;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 800px; /* Altezza minima per tutte le card */
}

.pricing-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* ==========================================================================
   LAYOUT RESPONSIVO PER NUMERO DI PRODOTTI - MASSIMO 4 COLONNE
   ========================================================================== */

.table-price-container.products-1 .pricing-card {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

.table-price-container.products-2 .pricing-card {
    width: calc(50% - 10px);
    flex: 0 0 calc(50% - 10px);
}

.table-price-container.products-3 .pricing-card {
    width: calc(33.333% - 14px);
    flex: 0 0 calc(33.333% - 14px);
}

.table-price-container.products-4 .pricing-card,
.table-price-container.products-more .pricing-card {
    width: calc(25% - 15px);
    flex: 0 0 calc(25% - 15px);
}

/* ==========================================================================
   HEADER PRODOTTO - ALTEZZA FISSA PER ALLINEAMENTO
   ========================================================================== */

.plan-header {
    background: #204b90 !important;
    color: white !important;
    text-align: center;
    padding: 30px 20px 25px;
    position: relative;
    height: 240px; /* Altezza fissa per allineamento perfetto */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-shrink: 0;
}

.plan-header::after {
    content: "";
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-top: 10px solid #204b90;
}

.plan-header h2 {
    margin: 0;
    font-size: 1.5em;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    color: white !important;
    height: 80px; /* Altezza fissa per il titolo */
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.3;
}

.price {
    font-size: 2.5em;
    font-weight: bold;
    margin: 15px 0;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 5px;
    color: white !important;
    height: 70px; /* Altezza fissa per il prezzo */
}

.price .currency {
    font-size: 0.6em;
    vertical-align: top;
}

.price .period {
    font-size: 0.4em;
    opacity: 0.8;
}

.subtitle {
    margin: 10px 0 0 0;
    font-size: 1.1em;
    opacity: 0.9;
    color: white !important;
    height: 30px; /* Altezza fissa per il sottotitolo */
    display: flex;
    align-items: center;
    justify-content: center;
}

.hr_color {
    border: 0;
    height: 2px;
    background: rgba(255,255,255,0.3);
    margin: 10px 0;
}

/* ==========================================================================
   CONTENUTO CARD - STRUTTURA CON FLEXBOX (NON GRID)
   ========================================================================== */

.plan-inside {
    padding: 25px 20px;
    background: #fafafa;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* Per le card SENZA periodo, aggiungi padding */
.plan-inside:not(:has(.periodo)) {
    padding-top: 102px;
}

/* ==========================================================================
   SEZIONE PERIODO - ALTEZZA AUTOMATICA
   ========================================================================== */

.periodo {
    margin: 0 0 20px 0;
    min-height: 60px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.periodo label {
    display: inline-block;
    margin: 5px 10px;
    padding: 8px 7px;
    background: #f0f0f0;
    border: 2px solid #ddd;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.periodo label:hover {
    background: #e0e0e0;
    border-color: #204b90;
}

.periodo input[type="radio"] {
    display: none;
}

.periodo input[type="radio"]:checked + span,
.periodo label:has(input[type="radio"]:checked) {
    background: #204b90 !important;
    color: white !important;
    border-color: #204b90 !important;
}

/* ==========================================================================
   SEZIONE SLIDERS - WRAPPER CON ALTEZZA FISSA
   ========================================================================== */

.sliders-wrapper {
    height: 350px; /* Altezza FISSA per allineare tutte le voci */
    overflow: hidden;
    grid-row: 2; /* Seconda riga della grid */
}

.sliders,
#sliders.sliders {
    margin: 0;
    height: 100%;
    overflow-x: visible;
    overflow-y: auto; /* Scroll verticale se necessario */
    padding-right: 5px; /* Spazio per la scrollbar */
}

/* Stile scrollbar personalizzato (webkit) */
.sliders::-webkit-scrollbar {
    width: 6px;
}

.sliders::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.sliders::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.sliders::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.sliders ul,
#sliders {
    list-style: none !important;
    padding: 0;
    margin: 0;
}

.sliders li,
#sliders li {
    margin: 15px 0;
    padding: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    overflow: visible;
}

.slider {
    margin: 10px 0;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    position: relative;
}

/* ==========================================================================
   SEZIONE VOCI/CARATTERISTICHE
   ========================================================================== */

.voci {
    margin-top: 0;
    padding-top: 15px;
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: visible;
    border-top: 1px solid #eee;
}

.voci ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.voci li {
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    position: relative;
    padding-left: 25px;
    min-height: 45px; /* Altezza minima per ogni voce */
    display: flex;
    align-items: center;
}

.voci .spunta:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #4CAF50;
    font-weight: bold;
    font-size: 1.2em;
    top: 50%;
    transform: translateY(-50%);
}

.voci li:last-child {
    border-bottom: none;
}

/* ==========================================================================
   FOOTER E PULSANTI - ALTEZZA FISSA
   ========================================================================== */

.plan-footer {
    padding: 25px 20px;
    text-align: center;
    background: white;
    border-top: 1px solid #eee;
    height: 120px; /* Altezza fissa per allineamento */
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.footer-buttons {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.button-row {
    display: flex;
    gap: 8px; /* Gap ridotto */
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap; /* Non vanno a capo */
    width: 100%;
}

/* Override CSS del tema per i form */
.pricing-card form,
.table-price-container form {
    background-color: transparent !important;
    border: none !important;
    margin: 0 !important;
    border-radius: 0 !important;
    padding: 0 !important;
}

.pricing-card form button,
.table-price-container form button {
    width: 130px !important;
    height: 42px !important;
    margin: 3px !important;
    padding: 10px 15px !important;
    box-sizing: border-box !important;
    font-size: 0.9em !important;
}

/* ==========================================================================
   STILI PULSANTI
   ========================================================================== */

.btn-primary,
.btn-secondary {
    background: white !important;
    color: #204b90 !important;
    border: 2px solid #204b90 !important;
    padding: 10px 15px;
    border-radius: 0;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 3px;
    width: 130px;
    height: 42px;
    text-align: center;
    box-sizing: border-box;
    white-space: nowrap; /* Impedisce al testo di andare a capo */
}

.btn-primary:hover,
.btn-secondary:hover {
    background: #204b90 !important;
    color: white !important;
    border-color: #204b90 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(32, 75, 144, 0.4);
    text-decoration: none;
}

/* ==========================================================================
   POPUP STYLES
   ========================================================================== */

.table-price-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: none;
    animation: fadeIn 0.3s ease;
}

.table-price-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 10000;
    animation: slideIn 0.3s ease;
}

.popup-header-table-price {
    background: #204b90;
    color: white;
    padding: 20px;
    border-radius: 12px 12px 0 0;
    position: relative;
}

.popup-header-table-price h3 {
    margin: 0;
    font-size: 1.4em;
    font-weight: 600;
    color: #fff;
}

.popup-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.popup-close:hover {
    opacity: 0.7;
}

.popup-content-table-price {
    padding: 25px;
}

.popup-product-info {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.popup-product-name {
    font-size: 1.3em;
    font-weight: 600;
    color: #204b90;
    margin-bottom: 10px;
}

.popup-product-price {
    font-size: 1.8em;
    font-weight: bold;
    color: #204b90;
    margin-bottom: 15px;
}

.popup-product-period {
    font-size: 1.1em;
    color: #666;
    margin-bottom: 15px;
}

.popup-extras {
    margin-bottom: 20px;
}

.popup-extras h4 {
    margin: 0 0 15px 0;
    font-size: 1.1em;
    color: #333;
}

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

.popup-extras li {
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.popup-extras li:last-child {
    border-bottom: none;
}

.popup-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.popup-btn {
    padding: 12px 30px;
    border: 2px solid #204b90;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    min-width: 120px;
    text-align: center;
}

.popup-btn-confirm {
    background: #204b90;
    color: white;
}

.popup-btn-confirm:hover {
    background: #163860;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(32, 75, 144, 0.4);
}

.popup-btn-cancel {
    background: white;
    color: #204b90;
}

.popup-btn-cancel:hover {
    background: #f5f5f5;
    transform: translateY(-2px);
}

/* ==========================================================================
   ANIMAZIONI
   ========================================================================== */

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

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translate(-50%, -60%);
    }
    to { 
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

@media (max-width: 1200px) {
    .table-price-container.products-4 .pricing-card,
    .table-price-container.products-more .pricing-card {
        width: calc(33.333% - 14px);
        flex: 0 0 calc(33.333% - 14px);
    }
}

@media (max-width: 1024px) {
    .table-price-container.products-3 .pricing-card,
    .table-price-container.products-4 .pricing-card,
    .table-price-container.products-more .pricing-card {
        width: calc(50% - 10px);
        flex: 0 0 calc(50% - 10px);
    }
    
    .plan-header {
        height: 200px;
    }
    
    .plan-header h2 {
        height: 60px;
        font-size: 1.3em;
    }
    
    .price {
        height: 60px;
        font-size: 2.2em;
    }
    
    .plan-inside {
        padding: 25px 20px;
    }
    
    .plan-inside:not(:has(.periodo)) {
        padding-top: 70px;
    }
}

@media (max-width: 768px) {
    .table-price-container .pricing-card {
        width: 100% !important;
        flex: 0 0 100% !important;
        margin: 10px 0;
        min-height: auto; /* Rimuovi altezza minima su mobile */
    }
    
    .table-price-container {
        flex-direction: column;
        align-items: center;
    }
    
    .plan-header {
        padding: 20px 15px;
        height: 180px;
    }
    
    .plan-header h2 {
        height: 50px;
        font-size: 1.2em;
    }
    
    .price {
        font-size: 2em;
        height: 50px;
    }
    
    .subtitle {
        height: 25px;
        font-size: 1em;
    }
    
    .plan-inside {
        padding: 20px 15px;
    }
    
    .plan-inside:not(:has(.periodo)) {
        padding-top: 20px;
    }
    
    .sliders-wrapper {
        height: auto !important; /* Forza altezza automatica su mobile */
    }
    
    .sliders {
        max-height: none !important; /* Rimuovi limite su mobile */
        overflow-y: visible !important;
    }

    .voci {
        margin-top: 15px;
    }
    
    .plan-footer {
        height: 100px;
    }
    
    .table-price-popup {
        width: 95%;
        max-height: 90vh;
    }
    
    .popup-content-table-price {
        padding: 20px;
    }
    
    .popup-buttons {
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }
    
    .popup-btn {
        width: 100%;
        max-width: 280px;
        text-align: center;
        margin: 5px 0;
    }
}