/**
 * CSS pour le module Free Product Formula
 */

/* Modal overlay */
.formula-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

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

/* Modal content */
.formula-modal-content {
    background: white;
    border-radius: 15px;
    max-width: 900px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

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

/* Bouton de fermeture */
.close-formula-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    font-size: 32px;
    color: #999;
    cursor: pointer;
    z-index: 10;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-formula-modal:hover {
    background: #f0f0f0;
    color: #333;
    transform: rotate(90deg);
}

/* Header de la modal */
.formula-modal-header {
    padding: 30px;
    background: black;
    color: white;
    border-radius: 15px 15px 0 0;
}

.formula-modal-header h2 {
    margin: 0 0 10px 0;
    font-size: 28px;
    font-weight: bold;
    color: white;
}

.formula-modal-header p {
    margin: 0;
    font-size: 16px;
    opacity: 0.9;
}

/* Body de la modal */
.formula-modal-body {
    padding: 30px;
}

/* Badge "OFFERT" sur le produit dans le panier */
.product-line-info .free-product-badge {
    display: inline-block;
    /* background: #28a745; */
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    margin-left: 37px;
    animation: pulse 2s infinite;
    margin-top: 18%;
}

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

/* Désactiver les contrôles de quantité pour les produits gratuits */
.cart-item.is-free-product .qty,
.cart-item.is-free-product .js-cart-line-product-quantity,
.cart-item.is-free-product .bootstrap-touchspin-up,
.cart-item.is-free-product .bootstrap-touchspin-down {
    pointer-events: none;
    opacity: 0.5;
    cursor: not-allowed !important;
}

.cart-item.is-free-product .js-cart-line-product-quantity {
    background-color: #f0f0f0 !important;
}

/* Message pour les produits gratuits */
.cart-item.is-free-product::after {
    content: "Quantité non modifiable";
    display: block;
    font-size: 11px;
    color: #999;
    font-style: italic;
    margin-top: 5px;
}

/* Grille des produits */
.free-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

/* Item produit */
.free-product-item {
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: white;
}

.free-product-item:hover {
    border-color: #667eea;
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.2);
    transform: translateY(-5px);
}

.free-product-item .product-image {
    width: 100%;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
}

.free-product-item .product-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.free-product-item .no-image {
    color: #999;
    font-size: 14px;
}

.free-product-item .product-info {
    flex-grow: 1;
    margin-bottom: 15px;
    width: 100%;
}

.free-product-item h4 {
    font-size: 16px;
    margin: 0 0 10px 0;
    color: #333;
    font-weight: 600;
    min-height: 40px;
}

.free-product-item .product-attributes {
    font-size: 13px;
    color: #666;
    margin: 5px 0;
}

.free-product-item .product-price {
    display: inline-block;
    background: #28a745;
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 14px;
    margin: 10px 0;
}

.free-product-item .btn {
    width: 100%;
    background: #FF3200;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.free-product-item .btn:hover {
    transform: scale(1.05);
}

/* Loader */
#formula-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

#formula-loader .spinner {
    width: 60px;
    height: 60px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Message de succès */
.formula-success-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    z-index: 10001;
    animation: slideInRight 0.3s ease;
    font-size: 16px;
    font-weight: 500;
}

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

.formula-success-message i {
    margin-right: 10px;
    font-size: 18px;
}

/* Empêcher le scroll du body quand la modal est ouverte */
body.formula-modal-open {
    overflow: hidden;
}

/* Responsive */
@media (max-width: 768px) {
    .formula-modal-content {
        width: 95%;
        max-height: 95vh;
    }

    .formula-modal-header {
        padding: 20px;
    }

    .formula-modal-header h2 {
        font-size: 22px;
    }

    .formula-modal-body {
        padding: 20px;
    }

    .free-products-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .free-product-item .product-image {
        height: 150px;
    }
}

/* Style pour le block dans le panier (déjà dans le TPL mais redondance pour être sûr) */
.free-product-formula-container {
    margin: 20px 0;
}

.formula-block {
    margin-bottom: 15px;
}
