/**
 * Styles pour le widget Akibat WooCommerce Products Grid
 * Version optimisée avec boutons personnalisables
 */

/* Grille de produits */
.akibat-woo-grid {
    display: grid;
    grid-gap: 20px;
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Colonnes de la grille */
.akibat-woo-grid.columns-1 {
    grid-template-columns: repeat(1, 1fr);
}

.akibat-woo-grid.columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

.akibat-woo-grid.columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

.akibat-woo-grid.columns-4 {
    grid-template-columns: repeat(4, 1fr);
}

.akibat-woo-grid.columns-5 {
    grid-template-columns: repeat(5, 1fr);
}

.akibat-woo-grid.columns-6 {
    grid-template-columns: repeat(6, 1fr);
}

/* Styles spéciaux pour grille de promotions uniquement */
.akibat-woo-grid--sale-only {
    position: relative;
}

/* Responsive Design */
@media (max-width: 1200px) {

    .akibat-woo-grid.columns-5,
    .akibat-woo-grid.columns-6 {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1024px) {

    .akibat-woo-grid.columns-4,
    .akibat-woo-grid.columns-5,
    .akibat-woo-grid.columns-6 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {

    .akibat-woo-grid.columns-1,
    .akibat-woo-grid.columns-2,
    .akibat-woo-grid.columns-3,
    .akibat-woo-grid.columns-4,
    .akibat-woo-grid.columns-5,
    .akibat-woo-grid.columns-6 {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Disposition verticale pour le formulaire d'ajout au panier */
    .akibat-woo-cart-form {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    .akibat-woo-add-to-cart {
        max-width: none;
        width: 100%;
    }
}

@media (max-width: 500px) {
    /* Styles pour le bouton panier en mobile */
    .akibat-woo-add-to-cart {
        font-size: 0 !important;
        padding: 0 !important;
        width: 36px;
        min-width: 36px;
        height: 36px;
        position: relative;
        max-width: 36px;
    }

    .akibat-woo-add-to-cart::before {
        content: "🛒";
        font-size: 18px;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    /* Ajuster le loading spinner en mobile */
    .akibat-woo-add-to-cart.loading::after {
        width: 14px;
        height: 14px;
    }

    /* Réorganisation du formulaire en ligne */
    .akibat-woo-cart-form {
        flex-direction: row;
        justify-content: center;
        gap: 5px;
    }

    /* Ajustement du conteneur de quantité */
    .akibat-woo-quantity {
        flex: 0 0 auto;
    }
}

@media (max-width: 480px) {
    .akibat-woo-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        grid-gap: 10px;
    }

    .akibat-woo-product {
        padding: 10px !important;
    }

    /* Boutons de quantité sur mobile */
    .akibat-woo-quantity-buttons {
        width: 18px !important;
        height: 32px !important;
    }

    .akibat-woo-quantity-with-buttons input.qty {
        width: 45px !important;
        height: 32px !important;
        font-size: 13px;
    }

    .akibat-woo-quantity-up,
    .akibat-woo-quantity-down {
        font-size: 11px;
    }
}

/* Produit individuel */
.akibat-woo-product {
    border: 1px solid #eee;
    padding: 15px;
    text-align: center;
    transition: all 0.3s ease;
    background-color: #fff;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
    position: relative;
}

.akibat-woo-product:hover {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* Styles spéciaux pour les produits en promotion */
.akibat-woo-product--on-sale {
    position: relative;
}

/* Image du produit */
.akibat-woo-product-image {
    margin-bottom: 15px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.akibat-woo-product-image a {
    display: block;
    position: relative;
}

.akibat-woo-product-image img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
    max-width: 100%;
}

.akibat-woo-product:hover .akibat-woo-product-image img {
    transform: scale(1.05);
}

/* Badges produit */
.akibat-woo-badge {
    position: absolute;
    padding: 5px 8px;
    font-size: 12px;
    font-weight: bold;
    border-radius: 3px;
    z-index: 10;
    text-transform: uppercase;
    text-align: center;
    line-height: 1.2;
    min-width: 40px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

/* Positions des badges */
.akibat-woo-badge--top-left {
    top: 10px;
    left: 10px;
}

.akibat-woo-badge--top-right {
    top: 10px;
    right: 10px;
}

.akibat-woo-badge--bottom-left {
    bottom: 10px;
    left: 10px;
}

.akibat-woo-badge--bottom-right {
    bottom: 10px;
    right: 10px;
}

/* Badge de promotion */
.akibat-woo-sale-badge {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
}

.akibat-woo-sale-badge small {
    display: block;
    font-size: 9px;
    margin-top: 2px;
    opacity: 0.9;
}

/* Badge rupture de stock */
.akibat-woo-out-of-stock-badge {
    background-color: #95a5a6;
    color: white;
}

/* Empilage des badges */
.akibat-woo-badge--top-right+.akibat-woo-out-of-stock-badge.akibat-woo-badge--top-right {
    top: 50px;
}

.akibat-woo-badge--top-left+.akibat-woo-out-of-stock-badge.akibat-woo-badge--top-left {
    top: 50px;
}

.akibat-woo-badge--bottom-right+.akibat-woo-out-of-stock-badge.akibat-woo-badge--bottom-right {
    bottom: 50px;
}

.akibat-woo-badge--bottom-left+.akibat-woo-out-of-stock-badge.akibat-woo-badge--bottom-left {
    bottom: 50px;
}

/* Titre du produit */
.akibat-woo-product-title {
    margin: 0 0 10px;
    font-size: 16px;
    line-height: 1.4;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.akibat-woo-product-title a {
    color: #333;
    text-decoration: none;
    display: block;
    word-wrap: break-word;
    hyphens: auto;
    transition: color 0.3s ease;
}

.akibat-woo-product-title a:hover {
    color: #c0392b;
}

/* Extrait du produit */
.akibat-woo-product-excerpt {
    margin: 0 0 15px;
    font-size: 14px;
    color: #666;
    line-height: 1.4;
    text-align: left;
}

/* Prix du produit - Styles de base personnalisables */
.akibat-woo-product-price {
    margin: 0 0 15px;
    font-weight: 600;
    font-size: 18px;
    flex-shrink: 0;
    /* Styles structurels de base - couleur gérée par Elementor */
    display: block;
    text-align: center;
}

.akibat-woo-product-price .price {
    display: block;
}

/* Styles pour le prix personnalisé avec barré */
.akibat-woo-price-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Prix original (barré) - styles améliorés */
.akibat-woo-original-price,
.akibat-woo-product-price del {
    font-weight: normal;
    font-size: 0.85em;
    text-decoration: line-through;
    opacity: 0.7;
    color: #999;
    position: relative;
}

.akibat-woo-original-price::after,
.akibat-woo-product-price del::after {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 1px;
    background: currentColor;
    transform: rotate(-8deg);
}

/* Prix de vente - styles améliorés */
.akibat-woo-sale-price,
.akibat-woo-product-price ins {
    font-weight: bold;
    font-size: 1.1em;
    text-decoration: none;
    color: #e74c3c;
}

/* Styles WooCommerce - structure uniquement pour permettre la personnalisation */
.akibat-woo-product-price del {
    font-weight: normal;
    font-size: 0.85em;
    margin-right: 0 !important;
    text-decoration: line-through;
}

.akibat-woo-product-price ins {
    text-decoration: none;
    font-weight: bold;
}

.akibat-woo-product-price .woocommerce-Price-amount {
    font-weight: inherit;
}

/* Styles pour l'affichage des montants de prix avec arrière-plan */
.woocommerce-Price-amount.amount {
    display: inline-block;
}

/* Section Ajouter au panier */
.akibat-woo-product-add-to-cart {
    margin-top: auto;
    padding-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.akibat-woo-cart-form {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

/* Sélecteur de quantité */
.akibat-woo-quantity {
    display: flex;
    align-items: center;
    position: relative;
}

.akibat-woo-quantity input.qty {
    width: 50px;
    height: 36px;
    padding: 0 5px;
    background-color: #ffe6c3;
    color: #310708;
    border: 1px solid #310708;
    border-radius: 3px;
    text-align: center;
    font-size: 14px;
    -moz-appearance: textfield;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.akibat-woo-quantity input.qty::-webkit-outer-spin-button,
.akibat-woo-quantity input.qty::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.akibat-woo-quantity input.qty:focus {
    outline: none;
    color: #a03800;
    border-color: #a03800;
    box-shadow: 0 0 0 2px rgba(160, 56, 0, 0.2);
}

/* Boutons quantité personnalisés - VERSION FINALE PROPRE */
.akibat-woo-quantity-with-buttons {
    position: relative;
    display: flex;
    align-items: center;
}

.akibat-woo-quantity-with-buttons input.qty {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    width: 50px;
    flex-shrink: 0;
}

.akibat-woo-quantity-buttons {
    display: flex;
    flex-direction: column;
    width: 20px;
    height: 36px;
    border: 1px solid #ddd;
    border-left: none;
    border-radius: 0 3px 3px 0;
    background: #f9f9f9;
}

.akibat-woo-quantity-up,
.akibat-woo-quantity-down {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    border: none;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    color: #666;
    user-select: none;
    transition: all 0.2s ease;
    line-height: 1;
    margin: 0;
    padding: 0;
    min-height: 18px;
}

.akibat-woo-quantity-up:hover,
.akibat-woo-quantity-down:hover {
    background: #eee;
    color: #333;
}

.akibat-woo-quantity-up {
    border-bottom: 1px solid #ddd;
    border-radius: 0 3px 0 0;
}

.akibat-woo-quantity-down {
    border-radius: 0 0 3px 0;
}

/* Bouton Ajouter au panier - Styles de base sans couleurs pour permettre la personnalisation Elementor */
.akibat-woo-add-to-cart {
    /* Styles structurels uniquement - les couleurs sont gérées par Elementor */
    border: none;
    padding: 10px 15px;
    text-align: center;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    font-weight: 600;
    min-height: 36px;
    flex: 1;
    max-width: 180px;
    line-height: 1.2;
    word-wrap: break-word;
    hyphens: auto;
    outline: none;
    box-sizing: border-box;
}

.akibat-woo-add-to-cart:hover {
    transform: translateY(-1px);
    text-decoration: none;
}

.akibat-woo-add-to-cart:active {
    transform: translateY(0);
}

.akibat-woo-add-to-cart:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
    opacity: 0.8;
}

/* États du bouton - animations et comportements */
.akibat-woo-add-to-cart.loading {
    opacity: 0.7;
    cursor: not-allowed;
    position: relative;
}

.akibat-woo-add-to-cart.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    transform: translate(-50%, -50%);
}

.akibat-woo-add-to-cart.added {
    animation: added-success 0.6s ease;
}

@keyframes spin {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }

    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

@keyframes added-success {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

/* Messages d'erreur AJAX */
.akibat-woo-ajax-error {
    color: #e74c3c;
    font-size: 12px;
    margin-top: 5px;
    text-align: center;
    background: rgba(231, 76, 60, 0.1);
    padding: 5px;
    border-radius: 3px;
    border: 1px solid rgba(231, 76, 60, 0.2);
}

/* Message de notice */
.akibat-woo-grid-notice {
    text-align: center;
    padding: 20px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    color: #6c757d;
}

.akibat-woo-grid-notice p {
    margin: 0;
    font-size: 16px;
}

/* Notice spéciale pour les promotions */
.akibat-woo-grid-notice--promotion {
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.05) 0%, rgba(231, 76, 60, 0.1) 100%);
    border-color: rgba(231, 76, 60, 0.2);
    color: #c0392b;
}

/* Styles pour les produits variables */
.akibat-woo-product .variations {
    margin-bottom: 15px;
}

.akibat-woo-product .variations select {
    width: 100%;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 3px;
    margin-bottom: 5px;
    transition: border-color 0.3s ease;
}

.akibat-woo-product .variations select:focus {
    outline: none;
    border-color: #c0392b;
}

/* Amélioration de l'accessibilité */
.akibat-woo-add-to-cart:focus,
.akibat-woo-quantity input.qty:focus {
    outline: 2px solid #c0392b;
    outline-offset: 2px;
}

/* Support RTL */
.rtl .akibat-woo-badge--top-right {
    right: auto;
    left: 10px;
}

.rtl .akibat-woo-badge--top-left {
    left: auto;
    right: 10px;
}

.rtl .akibat-woo-badge--bottom-right {
    right: auto;
    left: 10px;
}

.rtl .akibat-woo-badge--bottom-left {
    left: auto;
    right: 10px;
}

@media (min-width: 443px) {
    .akibat-woo-product-price del {
        margin-right: 5px !important;
    }
}

/* Prix adaptés pour très petits écrans */
@media (min-width: 360px) and (max-width: 411px) {
    .akibat-woo-product-price {
        font-size: 14px;
    }
    
    .akibat-woo-original-price,
    .akibat-woo-product-price del {
        font-size: 0.82em;
    }
    
    .akibat-woo-sale-price,
    .akibat-woo-product-price ins {
        font-size: 1em;
    }
    
    .akibat-woo-price-wrapper {
        gap: 4px;
    }
}

/* Styles pour l'impression */
@media print {

    .akibat-woo-product-add-to-cart,
    .akibat-woo-badge {
        display: none;
    }

    .akibat-woo-product {
        break-inside: avoid;
        border: 1px solid #ddd !important;
        background: white !important;
    }
}

/* Mode sombre (si supporté par le thème) */
/*
@media (prefers-color-scheme: dark) {
    .akibat-woo-product {
        background-color: #2c3e50;
        border-color: #34495e;
        color: #ecf0f1;
    }

    .akibat-woo-product-title a {
        color: #ecf0f1;
    }

    .akibat-woo-product-title a:hover {
        color: #3498db;
    }

    .akibat-woo-quantity input.qty {
        background-color: #34495e;
        border-color: #4a5568;
        color: #ecf0f1;
    }

    .akibat-woo-grid-notice {
        background-color: #34495e;
        border-color: #4a5568;
        color: #bdc3c7;
    }
}
*/