/**
 * Carrito flotante (botón + panel lateral).
 */

/* =========================================================================
   Botón flotante
   ========================================================================= */

#ene-cart-btn {
    position: fixed;
    right: 15px;
    bottom: 75px;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: var(--radius-full);
    background: var(--ene-primary);
    color: var(--ene-white);
    box-shadow: 0 4px 16px rgba(0, 0, 0, .3);
    cursor: pointer;
    transition: background-color var(--duration-fast) var(--ease-both), transform var(--duration-fast) var(--ease-both);
}

#ene-cart-btn:hover {
    background: var(--ene-primary-dark);
    transform: scale(1.06);
}

#ene-cart-btn:focus-visible {
    outline: 3px solid var(--ene-ink);
    outline-offset: 3px;
}

#ene-cart-btn svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#ene-cart-count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: var(--radius-full);
    background: var(--ene-ink);
    color: var(--ene-white);
    font-size: .72rem;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
}

#ene-cart-count[hidden] {
    display: none;
}

/* =========================================================================
   Panel
   ========================================================================= */

#ene-cart-overlay {
    position: fixed;
    inset: 0;
    z-index: 99998;
    background: rgba(17, 17, 17, .45);
    opacity: 0;
    transition: opacity var(--duration-slow) var(--ease-both);
}

#ene-cart-overlay.open {
    opacity: 1;
}

#ene-cart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    width: 420px;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: var(--ene-white);
    box-shadow: -4px 0 24px rgba(0, 0, 0, .18);
    transform: translateX(100%);
    transition: transform var(--duration-slow) var(--ease-both);
}

#ene-cart-drawer.open {
    transform: none;
}

#ene-cart-drawer[hidden],
#ene-cart-overlay[hidden] {
    display: none;
}

#ene-cart-drawer[aria-busy="true"] .ene-cart-lista {
    opacity: .5;
    pointer-events: none;
}

.ene-cart-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-3) var(--sp-4) var(--sp-3) var(--sp-5);
    border-bottom: 3px solid var(--ene-primary);
}

#ene-cart-drawer .ene-cart-titulo {
    margin: 0;
    padding: 0;
    border: 0 !important;
    font-family: var(--font-display);
    font-size: 1.6rem;
    letter-spacing: 1px;
    color: var(--ene-ink);
}

.ene-cart-cerrar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--ene-ink);
    cursor: pointer;
}

.ene-cart-cerrar:hover,
.ene-cart-cerrar:focus {
    background: none;
    color: var(--ene-primary);
}

.ene-cart-cerrar svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

/* Envío gratis */
.ene-cart-envio {
    padding: var(--sp-3) var(--sp-5);
    background: var(--ene-surface-2);
}

.ene-cart-envio[hidden] {
    display: none;
}

#ene-cart-drawer .ene-cart-envio-texto {
    margin: 0 0 6px;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--ene-ink);
}

.ene-cart-envio-barra {
    height: 6px;
    border-radius: var(--radius-full);
    background: var(--ene-surface-3);
    overflow: hidden;
}

.ene-cart-envio-barra span {
    display: block;
    height: 100%;
    background: var(--ene-success);
    transition: width var(--duration-slow) var(--ease-both);
}

/* Avisos */
#ene-cart-drawer .ene-cart-aviso {
    margin: 0;
    padding: var(--sp-2) var(--sp-5);
    background: var(--ene-ink);
    color: var(--ene-white);
    font-size: var(--text-sm);
}

.ene-cart-aviso[hidden] {
    display: none;
}

.ene-cart-deshacer {
    padding: 0;
    border: 0;
    background: none;
    color: var(--ene-white);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.ene-cart-deshacer:hover,
.ene-cart-deshacer:focus {
    background: none;
    color: var(--ene-white);
}

/* Lista */
.ene-cart-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-2) var(--sp-5);
}

#ene-cart-drawer .ene-cart-lista {
    margin: 0;
    padding: 0;
    list-style: none;
}

#ene-cart-drawer .ene-cart-item {
    display: flex;
    gap: var(--sp-3);
    margin: 0;
    padding: var(--sp-3) 0;
    border-bottom: 1px solid var(--ene-border);
    font-size: var(--text-sm);
    line-height: 1.4;
}

.ene-cart-item img {
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
    border: 1px solid var(--ene-border);
    border-radius: var(--radius-sm);
    object-fit: contain;
    background: var(--ene-surface-2);
}

.ene-cart-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#ene-cart-drawer .ene-cart-nombre {
    font-weight: 600;
    color: var(--ene-ink) !important;
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

#ene-cart-drawer a.ene-cart-nombre:hover {
    color: var(--ene-primary) !important;
    text-decoration: underline;
}

.ene-cart-sku,
.ene-cart-precio {
    font-size: var(--text-xs);
    color: var(--ene-text-muted);
}

.ene-cart-qty {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    margin-top: 6px;
    border: 1px solid var(--ene-border-dark);
    border-radius: var(--radius-sm);
}

.ene-cart-qty-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    background: var(--ene-white);
    color: var(--ene-ink);
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}

.ene-cart-qty-btn:hover:not(:disabled) {
    background: var(--ene-primary);
    color: var(--ene-white);
}

.ene-cart-qty-btn:disabled {
    color: var(--ene-text-disabled);
    cursor: not-allowed;
}

.ene-cart-qty-num {
    min-width: 32px;
    font-weight: 700;
    text-align: center;
}

.ene-cart-lado {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--sp-2);
}

.ene-cart-linea {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 400;
    letter-spacing: .5px;
    white-space: nowrap;
}

.ene-cart-quitar {
    padding: 4px 0;
    border: 0;
    background: none;
    color: var(--ene-text-muted);
    font-size: var(--text-xs);
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.ene-cart-quitar:hover,
.ene-cart-quitar:focus {
    background: none;
    color: var(--ene-primary);
}

.ene-cart-qty-btn:focus-visible,
.ene-cart-quitar:focus-visible,
.ene-cart-cerrar:focus-visible,
.ene-cart-deshacer:focus-visible,
.ene-cart-btn:focus-visible,
#ene-cart-drawer a.ene-cart-nombre:focus-visible {
    outline: 2px solid var(--ene-primary);
    outline-offset: 2px;
}

/* Vacío */
.ene-cart-vacio {
    padding: var(--sp-7) 0;
    text-align: center;
}

.ene-cart-vacio[hidden] {
    display: none;
}

#ene-cart-drawer .ene-cart-vacio p {
    margin: 0 0 var(--sp-4);
    color: var(--ene-text-secondary);
}

/* Pie */
.ene-cart-pie {
    padding: var(--sp-4) var(--sp-5);
    border-top: 1px solid var(--ene-border);
    background: var(--ene-surface-2);
}

.ene-cart-pie[hidden] {
    display: none;
}

.ene-cart-subtotal {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-weight: 700;
    color: var(--ene-ink);
}

.ene-cart-subtotal-valor {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 400;
    letter-spacing: .5px;
}

#ene-cart-drawer .ene-cart-nota {
    margin: 0 0 var(--sp-3);
    font-size: var(--text-xs);
    color: var(--ene-text-muted);
}

#ene-cart-drawer .ene-cart-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    margin-bottom: var(--sp-2);
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: var(--text-sm);
    text-decoration: none;
}

#ene-cart-drawer .ene-cart-btn--primario {
    background: var(--ene-primary);
    color: var(--ene-white) !important;
}

#ene-cart-drawer .ene-cart-btn--primario:hover {
    background: var(--ene-primary-dark);
}

#ene-cart-drawer .ene-cart-btn--secundario {
    border: 2px solid var(--ene-ink);
    background: var(--ene-white);
    color: var(--ene-ink) !important;
}

#ene-cart-drawer .ene-cart-btn--secundario:hover {
    border-color: var(--ene-primary);
    color: var(--ene-primary) !important;
}

/* Con el panel abierto, el botón de WhatsApp taparía "Ver carrito". */
body.ene-cart-abierto #ht-ctc-chat {
    display: none !important;
}

@media (prefers-reduced-motion: reduce) {
    #ene-cart-drawer,
    #ene-cart-overlay {
        transition: none;
    }
}
