/* ============================================================
   CCM Sticky Cart
   Barra fija inferior con thumb + nombre + precio + ATC.
   Aparece cuando el ATC original sale del viewport hacia arriba.
   ============================================================ */

.ccmg-sticky-cart {
    --ccmg-sc-bg:           #ffffff;
    --ccmg-sc-text:         #121212;
    --ccmg-sc-muted:        rgba(0, 0, 0, 0.6);
    --ccmg-sc-border:       rgba(0, 0, 0, 0.08);
    --ccmg-sc-accent:       #e60000;
    --ccmg-sc-accent-dark:  #b40000;
    --ccmg-sc-shadow:       0 -2px 12px rgba(0, 0, 0, 0.08);
    --ccmg-sc-radius:       6px;
    --ccmg-sc-thumb-size:   44px;
    --ccmg-sc-height:       64px;
    --ccmg-sc-max-width:    1280px;
    --ccmg-sc-z:            999;
    --ccmg-sc-transition:   220ms ease;

    position:       fixed;
    inset:          auto 0 0 0;
    z-index:        var(--ccmg-sc-z);
    background:     var(--ccmg-sc-bg);
    border-top:     1px solid var(--ccmg-sc-border);
    box-shadow:     var(--ccmg-sc-shadow);
    transform:      translateY(100%);
    visibility:     hidden;
    opacity:        0;
    transition:     transform var(--ccmg-sc-transition),
                    opacity var(--ccmg-sc-transition),
                    visibility 0s linear var(--ccmg-sc-transition);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    font-family:    "Founder grotesk CCM", "Founders Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif;
    color:          var(--ccmg-sc-text);
    isolation:      isolate;
}

.ccmg-sticky-cart.is-visible {
    transform:  translateY(0);
    visibility: visible;
    opacity:    1;
    transition: transform var(--ccmg-sc-transition),
                opacity var(--ccmg-sc-transition),
                visibility 0s linear 0s;
}

.ccmg-sticky-cart :where(*, *::before, *::after) {
    box-sizing: border-box;
}

.ccmg-sticky-cart__inner {
    display:     flex;
    align-items: center;
    gap:         12px;
    width:       100%;
    max-width:   var(--ccmg-sc-max-width);
    height:      var(--ccmg-sc-height);
    margin:      0 auto;
    padding:     8px 16px;
}

.ccmg-sticky-cart__media {
    flex:          0 0 auto;
    width:         var(--ccmg-sc-thumb-size);
    height:        var(--ccmg-sc-thumb-size);
    border-radius: 4px;
    overflow:      hidden;
    background:    #f5f5f5;
    display:       block;
}

.ccmg-sticky-cart__media img,
.ccmg-sticky-cart__img {
    width:      100%;
    height:     100%;
    object-fit: cover;
    display:    block;
}

.ccmg-sticky-cart__info {
    flex:           1 1 auto;
    min-width:      0;
    display:        flex;
    flex-direction: column;
    gap:            2px;
}

.ccmg-sticky-cart__title {
    margin:        0;
    overflow:      hidden;
    text-overflow: ellipsis;
    white-space:   nowrap;
    font-size:     14px;
    font-weight:   500;
    line-height:   1.2;
    color:         var(--ccmg-sc-text);
}

.ccmg-sticky-cart__price {
    font-size:   14px;
    font-weight: 600;
    line-height: 1.2;
    color:       var(--ccmg-sc-text);
    white-space: nowrap;
    overflow:    hidden;
    text-overflow: ellipsis;
}

.ccmg-sticky-cart__price del {
    color:           var(--ccmg-sc-muted);
    font-weight:     400;
    margin-right:    6px;
    text-decoration: line-through;
}

.ccmg-sticky-cart__price ins {
    text-decoration: none;
    background:      transparent;
    color:           inherit;
}

.ccmg-sticky-cart__price .woocommerce-Price-amount {
    font-weight: inherit;
}

.ccmg-sticky-cart__atc {
    flex:            0 0 auto;
    display:         inline-flex;
    align-items:     center;
    justify-content: center;
    min-width:       140px;
    height:          44px;
    padding:         0 18px;
    border:          0;
    border-radius:   var(--ccmg-sc-radius);
    background:      var(--ccmg-sc-accent);
    color:           #ffffff;
    font-family:     inherit;
    font-size:       15px;
    font-weight:     500;
    line-height:     1;
    cursor:          pointer;
    text-decoration: none;
    white-space:     nowrap;
    transition:      background-color var(--ccmg-sc-transition),
                     opacity var(--ccmg-sc-transition);
}

.ccmg-sticky-cart__atc:hover:not(:disabled) {
    background: var(--ccmg-sc-accent-dark);
}

.ccmg-sticky-cart__atc:focus-visible {
    outline:        2px solid var(--ccmg-sc-accent);
    outline-offset: 2px;
}

.ccmg-sticky-cart__atc[aria-busy="true"],
.ccmg-sticky-cart__atc.is-loading {
    opacity: 0.7;
    cursor:  progress;
}

.ccmg-sticky-cart__atc.is-added {
    background: #2e7d32;
}

/* Reserva espacio al final del body cuando el bar es visible
   para que el contenido no quede oculto al hacer scroll al final. */
body.ccmg-has-sticky-cart {
    padding-bottom: calc(var(--ccmg-sc-height, 64px) + env(safe-area-inset-bottom, 0px));
}

/* Desplazar botones flotantes (WhatsApp + Side Cart) cuando el sticky cart es visible.
   — .wa__btn_popup  → contenedor fixed del plugin "WhatsApp for WordPress" (bottom: 30px; z-index: 999999999).
   — .xoo-wsc-basket → botón fixed del plugin "Side Cart Premium" (margin: 10px; z-index: 9999997). */
.wa__btn_popup,
.xoo-wsc-basket {
    transition: transform var(--ccmg-sc-transition, 220ms ease);
}

body.ccmg-has-sticky-cart .wa__btn_popup,
body.ccmg-has-sticky-cart .xoo-wsc-basket {
    transform: translateY(calc(-1 * (var(--ccmg-sc-height, 64px) + env(safe-area-inset-bottom, 0px))));
}

@media (max-width: 480px) {
    .ccmg-sticky-cart__inner {
        gap:     10px;
        padding: 8px 12px;
    }
    .ccmg-sticky-cart__atc {
        min-width: 110px;
        padding:   0 12px;
        font-size: 14px;
    }
    .ccmg-sticky-cart__price {
        font-size: 13px;
    }
    .ccmg-sticky-cart__title {
        font-size: 13px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ccmg-sticky-cart {
        transition: none;
    }
}
