/* ════════════════════════════════════════════════════════════
   Cart Items Widget — v2.0.0
   ════════════════════════════════════════════════════════════ */

/* ── WRAPPER ──────────────────────────────────────────────── */
.ciw-wrapper {
    width: 100%;
}

/* El widget NUNCA genera su propio scroll: la lista de productos fluye y
   crece con el contenido; quien scrollea es el canva, no el widget. */
.ciw-wrapper,
.ciw-list {
    overflow: visible;
    max-height: none;
}

/* ── Footer "abajo fijos" dentro del Off-Canvas de Elementor ──
   El área scrollable del Off-Canvas (.e-off-canvas__content) tiene altura
   definida. Estirando la cadena como columna flex, el carrito llena esa
   altura y el footer baja al fondo (contenido corto) o queda pegado abajo
   con position:sticky mientras el PANEL scrollea (contenido largo).
   Resultado: un solo scroll (el del canva), sin barra interna de productos. */
.e-off-canvas__content:has(.ciw-wrapper--has-fixed-footer) {
    display: flex;
    flex-direction: column;
}
.e-off-canvas__content:has(.ciw-wrapper--has-fixed-footer) > .e-con {
    flex: 1 1 auto;
    min-height: 0;
}
.e-off-canvas__content:has(.ciw-wrapper--has-fixed-footer) > .e-con > .e-con-inner {
    flex: 1 1 auto;
    min-height: 0;
    align-self: stretch;
    width: 100%;
    display: flex;
    flex-direction: column;
}
.elementor-widget-cart_items_widget:has(.ciw-wrapper--has-fixed-footer) {
    flex: 1 1 auto;
    min-height: 0;
    align-self: stretch;
    display: flex;
    flex-direction: column;
}
.elementor-widget-cart_items_widget:has(.ciw-wrapper--has-fixed-footer) > .elementor-widget-container {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.ciw-wrapper--has-fixed-footer {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

/* ── LIST ─────────────────────────────────────────────────── */
.ciw-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ── SPINNER ──────────────────────────────────────────────── */
.ciw-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid #e5e5e5;
    border-top-color: #999;
    border-radius: 50%;
    animation: ciw-spin 0.7s linear infinite;
    margin: 32px auto;
}
@keyframes ciw-spin { to { transform: rotate(360deg); } }

/* ── EMPTY ────────────────────────────────────────────────── */
.ciw-empty {
    color: #aaa;
    font-size: 14px;
    margin: 0;
    padding: 40px 0;
    text-align: center;
}
.ciw-wrapper.is-empty .ciw-footer {
    display: none;
}

/* ── ITEM ─────────────────────────────────────────────────── */
.ciw-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 0;
    border-bottom: 1px solid #f0f0f0;
    background-color: #fff;
    position: relative;
    transition: opacity 0.2s ease;
}
.ciw-item:last-child { border-bottom: none; }
.ciw-item.is-loading {
    opacity: 0.45;
    pointer-events: none;
}

/* ── PRODUCTO NUEVO: entrada + resaltado ──────────────────────
   Al añadir, el item entra con .ciw-item--flash (color resaltado) y luego el
   JS le pone .ciw-item--fade y quita --flash → vuelve al color normal suave. */
@keyframes ciw-enter {
    from { opacity: 0; transform: translateY(-10px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.ciw-item--enter {
    animation: ciw-enter 0.45s cubic-bezier(0.2, 0.7, 0.3, 1);
}

/* Colores del resaltado (por defecto azul con texto blanco). Usan !important
   porque las reglas por-elemento de Elementor empatan en especificidad y
   ganarían por orden de origen. Elementor puede sobrescribirlas (también con
   !important desde los controles de estilo del resaltado). */
.ciw-wrapper .ciw-item--flash {
    background-color: #2563eb !important;
}
.ciw-wrapper .ciw-item--flash .ciw-name,
.ciw-wrapper .ciw-item--flash .ciw-name a,
.ciw-wrapper .ciw-item--flash .ciw-price,
.ciw-wrapper .ciw-item--flash .ciw-price .woocommerce-Price-amount,
.ciw-wrapper .ciw-item--flash .ciw-price del .woocommerce-Price-amount,
.ciw-wrapper .ciw-item--flash .ciw-price ins .woocommerce-Price-amount {
    color: #ffffff !important;
}
.ciw-wrapper .ciw-item--flash .ciw-meta {
    color: rgba(255, 255, 255, 0.8) !important;
}

/* La transición del regreso al color normal (duración configurable) */
.ciw-item--fade,
.ciw-item--fade .ciw-name,
.ciw-item--fade .ciw-name a,
.ciw-item--fade .ciw-meta,
.ciw-item--fade .ciw-price,
.ciw-item--fade .ciw-price .woocommerce-Price-amount {
    transition: background-color var(--ciw-flash-dur, 1200ms) ease,
                color var(--ciw-flash-dur, 1200ms) ease;
}

/* ── IMAGE ────────────────────────────────────────────────── */
.ciw-img {
    width: 90px;
    height: 90px;
    flex-shrink: 0;
    border-radius: 10px;
    overflow: hidden;
    background-color: #f5f5f5;
}
.ciw-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.ciw-img-link {
    display: block;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* ── BODY ─────────────────────────────────────────────────── */
.ciw-body {
    flex: 1;
    min-width: 0;
}
.ciw-name {
    font-size: 14px;
    font-weight: 600;
    color: #111;
    margin: 0 0 3px;
    line-height: 1.3;
}
.ciw-name a {
    color: inherit;
    text-decoration: none;
}
.ciw-name a:hover {
    text-decoration: underline;
}
.ciw-meta {
    font-size: 12px;
    color: #888;
    margin: 0;
    line-height: 1.4;
}

/* ── PRICE + QTY (posición configurable) ──────────────────── */
.ciw-pq {
    display: flex;
    gap: 6px 12px;
    margin-top: 8px;
}

/* Precio arriba de la cantidad (por defecto) */
.ciw-pq--above {
    flex-direction: column;
    align-items: flex-start;
}
/* Precio debajo de la cantidad */
.ciw-pq--below {
    flex-direction: column-reverse;
    align-items: flex-start;
}
/* Precio a la izquierda, cantidad a la derecha */
.ciw-pq--left {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}
/* Precio a la derecha, cantidad a la izquierda */
.ciw-pq--right {
    flex-direction: row-reverse;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

/* ── PRICE ────────────────────────────────────────────────── */
.ciw-price {
    font-size: 14px;
    font-weight: 600;
    color: #111;
}
.ciw-price del {
    font-weight: 400;
    margin-right: 4px;
}
.ciw-price del .woocommerce-Price-amount { color: #aaa; }
.ciw-price ins { text-decoration: none; }
.ciw-price.is-sale ins .woocommerce-Price-amount { color: #cc0000; }

/* ── QTY ──────────────────────────────────────────────────── */
.ciw-qty-wrap {
    display: inline-flex;
    align-items: center;
    border: 1px solid #e0e0e0;
    border-radius: 50px;
    overflow: hidden;
    background-color: #f5f5f5;
}
.ciw-qty-btn {
    background: none;
    border: none;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #111;
    transition: background-color 0.15s;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}
.ciw-qty-btn:hover:not(:disabled) { background-color: rgba(0,0,0,0.06); }
.ciw-qty-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.ciw-qty-btn i,
.ciw-qty-btn svg {
    font-size: 11px;
    width: 11px;
    height: 11px;
    display: block;
    pointer-events: none;
}
.ciw-qty-value {
    min-width: 32px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #111;
    user-select: none;
}

/* ── REMOVE ───────────────────────────────────────────────── */
.ciw-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    flex-shrink: 0;
    transition: color 0.2s;
    line-height: 1;
    align-self: flex-start;
}
.ciw-remove:hover { color: #cc0000; }
.ciw-remove i,
.ciw-remove svg {
    font-size: 14px;
    width: 14px;
    height: 14px;
    display: block;
    pointer-events: none;
}

/* ════════════════════════════════════════════════════════════
   FOOTER (Botones Carrito / Pagar)
   ════════════════════════════════════════════════════════════ */
.ciw-footer {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 0 4px;
}

/* Apilados después de los productos (scrollan con la lista) */
.ciw-footer--inline {
    border-top: 1px solid #f0f0f0;
    margin-top: 4px;
}

/* Fijos abajo: margin-top:auto lo empuja al fondo (contenido corto) y
   position:sticky lo mantiene visible mientras el panel scrollea (largo). */
.ciw-footer--fixed {
    margin-top: auto;
    position: sticky;
    bottom: 0;
    background-color: #fff;
    border-top: 1px solid #ececec;
    z-index: 3;
}

/* ── BOTONES ──────────────────────────────────────────────── */
.ciw-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    padding: 14px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background-color 0.18s ease, transform 0.05s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}
.ciw-btn:hover { text-decoration: none; }
.ciw-btn:active { transform: translateY(1px); }

/* Secundario: Ver carrito */
.ciw-btn--cart {
    background-color: #fff;
    color: #111;
    border-color: #ddd;
}
.ciw-btn--cart:hover {
    background-color: #f6f6f6;
    color: #111;
}

/* Primario: Ir a pagar */
.ciw-btn--checkout {
    background-color: #111;
    color: #fff;
}
.ciw-btn--checkout:hover {
    background-color: #000;
    color: #fff;
}
.ciw-btn__sep {
    opacity: 0.55;
    font-weight: 400;
}
.ciw-btn__total {
    font-weight: 700;
    white-space: nowrap;
}
/* El total hereda el color del botón */
.ciw-btn__total .woocommerce-Price-amount,
.ciw-btn__total .ce-cart-total {
    color: inherit;
}

/* ════════════════════════════════════════════════════════════
   BADGE — bullet contador [ce_cart_badge]
   ════════════════════════════════════════════════════════════ */
.ce-cart-badge {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    color: #111;
    text-decoration: none;
    line-height: 1;
    transition: opacity 0.18s ease, transform 0.05s ease;
}
.ce-cart-badge:hover { opacity: 0.75; }
.ce-cart-badge:active { transform: scale(0.94); }

.ce-cart-badge__icon {
    display: inline-flex;
    width: 26px;
    height: 26px;
}
.ce-cart-badge__icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* El número en círculo, arriba a la derecha */
.ce-cart-badge__count {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #e11900;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    border-radius: 999px;
    box-shadow: 0 0 0 2px #fff;
}

/* Sin icono (icon="none"): el número se muestra como un círculo relleno */
.ce-cart-badge:not(:has(.ce-cart-badge__icon)) {
    width: auto;
    height: auto;
}
.ce-cart-badge:not(:has(.ce-cart-badge__icon)) .ce-cart-badge__count {
    position: static;
    box-shadow: none;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    font-size: 13px;
}

/* Ocultar el badge cuando el carrito está vacío (hide_empty="yes") */
.ce-cart-badge--hide-empty:has(.ce-cart-badge__count[data-count="0"]) {
    display: none;
}

/* ── Bloque de botones suelto via [ce_cart_buttons] ──────────── */
.ciw-footer.ciw-footer--inline:first-child {
    border-top: none;
    margin-top: 0;
}
