/* Styles pour le frontend */

/* Sélecteurs d'attributs (Formule et Concentration) */
.dwp-custom-selectors-wrapper {
    margin: 20px 0;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

/* Cacher le sélecteur de quantité WooCommerce par défaut quand notre plugin est actif */
.dwp-custom-selectors-wrapper ~ form.cart .quantity,
form.cart:has(~ .dwp-custom-selectors-wrapper) .quantity {
    display: none !important;
}

/* Alternative : cacher via le wrapper parent */
body.single-product .dwp-quantity-selector-wrapper {
    display: block;
}

body.single-product .dwp-quantity-selector-wrapper ~ * .quantity {
    display: none !important;
}

/* Cacher tous les sélecteurs de quantité WooCommerce sur les pages avec notre plugin */
.single-product form.cart div.quantity {
    display: none !important;
}

/* Cacher les sélecteurs d'attributs WooCommerce (Formule, Concentration, etc.) */
.single-product .variations,
.single-product form.cart table.variations,
.single-product .variations_form table.variations {
    display: none !important;
}

/* Cacher les selects d'attributs individuels */
.single-product form.cart select[name^="attribute_"] {
    display: none !important;
}

/* Cacher le prix des variations WooCommerce */
.single-product .woocommerce-variation-price,
.single-product .woocommerce-variation .price,
.single-product .woocommerce-variation-description {
    display: none !important;
}

/* Cacher le bouton reset des variations */
.single-product .reset_variations {
    display: none !important;
}

.dwp-attribute-label {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
}

.dwp-attribute-selector {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

/* Boutons d'attributs avec images */
.dwp-attribute-option {
    padding: 0;
    border: 3px solid transparent;
    background: white;
    cursor: pointer;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

/* Boutons avec image */
.dwp-attribute-option.dwp-image-option {
    padding: 0;
    width: 150px;
    height: auto;
}

/* Image de l'attribut */
.dwp-attribute-image {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
}

/* Check overlay (caché par défaut) */
.dwp-check-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    font-weight: bold;
    color: white;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    z-index: 10;
}

/* Boutons avec texte seulement (concentration ou fallback sans image) */
.dwp-attribute-option:not(.dwp-image-option) {
    padding: 10px 20px;
    border: 2px solid #ddd;
    min-width: 80px;
    text-align: center;
}

.dwp-attribute-text {
    display: block;
    font-weight: 600;
    color: #333;
}

.dwp-attribute-option:hover {
    border-color: #2271b1;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* État sélectionné */
.dwp-attribute-option.selected {
    border-color: #2271b1;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.2);
}

/* Check visible quand sélectionné */
.dwp-attribute-option.selected .dwp-check-overlay {
    opacity: 1;
}

/* Image légèrement assombrie quand sélectionnée */
.dwp-attribute-option.selected .dwp-attribute-image {
    filter: brightness(0.8);
}

/* Boutons texte sélectionnés */
.dwp-attribute-option.selected:not(.dwp-image-option) {
    background: #2271b1;
    color: white;
    border-color: #2271b1;
}

.dwp-attribute-option.dwp-option-disabled {
    display: none !important;
}

/* Sélecteur de quantité personnalisé */
.dwp-quantity-selector-wrapper {
    margin: 20px 0;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.dwp-quantity-label {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
}

.dwp-quantity-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    max-width: 200px;
    margin: 0 auto;
}

.dwp-quantity-btn {
    width: 50px;
    height: 50px;
    border: 2px solid #2271b1;
    background: #fff;
    color: #2271b1;
    font-size: 24px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.dwp-quantity-minus {
    border-radius: 8px 0 0 8px;
    border-right: none;
}

.dwp-quantity-plus {
    border-radius: 0 8px 8px 0;
    border-left: none;
}

.dwp-quantity-btn:hover {
    background: #2271b1;
    color: #fff;
    transform: scale(1.05);
}

.dwp-quantity-btn:active {
    transform: scale(0.95);
}

.dwp-quantity-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.dwp-quantity-display {
    min-width: 100px;
    height: 50px;
    border-top: 2px solid #2271b1;
    border-bottom: 2px solid #2271b1;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.dwp-quantity-value {
    font-size: 24px;
    font-weight: 700;
    color: #2271b1;
}

.dwp-quantity-unit {
    font-size: 18px;
    font-weight: 600;
    color: #666;
}

.dwp-quantity-info {
    text-align: center;
    font-size: 13px;
    color: #666;
    margin-top: 10px;
    font-style: italic;
}

/* Sélecteur d'attributs avec images */
.dwp-attribute-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 15px 0;
}

.dwp-attribute-option {
    position: relative;
    cursor: pointer;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    transition: all 0.3s ease;
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.dwp-attribute-option:hover {
    border-color: #999;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.dwp-attribute-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.dwp-attribute-option input[type="radio"]:checked + .dwp-option-content {
    color: #2271b1;
    font-weight: 600;
}

.dwp-attribute-option input[type="radio"]:checked ~ * {
    border-color: #2271b1;
}

.dwp-attribute-option:has(input:checked) {
    border-color: #2271b1;
    background: #f0f6fc;
    box-shadow: 0 0 0 1px #2271b1;
}

.dwp-option-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.dwp-option-content img {
    max-width: 60px;
    height: auto;
    border-radius: 4px;
}

.dwp-option-label {
    font-size: 14px;
    line-height: 1.4;
}

/* Affichage du poids sélectionné */
.dwp-weight-wrapper {
    margin: 20px 0;
    padding: 15px 20px;
    background: linear-gradient(135deg, #f7f9fc 0%, #e8f0f9 100%);
    border-radius: 8px;
    border-left: 4px solid #2271b1;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.dwp-weight-display {
    display: flex;
    align-items: center;
}

.dwp-weight-label {
    font-weight: 600;
    color: #333;
    font-size: 16px;
}

.dwp-weight-amount {
    font-size: 24px;
    font-weight: 700;
    color: #2271b1;
    margin-left: 10px;
}

/* Affichage du prix calculé */
.dwp-calculated-price-wrapper {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    background: #f9f9f9;
    margin: 20px 0;
}

.dwp-calculated-price {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.dwp-price-label {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.dwp-price-value {
    font-size: 24px;
    font-weight: 700;
    color: #2271b1;
}

.dwp-price-value .woocommerce-Price-amount {
    display: inline-block;
}

.dwp-price-number {
    font-size: 28px;
}

.dwp-price-details {
    margin-top: 10px;
    font-size: 14px;
    color: #666;
}

.dwp-price-per-kg {
    font-style: italic;
}

/* Cache le select standard */
.dwp-hidden-select {
    display: none !important;
}

/* Variantes pour différentes tailles */
.dwp-pa_formule .dwp-attribute-option {
    min-width: 100px;
}

.dwp-pa_concentration .dwp-attribute-option {
    min-width: 110px;
}

/* État désactivé */
.dwp-attribute-option.disabled,
.dwp-attribute-option.dwp-option-disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
    background: #f5f5f5;
    border-color: #ccc;
}

.dwp-attribute-option.disabled:hover,
.dwp-attribute-option.dwp-option-disabled:hover {
    border-color: #ccc;
    box-shadow: none;
    transform: none;
}

.dwp-attribute-option.disabled::after,
.dwp-attribute-option.dwp-option-disabled::after {
    content: "✕";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 40px;
    color: rgba(255, 0, 0, 0.3);
    font-weight: bold;
    pointer-events: none;
}

/* Animation de chargement */
.dwp-calculated-price-wrapper.loading {
    opacity: 0.6;
    pointer-events: none;
}

.dwp-calculated-price-wrapper.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2271b1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Messages d'erreur */
.dwp-error-message {
    color: #d63638;
    font-size: 14px;
    margin-top: 10px;
    padding: 10px;
    background: #fcf0f1;
    border-left: 4px solid #d63638;
    border-radius: 4px;
}

/* Responsive */
@media (max-width: 768px) {
    .dwp-attribute-selector {
        gap: 8px;
    }
    
    .dwp-attribute-option {
        min-width: 70px;
        padding: 8px;
    }
    
    .dwp-option-content img {
        max-width: 50px;
    }
    
    .dwp-option-label {
        font-size: 13px;
    }
    
    .dwp-calculated-price {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .dwp-price-value {
        font-size: 20px;
    }
    
    .dwp-price-number {
        font-size: 24px;
    }
}

@media (max-width: 480px) {
    .dwp-attribute-option {
        min-width: 60px;
        padding: 6px;
    }
    
    .dwp-option-content img {
        max-width: 40px;
    }
    
    .dwp-option-label {
        font-size: 12px;
    }
}
