/**
 * CSS per Multi Product PDF Generator
 * Stili per la selezione prodotti e carrello
 */

/* ===== PULSANTI DI SELEZIONE PRODOTTO ===== */
.pdf-product-selection-button {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    color: #495057;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-block;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.pdf-product-selection-button:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.pdf-product-selection-button.selected {
    background: #28a745;
    border-color: #28a745;
    color: white;
}

.pdf-product-selection-button.selected:hover {
    background: #218838;
    border-color: #1e7e34;
}

.pdf-product-selection-button:active {
    transform: translateY(0);
}

.pdf-product-selection-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Varianti per tipo di selezione */
.product-selection-product {
    font-size: 13px;
    padding: 6px 12px;
}

.product-selection-post {
    font-size: 15px;
    padding: 10px 20px;
    font-weight: 600;
}

/* ===== CARRELLO PRODOTTI ===== */
.products-cart-container {
    position: relative;
    display: inline-block;
    margin: 10px;
}

.products-cart-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    background: #007cba;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0,124,186,0.3);
}

.products-cart-icon:hover {
    background: #005a87;
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0,124,186,0.4);
}

.products-cart-icon i {
    font-size: 20px;
}

.products-cart-counter {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s ease;
}

.products-cart-container.has-items .products-cart-counter {
    opacity: 1;
    transform: scale(1);
}

/* Preview del carrello */
.products-cart-preview {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 300px;
    max-width: 400px;
    display: none;
    margin-top: 10px;
}

.products-cart-preview::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid white;
}

.products-cart-items {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 300px;
    overflow-y: auto;
}

.cart-item {
    display: flex;
    align-items: flex-start;
    padding: 12px 15px;
    border-bottom: 1px solid #f8f9fa;
    position: relative;
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item:hover {
    background: #f8f9fa;
}

.cart-item-info {
    flex: 1;
    margin-right: 10px;
}

.cart-item-name {
    font-weight: 600;
    color: #212529;
    font-size: 14px;
    margin-bottom: 4px;
    line-height: 1.3;
}

.cart-item-post {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 2px;
    font-style: italic;
}

.cart-item-debug {
    font-size: 10px;
    color: #8392a5;
    font-family: monospace;
    margin-bottom: 2px;
    background: #f8f9fa;
    padding: 2px 4px;
    border-radius: 2px;
}

.cart-item-status {
    font-size: 11px;
    color: #6c757d;
    margin-bottom: 2px;
    font-weight: 500;
}

.cart-post-header {
    background: #e9ecef;
    padding: 8px 15px;
    font-size: 13px;
    color: #495057;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
}

.cart-post-header + .cart-item {
    border-top: none;
}

/* Debug info generale */
.debug-info {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 15px;
    margin: 10px 0;
    font-family: monospace;
    font-size: 13px;
}

.debug-info h4 {
    margin-top: 0;
    color: #495057;
    font-family: inherit;
}

.debug-info ul {
    margin: 10px 0 0 0;
    padding-left: 20px;
}

.debug-info li {
    margin-bottom: 5px;
    line-height: 1.4;
}

.cart-item-qty,
.cart-item-price {
    font-size: 12px;
    color: #495057;
    margin-bottom: 2px;
}

.cart-item-price {
    font-weight: 600;
    color: #28a745;
}

.remove-cart-item {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-size: 14px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-cart-item:hover {
    background: #dc3545;
    color: white;
}

.empty-cart {
    padding: 20px 15px;
    text-align: center;
    color: #6c757d;
    font-style: italic;
}

.clear-cart-btn {
    width: 100%;
    padding: 10px 15px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 0 0 8px 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.3s ease;
}

.clear-cart-btn:hover {
    background: #c82333;
}

/* ===== GENERATORE PDF ===== */
.pdf-generator-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 20px 0;
}

.generate-multi-product-pdf-button {
    background: linear-gradient(135deg, #007cba 0%, #005a87 100%);
    color: white !important;
    border: none !important;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,124,186,0.3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.generate-multi-product-pdf-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,124,186,0.4);
}

.generate-multi-product-pdf-button:active {
    transform: translateY(0);
}

.generate-multi-product-pdf-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.selected-products-count {
    background: #f8f9fa;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    color: #495057;
    border: 1px solid #dee2e6;
}

.selected-products-count span {
    font-weight: 600;
    color: #007cba;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .products-cart-preview {
        position: fixed;
        top: 50%;
        left: 50%;
        right: auto;
        transform: translate(-50%, -50%);
        min-width: 280px;
        max-width: 90vw;
        max-height: 80vh;
        margin-top: 0;
    }
    
    .products-cart-preview::before {
        display: none;
    }
    
    .pdf-product-selection-button {
        font-size: 13px;
        padding: 6px 12px;
    }
    
    .generate-multi-product-pdf-button {
        font-size: 14px;
        padding: 10px 20px;
    }
    
    .pdf-generator-container {
        margin: 15px 0;
    }
}

@media (max-width: 480px) {
    .products-cart-icon {
        width: 45px;
        height: 45px;
    }
    
    .products-cart-icon i {
        font-size: 18px;
    }
    
    .products-cart-counter {
        width: 20px;
        height: 20px;
        font-size: 11px;
    }
    
    .cart-item {
        padding: 10px 12px;
    }
    
    .cart-item-name {
        font-size: 13px;
    }
    
    .cart-item-post,
    .cart-item-qty,
    .cart-item-price {
        font-size: 11px;
    }
}

/* ===== ANIMAZIONI ===== */
@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 124, 186, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(0, 124, 186, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 124, 186, 0);
    }
}

.products-cart-container.has-items .products-cart-icon {
    animation: pulse 2s infinite;
}

.products-cart-counter {
    animation: bounceIn 0.6s ease-out;
}

.products-cart-preview {
    animation: slideIn 0.3s ease-out;
}

.cart-item {
    animation: slideIn 0.3s ease-out;
}

/* ===== STATI LOADING ===== */
.generate-multi-product-pdf-button.loading {
    position: relative;
    color: transparent;
}

.generate-multi-product-pdf-button.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* ===== TOOLTIP PERSONALIZZATI ===== */
.pdf-product-selection-button[data-tooltip] {
    position: relative;
}

.pdf-product-selection-button[data-tooltip]:hover::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 5px;
}

.pdf-product-selection-button[data-tooltip]:hover::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #333;
    z-index: 1000;
}

/* ===== FOCUS E ACCESSIBILITÀ ===== */
.pdf-product-selection-button:focus,
.generate-multi-product-pdf-button:focus,
.remove-cart-item:focus,
.clear-cart-btn:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.products-cart-icon:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* ===== TEMI SCURO (OPZIONALE) ===== */
@media (prefers-color-scheme: dark) {
    .products-cart-preview {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .cart-item:hover {
        background: #4a5568;
    }
    
    .cart-item-name {
        color: #e2e8f0;
    }
    
    .cart-item-post {
        color: #a0aec0;
    }
    
    .cart-item-qty,
    .cart-item-price {
        color: #cbd5e0;
    }
    
    .empty-cart {
        color: #a0aec0;
    }
    
    .selected-products-count {
        background: #4a5568;
        color: #e2e8f0;
        border-color: #718096;
    }
}

/* ===== UTILITÀ ===== */
.hidden {
    display: none !important;
}

.fade-in {
    animation: slideIn 0.3s ease-out;
}

.bounce-in {
    animation: bounceIn 0.6s ease-out;
}

/* ===== DEBUG (RIMUOVERE IN PRODUZIONE) ===== */
.debug-mode .pdf-product-selection-button::after {
    content: ' [' attr(data-item-id) ']';
    font-size: 10px;
    opacity: 0.7;
}

.debug-mode .cart-item::before {
    content: attr(data-item-id);
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 9px;
    background: #ffc107;
    color: #000;
    padding: 1px 3px;
    border-radius: 2px;
}

/* ===== PRINT STYLES ===== */
@media print {
    .products-cart-container,
    .pdf-generator-container,
    .pdf-product-selection-button {
        display: none !important;
    }
}

/* ===== COMPATIBILITÀ CON TEMI WORDPRESS ===== */
.wp-block-group .pdf-product-selection-button,
.wp-block-columns .pdf-product-selection-button {
    margin: 5px;
}

.elementor-widget .pdf-product-selection-button {
    width: auto;
    height: auto;
}

/* Correzioni per temi che sovrascrivono i button */
button.pdf-product-selection-button,
button.generate-multi-product-pdf-button {
    font-family: inherit;
    line-height: normal;
}

/* ===== INTEGRAZIONI CON PLUGIN POPOLARI ===== */

/* WooCommerce */
.woocommerce .pdf-product-selection-button {
    margin: 0 5px 5px 0;
}

/* Contact Form 7 */
.wpcf7-form .pdf-product-selection-button {
    margin: 5px 0;
}

/* Elementor */
.elementor-button-wrapper .pdf-product-selection-button {
    display: inline-block;
}


