/* =====================================================================
   CARRITO FLOTANTE · única fuente para los tres pilares
   =====================================================================
   Antes vivía en dos hojas a la vez y, en la de la comunidad, en tres
   bloques dispersos que se pisaban con !important: uno forzaba borde de
   color en cada item y otro pintaba el botón de verde. Resultado: el mismo
   componente se veía distinto en cada pilar.

   Ahora está aquí y solo aquí. La cargan base-store.html y
   base-comunidad.html, así que el carrito es idéntico en ambos.

   Las reglas de apilamiento y geometría van con el id #desktop-cart-widget y
   !important a propósito: la capa antigua de store_home.css usaba esa misma
   especificidad, y en la página conviven otros flotantes con z-index máximo
   (#wa-support llega a 2147483647, .fancybox__container a 2147483646). Si el
   carrito no gana, el velo oscuro queda por encima del panel y no se puede
   pulsar nada.

   El acento sale de --storefront-accent, que la comunidad fija por rubro en
   el <body>, así que el carrito acompaña al color del rubro sin tocar nada.
   ===================================================================== */

.desktop-cart-widget,
#desktop-cart-widget {
    --cart-accent: var(--storefront-accent, #5b43d6);
    --cart-text: #172033;
    --cart-muted: #6f7890;
    --cart-line: #e8ebf2;

    position: fixed !important;
    inset: 0 !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;

    /* Por encima de todo flotante de la página. */
    z-index: 2147483647 !important;

    /* La capa antigua ponía isolation: isolate, que atrapa los position:fixed
       de dentro. Ya nos escondió el resumen de compra bajo el header. */
    isolation: auto !important;

    opacity: 1 !important;
    pointer-events: none;
    visibility: hidden;
}

/* Tres llaves porque cada base abre el panel a su manera: la comunidad
   alterna .active y las dos escriben aria-hidden. */
#desktop-cart-widget.active,
#desktop-cart-widget.is-open,
#desktop-cart-widget[aria-hidden="false"],
.desktop-cart-widget.active,
.desktop-cart-widget.is-open,
.desktop-cart-widget[aria-hidden="false"] {
    visibility: visible !important;
    pointer-events: auto !important;
}

#desktop-cart-widget .desktop-cart-overlay,
.desktop-cart-overlay {
    position: absolute !important;
    inset: 0 !important;
    /* Explicito: el panel va encima pase lo que pase. */
    z-index: 1 !important;
    background: rgba(15, 23, 42, .48);
    opacity: 0;
    transition: opacity .42s cubic-bezier(.32, .72, 0, 1);
}

#desktop-cart-widget.active .desktop-cart-overlay,
#desktop-cart-widget.is-open .desktop-cart-overlay,
#desktop-cart-widget[aria-hidden="false"] .desktop-cart-overlay,
.desktop-cart-widget.active .desktop-cart-overlay,
.desktop-cart-widget.is-open .desktop-cart-overlay,
.desktop-cart-widget[aria-hidden="false"] .desktop-cart-overlay {
    opacity: 1;
}

#desktop-cart-widget .desktop-cart-panel,
.desktop-cart-panel {
    position: absolute !important;
    right: 0 !important;
    left: auto !important;
    top: 0 !important;
    bottom: 0 !important;
    width: min(430px, 94vw) !important;
    max-width: 100vw;
    /* Siempre por encima del velo. */
    z-index: 2 !important;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    transform: translateX(100%);
    /* Curva de salida suave: arranca rapido y frena al final, en vez del
       tiron de `ease`. */
    transition: transform .42s cubic-bezier(.32, .72, 0, 1) !important;
    will-change: transform;
    backface-visibility: hidden;
    outline: 0;
    box-shadow: -20px 0 45px rgba(15, 23, 42, .12);
    /* El panel nunca debe generar scroll horizontal. */
    overflow-x: hidden;
}

#desktop-cart-widget.active .desktop-cart-panel,
#desktop-cart-widget.is-open .desktop-cart-panel,
#desktop-cart-widget[aria-hidden="false"] .desktop-cart-panel,
.desktop-cart-widget.active .desktop-cart-panel,
.desktop-cart-widget.is-open .desktop-cart-panel,
.desktop-cart-widget[aria-hidden="false"] .desktop-cart-panel {
    transform: translateX(0) !important;
}

/* ---------- Cabecera ---------- */

.desktop-cart-header {
    min-height: 80px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--cart-line);
}

.cart-title-section {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.cart-title-section > i {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    background: #f2efff;
    background: color-mix(in srgb, var(--cart-accent) 12%, #ffffff);
    color: var(--cart-accent);
    font-size: 17px;
}

.cart-title-section > div {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.cart-title-section strong {
    font-size: 16px;
    font-weight: 800;
    color: var(--cart-text);
    line-height: 1.2;
}

.cart-title-section .cart-items-count {
    margin-top: 2px;
    font-size: 11px;
    color: var(--cart-muted);
}

.desktop-cart-close {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 12px;
    background: #f3f4f6;
    color: #4b5563;
    font-size: 15px;
    cursor: pointer;
    transition: background .18s ease, color .18s ease;
}

.desktop-cart-close:hover,
.desktop-cart-close:focus-visible {
    background: #e9ebef;
    color: #1f2937;
    outline: none;
}

/* ---------- Items ---------- */

.desktop-cart-items {
    flex: 1;
    min-height: 0;
    padding: 14px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
}

.desktop-cart-items::-webkit-scrollbar {
    width: 8px;
}

.desktop-cart-items::-webkit-scrollbar-track {
    background: transparent;
}

.desktop-cart-items::-webkit-scrollbar-thumb {
    border-radius: 8px;
    background: #d6dae2;
}

.desktop-empty-cart {
    height: 100%;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--cart-muted);
}

.desktop-empty-cart > i {
    width: 60px;
    height: 60px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: #f3f4f7;
    color: #9aa1b1;
    font-size: 22px;
}

.desktop-empty-cart h4 {
    margin: 14px 0 5px;
    font-size: 15px;
    font-weight: 700;
    color: var(--cart-text);
}

.desktop-empty-cart p {
    margin: 0;
    font-size: 12px;
}

.desktop-cart-item {
    display: flex;
    gap: 12px;
    padding: 12px 6px;
    border-bottom: 1px solid var(--cart-line);
}

.desktop-cart-item:last-child {
    border-bottom: 0;
}

.desktop-cart-item .cart-item-image {
    width: 72px;
    height: 72px;
    flex: 0 0 72px;
    border-radius: 12px;
    object-fit: cover;
    background: #f3f4f6;
}

.desktop-cart-item .cart-item-details {
    flex: 1;
    min-width: 0;
}

.desktop-cart-item .cart-item-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--cart-text);
    /* Un nombre largo recorta, nunca ensancha el panel. */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.desktop-cart-item .cart-item-price {
    margin-top: 5px;
    font-size: 12px;
    font-weight: 800;
    color: var(--cart-accent);
}

.desktop-cart-item .cart-item-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
}

.quantity-btn,
.cart-item-remove {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    display: grid;
    place-items: center;
    border: 1px solid var(--cart-line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--cart-text);
    font-size: 10px;
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease;
}

.quantity-btn:hover {
    background: #f3f4f6;
}

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

.btn-checkout:active:not(.is-disabled):not([aria-disabled="true"]) {
    transform: scale(.99);
}

.cart-item-remove {
    margin-left: auto;
    color: #dc2626;
}

.cart-item-remove:hover {
    background: #fef2f2;
}

.cart-item-quantity {
    min-width: 22px;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--cart-text);
}

/* ---------- Totales y acción ---------- */

.desktop-cart-summary {
    padding: 15px 20px;
    border-top: 1px solid var(--cart-line);
}

.summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 5px 0;
    font-size: 13px;
    color: var(--cart-text);
}

.summary-row.discount span:last-child {
    font-weight: 700;
    color: #16a34a;
}

.summary-row.total {
    padding-top: 10px;
    font-size: 15px;
}

.summary-row.total strong {
    font-size: 19px;
    font-weight: 800;
    color: var(--cart-text);
}

.desktop-cart-actions {
    padding: 0 20px 20px;
}

/* Sin borde: el botón es un bloque sólido. */
.btn-checkout {
    width: 100%;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 0;
    border-radius: 14px;
    background: var(--cart-accent);
    color: #ffffff;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    transition: filter .18s ease;
}

.btn-checkout:hover:not(.is-disabled):not([aria-disabled="true"]) {
    filter: brightness(.93);
}

/* El JS retira el `disabled` nativo y marca con la clase, para que en móvil
   el botón siga recibiendo el toque. Por eso se estila la clase. */
.btn-checkout.is-disabled,
.btn-checkout[aria-disabled="true"],
.btn-checkout:disabled {
    background: #cfd4dd;
    cursor: not-allowed;
    opacity: .82;
    filter: none;
}

body.store-cart-open {
    overflow: hidden;
}

/* Con el carrito abierto ningún flotante puede quedar por encima ni robar el
   clic. Los selectores llevan las tres clases porque store_home.css fija
   #wa-support.whatsapp_chat_support.wcs_fixed_right con z-index máximo, y con
   dos reglas !important gana la más específica. */
body.store-cart-open #wa-support,
body.store-cart-open #wa-support.whatsapp_chat_support,
body.store-cart-open #wa-support.whatsapp_chat_support.wa_support_standalone,
body.store-cart-open #wa-support.whatsapp_chat_support.wcs_fixed_right,
body.store-cart-open .store-whatsapp-chat,
body.store-cart-open .gtranslate_wrapper,
body.store-cart-open .mn-footer-nav,
body.store-cart-open .single-store-mobile-dock {
    z-index: 1000 !important;
    pointer-events: none !important;
}

@media (max-width: 575.98px) {
    .desktop-cart-panel {
        width: 100%;
    }

    .desktop-cart-header {
        min-height: 68px;
        padding: 12px 14px;
    }

    .desktop-cart-summary {
        padding: 12px 14px;
    }

    .desktop-cart-actions {
        padding: 0 14px 14px;
    }

    .desktop-cart-item .cart-item-image {
        width: 60px;
        height: 60px;
        flex: 0 0 60px;
    }
}

/* Respeta a quien pide menos movimiento en el sistema. */
@media (prefers-reduced-motion: reduce) {

    #desktop-cart-widget .desktop-cart-panel,
    .desktop-cart-panel,
    .desktop-cart-overlay,
    .quantity-btn,
    .btn-checkout {
        transition-duration: .01ms !important;
    }

    .quantity-btn:active,
    .btn-checkout:active {
        transform: none;
    }
}
