/**
 * Styles CSS WooWeight Frontend
 *
 * @package WooWeight
 * @since 1.0.0
 */

/* ========================================
   VARIABLES CSS (peuvent être surchargées)
======================================== */
:root {
    --wooweight-bg: #f9f9f9;
    --wooweight-border: #e0e0e0;
    --wooweight-btn-bg: #2271b1;
    --wooweight-btn-text: #ffffff;
    --wooweight-btn-bg-hover: #1a5a8a;
    --wooweight-btn-text-hover: #ffffff;
    --wooweight-label-color: #333333;
    --wooweight-price-color: #000000;
    --wooweight-padding: 15px;
    --wooweight-gap: 10px;
    --wooweight-radius: 8px;
    --wooweight-border-width: 1px;
    --wooweight-input-gap: 5px;
    --wooweight-mobile-btn-width: 36px;
    --wooweight-mobile-btn-height: 36px;
    --wooweight-mobile-btn-font: 18px;
    --wooweight-mobile-btn-bg: #ffffff;
    --wooweight-mobile-btn-text: #333333;
    --wooweight-mobile-btn-border: #dddddd;
    --wooweight-mobile-btn-border-width: 1px;
    --wooweight-mobile-btn-radius: 4px;
}

/* ========================================
   CONTENEUR PRINCIPAL
======================================== */
.wooweight-shop-cart {
    margin-top: 15px;
    padding: var(--wooweight-padding);
    background: var(--wooweight-bg);
    border-radius: var(--wooweight-radius);
    border: var(--wooweight-border-width) solid var(--wooweight-border);
    transition: all 0.3s ease;
}

.wooweight-shop-cart:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* ========================================
   LAYOUT 2 LIGNES (DÉFAUT)
======================================== */
.wooweight-shop-cart.wooweight-layout-2 .wooweight-weight-selector {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--wooweight-gap);
    margin-bottom: var(--wooweight-gap);
}

.wooweight-shop-cart.wooweight-layout-2 .wooweight-weight-input,
.wooweight-shop-cart.wooweight-layout-2 .wooweight-package-input {
    display: flex;
    flex-direction: column;
}

.wooweight-shop-cart.wooweight-layout-2 .wooweight-calculated-price-inline {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
}

/* Mode quantité (1 champ Qté + total aligné à droite) */
.wooweight-shop-cart.wooweight-layout-2.wooweight-qty-mode .wooweight-weight-selector {
    grid-template-columns: auto 1fr;
}

.wooweight-shop-cart.wooweight-layout-2.wooweight-qty-mode .wooweight-weight-input {
    min-width: 0;
}

.wooweight-shop-cart.wooweight-layout-2.wooweight-qty-mode .wooweight-calculated-price-inline {
    align-items: flex-end;
    justify-content: flex-end;
    text-align: right;
}

/*dev à variabiliser pour intégrer aux paramètres*/

/* Affichage smartphone */
@media screen and (max-width: 768px) {
    .wooweight-shop-cart.wooweight-layout-2 .wooweight-calculated-price-inline .wooweight-total-price {
        font-size: 24px !important; /* Ajustez selon vos besoins */
    }
}

/* Affichage très petits écrans (optionnel) */
@media screen and (max-width: 480px) {
    .wooweight-shop-cart.wooweight-layout-2 .wooweight-calculated-price-inline .wooweight-total-price {
        font-size: 24px !important; /* Encore plus petit si nécessaire */
    }
}


.wooweight-shop-cart.wooweight-layout-2 .wooweight-calculated-price-inline .wooweight-price-label {
    font-size: 11px;
    color: #666;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wooweight-shop-cart.wooweight-layout-2 .wooweight-calculated-price-inline .wooweight-total-price {
    font-size: 20px;
    font-weight: bold;
    color: var(--wooweight-price-color);
}

/* ========================================
   LAYOUT 3 LIGNES
======================================== */
.wooweight-shop-cart.wooweight-layout-3 .wooweight-weight-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--wooweight-gap);
    margin-bottom: var(--wooweight-gap);
}

.wooweight-shop-cart.wooweight-layout-3 .wooweight-weight-input,
.wooweight-shop-cart.wooweight-layout-3 .wooweight-package-input {
    display: flex;
    flex-direction: column;
}

.wooweight-shop-cart.wooweight-layout-3 .wooweight-calculated-price {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: #fff;
    border-radius: 4px;
    margin-bottom: var(--wooweight-gap);
    font-weight: 600;
    border: 1px solid var(--wooweight-border);
}

.wooweight-shop-cart.wooweight-layout-3 .wooweight-price-label {
    color: #666;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wooweight-shop-cart.wooweight-layout-3 .wooweight-total-price {
    color: var(--wooweight-price-color);
    font-size: 20px;
    font-weight: bold;
}

/* ========================================
   LABELS
======================================== */
.wooweight-shop-cart label {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--wooweight-label-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
}

/* ========================================
   CHAMPS INPUT
======================================== */
.wooweight-weight-field,
.wooweight-packages-field,
.wooweight-qty-field {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    text-align: center;
    transition: all 0.3s ease;
    background: #fff;
}

.wooweight-weight-field:focus,
.wooweight-packages-field:focus,
.wooweight-qty-field:focus {
    outline: none;
    border-color: var(--wooweight-btn-bg);
    box-shadow: 0 0 0 1px var(--wooweight-btn-bg);
}

.wooweight-weight-field:hover,
.wooweight-packages-field:hover,
.wooweight-qty-field:hover {
    border-color: #999;
}

/* Conteneur avec boutons +/- pour mobile */
.wooweight-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--wooweight-input-gap, 5px);
}

.wooweight-input-wrapper input {
    flex: 1;
}

/* Boutons +/- (masqués par défaut sur desktop) */
.wooweight-btn-minus,
.wooweight-btn-plus {
    display: none;
    width: var(--wooweight-mobile-btn-width, 36px);
    height: var(--wooweight-mobile-btn-height, 36px);
    border: var(--wooweight-mobile-btn-border-width, 1px) solid var(--wooweight-mobile-btn-border, #ddd);
    background: var(--wooweight-mobile-btn-bg, #fff);
    border-radius: var(--wooweight-mobile-btn-radius, 4px);
    cursor: pointer;
    font-size: var(--wooweight-mobile-btn-font, 18px);
    font-weight: bold;
    color: var(--wooweight-mobile-btn-text, #333);
    transition: all 0.2s ease;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
}

.wooweight-btn-minus:hover,
.wooweight-btn-plus:hover {
    background: #f0f0f0;
    border-color: #999;
}

.wooweight-btn-minus:active,
.wooweight-btn-plus:active {
    background: #e0e0e0;
    /*transform: scale(0.95);*/
}

/* ========================================
   BOUTON AJOUTER AU PANIER
======================================== */
.wooweight-add-to-cart {
    width: 100%;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 4px;
    background-color: var(--wooweight-btn-bg);
    color: var(--wooweight-btn-text);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.wooweight-add-to-cart:hover {
    background-color: var(--wooweight-btn-bg-hover);
    color: var(--wooweight-btn-text-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.wooweight-add-to-cart:active {
    transform: translateY(0);
}

/* État de chargement (spinner natif WooCommerce) */
.wooweight-add-to-cart.loading {
    opacity: 0.6;
    cursor: wait;
}

.wooweight-add-to-cart.loading::after {
    content: "";
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: wooweight-spin 0.8s linear infinite;
}

@keyframes wooweight-spin {
    0% {
        transform: translateY(-50%) rotate(0deg);
    }
    100% {
        transform: translateY(-50%) rotate(360deg);
    }
}

/* Masquer le bouton "Voir le panier" après ajout */
.wooweight-shop-cart .added_to_cart {
    display: none !important;
}

/* Forcer l'affichage du bouton même avec classe .added */
.wooweight-add-to-cart.added {
    display: block !important;
}

/* ========================================
   AFFICHAGE DANS LE MINI-CART
======================================== */
.wooweight-cart-details {
    font-size: 12px;
    line-height: 1.6;
    margin-top: 5px;
    color: #666;
}

.wooweight-weight-detail {
    display: block;
    color: #666;
    font-style: italic;
}

.wooweight-price-detail {
    display: block;
    color: #000;
    font-weight: 600;
    margin-top: 2px;
}

/* ========================================
   AFFICHAGE DANS LE PANIER STANDARD
======================================== */
.woocommerce-cart-form .wooweight-cart-details {
    margin-top: 10px;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 4px;
    font-size: 13px;
}

/* ========================================
   EMAILS ET COMMANDES
======================================== */
.wooweight-order-meta {
    margin-top: 10px;
    padding: 10px;
    background: #f9f9f9;
    border-left: 3px solid #2271b1;
    font-size: 12px;
}

.wooweight-order-meta div {
    margin-bottom: 5px;
}

.wooweight-order-meta strong {
    color: #333;
}

.wooweight-order-summary {
    margin-top: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-left: 4px solid #2271b1;
}

.wooweight-order-summary h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #2271b1;
}

/* ========================================
   RESPONSIVE - MOBILE
======================================== */
@media (max-width: 768px) {
    /* Afficher les boutons +/- sur mobile */
    .wooweight-btn-minus,
    .wooweight-btn-plus {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Masquer les spinners natifs sur mobile */
    .wooweight-weight-field::-webkit-inner-spin-button,
    .wooweight-weight-field::-webkit-outer-spin-button,
    .wooweight-packages-field::-webkit-inner-spin-button,
    .wooweight-packages-field::-webkit-outer-spin-button,
    .wooweight-qty-field::-webkit-inner-spin-button,
    .wooweight-qty-field::-webkit-outer-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }
    
    .wooweight-weight-field,
    .wooweight-packages-field,
    .wooweight-qty-field {
        -moz-appearance: textfield;
    }
    
    .wooweight-shop-cart.wooweight-layout-2 .wooweight-weight-selector,
    .wooweight-shop-cart.wooweight-layout-3 .wooweight-weight-selector {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .wooweight-shop-cart.wooweight-layout-2 .wooweight-calculated-price-inline {
        align-items: flex-start;
        margin-top: 10px;
    }
    
    .wooweight-shop-cart.wooweight-layout-3 .wooweight-calculated-price {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .wooweight-add-to-cart {
        padding: 14px 20px;
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .wooweight-shop-cart {
        padding: 12px;
    }
    
    .wooweight-weight-field,
    .wooweight-packages-field,
    .wooweight-qty-field {
        font-size: 14px;
        padding: 8px 10px;
    }
}

/* ========================================
   ANIMATIONS
======================================== */
@keyframes wooweight-fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wooweight-shop-cart {
    animation: wooweight-fadeIn 0.4s ease-out;
}

/* ========================================
   COMPATIBILITÉ THÈMES
======================================== */

/* OceanWP */
.oceanwp-theme .wooweight-shop-cart {
    margin-top: -10px;
}

/* Storefront */
.storefront .wooweight-add-to-cart {
    background-color: #96588a;
}

.storefront .wooweight-add-to-cart:hover {
    background-color: #843371;
}

/* Astra */
.ast-theme .wooweight-shop-cart {
    border-radius: 3px;
}

/* GeneratePress */
.generate-theme .wooweight-calculated-price {
    font-family: inherit;
}

/* ========================================
   ACCESSIBILITÉ
======================================== */
.wooweight-weight-field:focus-visible,
.wooweight-packages-field:focus-visible,
.wooweight-qty-field:focus-visible {
    outline: 2px solid var(--wooweight-btn-bg);
    outline-offset: 2px;
}

.wooweight-add-to-cart:focus-visible {
    outline: 2px solid var(--wooweight-btn-bg);
    outline-offset: 2px;
}

/* Mode contraste élevé */
@media (prefers-contrast: high) {
    .wooweight-shop-cart {
        border: 2px solid #000;
    }
    
    .wooweight-weight-field,
    .wooweight-packages-field,
    .wooweight-qty-field {
        border: 2px solid #000;
    }
}

/* Mode sombre (si supporté par le thème) */
@media (prefers-color-scheme: dark) {
    .wooweight-shop-cart {
        background: #1e1e1e;
        border-color: #3a3a3a;
    }
    
    .wooweight-shop-cart.wooweight-layout-3 .wooweight-calculated-price {
        background: #2a2a2a;
        border-color: #3a3a3a;
    }
    
    .wooweight-weight-field,
    .wooweight-packages-field,
    .wooweight-qty-field {
        background: #2a2a2a;
        border-color: #3a3a3a;
        color: #fff;
    }
    
    .wooweight-shop-cart label {
        color: #aaa;
    }
    
    .wooweight-total-price {
        color: #fff !important;
    }
}

/* ========================================
   MESSAGES D'ERREUR
======================================== */
.wooweight-error {
    padding: 10px 15px;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin-bottom: 10px;
    font-size: 14px;
}

.wooweight-success {
    padding: 10px 15px;
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    margin-bottom: 10px;
    font-size: 14px;
}

/* ========================================
   ADMIN - ONGLET PRODUIT
======================================== */
#woocommerce-product-data .wooweight-settings-group {
    padding: 12px;
}

#woocommerce-product-data .wooweight-settings-group p {
    margin-bottom: 12px;
}

/* ========================================
   PRINT (FACTURES)
======================================== */
@media print {
    .wooweight-order-meta,
    .wooweight-order-summary {
        border: 1px solid #000;
        page-break-inside: avoid;
    }
}

/* ========================================
   SUFFIXE "/kg" POUR PRIX
======================================== */
.wooweight-unit {
    font-size: 0.85em;
    color: #666;
    margin-left: 2px;
}