/**
 * Shipping Progress Bar - Frontend Styles
 * Version: 1.0.0
 */

/* Wrapper général - Layout vertical par défaut (produit) */
.spb-wrapper {
    position: relative;
    margin: 15px 0; /* Aligné à gauche sur desktop */
    width: 100%;
    max-width: 350px; /* Largeur par défaut pour pages produits */
    text-align: left;
    display: block;
}

/* Container de la barre */
.spb-bar-container {
    width: 100%;
}

/* Full width ET centré pour panier et checkout */
.woocommerce-cart .spb-wrapper,
.woocommerce-checkout .spb-wrapper,
.spb-cart-injected .spb-wrapper,
.spb-checkout-injected .spb-wrapper {
    max-width: 100% !important; /* Full width sur panier/checkout */
    margin-left: auto;
    margin-right: auto;
}

/* Layout horizontal UNIQUEMENT pour panier et checkout (PAS pour shortcode) */
.woocommerce-cart .spb-wrapper:not(.spb-shortcode),
.woocommerce-checkout .spb-wrapper:not(.spb-shortcode),
.spb-cart-injected .spb-wrapper:not(.spb-shortcode),
.spb-checkout-injected .spb-wrapper:not(.spb-shortcode) {
    display: flex !important;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.woocommerce-cart .spb-bar-container:not(.spb-shortcode .spb-bar-container),
.woocommerce-checkout .spb-bar-container:not(.spb-shortcode .spb-bar-container),
.spb-cart-injected .spb-bar-container:not(.spb-shortcode .spb-bar-container),
.spb-checkout-injected .spb-bar-container:not(.spb-shortcode .spb-bar-container) {
    flex: 1;
    min-width: 250px;
}

.woocommerce-cart .spb-wrapper:not(.spb-shortcode) .spb-cta-button,
.woocommerce-cart .spb-wrapper:not(.spb-shortcode) .spb-cta-link,
.woocommerce-checkout .spb-wrapper:not(.spb-shortcode) .spb-cta-button,
.woocommerce-checkout .spb-wrapper:not(.spb-shortcode) .spb-cta-link,
.spb-cart-injected .spb-wrapper:not(.spb-shortcode) .spb-cta-button,
.spb-cart-injected .spb-wrapper:not(.spb-shortcode) .spb-cta-link,
.spb-checkout-injected .spb-wrapper:not(.spb-shortcode) .spb-cta-button,
.spb-checkout-injected .spb-wrapper:not(.spb-shortcode) .spb-cta-link {
    margin: 0 !important;
    flex-shrink: 0;
}

/* ========================================
   ESPACEMENT APRÈS BOUTON ADD TO CART
   Sélecteurs multiples pour compatibilité
======================================== */

/* WooCommerce standard */
.woocommerce div.product form.cart .spb-wrapper,
.product .spb-wrapper,
.single-product .spb-wrapper {
    margin-top: 40px !important;
    margin-bottom: 20px !important;
    display: block !important;
    clear: both !important;
}

/* Divi spécifique - Marges augmentées */
.et_pb_woo_custom_add_to_cart .spb-wrapper,
.et-db #et-boc .et-l .spb-wrapper,
.et_pb_module .spb-wrapper,
#et-main-area .spb-wrapper,
.et_builder_outer_content .spb-wrapper,
div.product.et_pb_woo_custom_add_to_cart form.cart + .spb-wrapper,
.et_pb_woo_custom_add_to_cart button.single_add_to_cart_button ~ .spb-wrapper {
    margin-top: 85px !important;
    margin-bottom: 20px !important;
    display: block !important;
    clear: both !important;
}

/* Elementor spécifique - Marges moyennes */
.elementor-widget-woocommerce-product-add-to-cart .spb-wrapper,
.elementor-add-to-cart .spb-wrapper,
.elementor .spb-wrapper,
.elementor-element .spb-wrapper,
.elementor-widget-container .spb-wrapper {
    margin-top: 70px !important;
    margin-bottom: 20px !important;
    display: block !important;
    clear: both !important;
}

/* Sélecteur universel en dernier recours */
.product form.cart > .spb-wrapper,
button.single_add_to_cart_button + .spb-wrapper,
.single_add_to_cart_button ~ .spb-wrapper {
    margin-top: 40px !important;
    margin-bottom: 20px !important;
}

/* Force avec sélecteur adjacent (frère) */
.cart .spb-wrapper,
form.cart .spb-wrapper {
    margin-top: 40px !important;
}

/* Espacement sur panier/checkout */
.woocommerce-cart .spb-wrapper,
.woocommerce-checkout .spb-wrapper {
    margin: 20px auto;
}

/* ========================================
   BARRE DE PROGRESSION
======================================== */

/* Barre de fond */
.spb-bar {
    height: 30px;
    background-color: #e0e0e0;
    border-radius: 30px;
    overflow: visible !important;
    position: relative;
}

/* Barre remplie */
.spb-bar-fill {
    height: 100%;
    width: 0%;
    border-radius: 30px;
    transition: width 0.4s ease, background-color 0.4s ease;
    position: absolute;
    top: 0;
    left: 0;
}

/* Texte au-dessus de la barre */
.spb-bar-text-above {
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    line-height: 1.4;
}

/* Texte inside */
.spb-text-inside {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5), 0 0 10px rgba(0,0,0,0.3);
    z-index: 100;
    pointer-events: none;
    max-width: calc(100% - 20px);
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1;
}

/* ========================================
   CALL-TO-ACTION
======================================== */

/* CTA bouton */
.spb-cta-button {
    display: inline-block;
    margin-top: 12px;
    height: 36px;
    line-height: 36px;
    padding: 0 20px;
    font-size: 14px;
    font-weight: 600;
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 30px;
    background-color: #27ae60;
    text-align: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    white-space: nowrap;
}

.spb-cta-button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    color: #fff !important;
}

/* Lien CTA */
.spb-cta-link {
    display: inline-block;
    margin-top: 12px;
    font-size: 14px;
    color: inherit;
    background: none !important;
    text-decoration: underline !important;
    padding: 0;
    line-height: normal;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

.spb-cta-link:hover {
    opacity: 0.8;
}

/* ========================================
   PANIER & CHECKOUT
======================================== */

/* Conteneurs injectés via JS - PAS de fond gris */
.spb-cart-injected,
.spb-checkout-injected {
    background: transparent;
    padding: 0;
    margin: 0 !important;
}

/* Meilleure visibilité panier */
.woocommerce-cart-form + .cart-collaterals .spb-wrapper {
    margin: 20px 0;
}

/* Meilleure visibilité checkout */
#order_review .spb-wrapper {
    margin: 15px 0;
}

/* Wrapper alternatif pour hooks de secours */
.spb-cart-wrapper,
.spb-checkout-wrapper {
    margin: 20px 0 !important;
}

/* ========================================
   RESPONSIVE
======================================== */

@media (max-width: 768px) {
    .spb-wrapper { 
        width: 100%;
        max-width: 100%;
        margin-left: auto !important; /* Centré sur mobile */
        margin-right: auto !important;
    }
    
    .product .spb-wrapper,
    .single-product .spb-wrapper {
        margin-top: 30px !important;
    }
    
    /* Sur mobile, CTA centré en dessous pour panier/checkout */
    .woocommerce-cart .spb-wrapper,
    .woocommerce-checkout .spb-wrapper,
    .spb-cart-injected .spb-wrapper,
    .spb-checkout-injected .spb-wrapper {
        flex-direction: column;
        align-items: stretch;
    }
    
    .woocommerce-cart .spb-bar-container,
    .woocommerce-checkout .spb-bar-container,
    .spb-cart-injected .spb-bar-container,
    .spb-checkout-injected .spb-bar-container {
        min-width: 100%;
    }
    
    .woocommerce-cart .spb-cta-button,
    .woocommerce-cart .spb-cta-link,
    .woocommerce-checkout .spb-cta-button,
    .woocommerce-checkout .spb-cta-link,
    .spb-cart-injected .spb-cta-button,
    .spb-cart-injected .spb-cta-link,
    .spb-checkout-injected .spb-cta-button,
    .spb-checkout-injected .spb-cta-link {
        width: 100%;
        text-align: center;
        margin-top: 12px !important;
    }
    
    .spb-bar-text-above {
        font-size: 13px;
    }
    
    .spb-text-inside { 
        font-size: 12px;
        max-width: calc(100% - 16px);
    }
    
    .spb-cta-button, 
    .spb-cta-link { 
        font-size: 13px;
    }
    
    .spb-cta-button {
        padding: 0 16px;
        height: 32px;
        line-height: 32px;
    }
}

@media (max-width: 480px) {
    .product .spb-wrapper,
    .single-product .spb-wrapper {
        margin-top: 25px !important;
    }
    
    .spb-bar {
        height: 26px;
    }
    
    .spb-bar-text-above {
        font-size: 12px;
    }
    
    .spb-text-inside { 
        font-size: 11px;
        max-width: calc(100% - 12px);
    }
    
    .spb-cta-button, 
    .spb-cta-link { 
        font-size: 12px;
    }
    
    .spb-cta-button {
        padding: 0 14px;
        height: 30px;
        line-height: 30px;
    }
}

/* ========================================
   AUTRES
======================================== */

/* RTL Support */
.rtl .spb-text-inside {
    left: auto;
    right: 50%;
    transform: translate(50%, -50%);
}

/* Print - masquer */
@media print {
    .spb-wrapper {
        display: none;
    }
}