/* ============================================================
   cart.css – MGTEX Carrito de Compras
   ─────────────────────────────────────────────────────────
   Únicos estilos relacionados con el carrito:
     · Dropdown con miniaturas de productos
     · Badge activo
     · Animación de vuelo al agregar
     · Feedback del botón "Agregar"
     · Sacudida del ícono
     · Swatches de color del filtro lateral
   ─────────────────────────────────────────────────────────
   No contiene lógica de negocio ni estilos generales.
   ============================================================ */

/* ─── Badge (punto de notificación) ───────────────────────── */
.ec-badge {
    display: inline-block;
    width: 10px;
    height: 10px;
    background: var(--ec-marca, #d90429);
    border-radius: 50%;
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 0;
    line-height: 0;
    color: transparent;
}

.ec-badge--active {
    background: var(--ec-marca);
    animation: badgePop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes badgePop {
    from { transform: scale(0.5); }
    to   { transform: scale(1); }
}

/* ─── Dropdown del carrito ─────────────────────────────────── */
.ec-cart-dropdown {
    min-width: 310px;
    max-width: 340px;
}

/* Estado vacío */
#ecCartEmpty {
    padding: 28px 20px;
    text-align: center;
}

/* Estado con items */
#ecCartFilled {
    display: none;
}

/* ─── Lista de items ────────────────────────────────────────── */
.ec-cart-items {
    max-height: 290px;
    overflow-y: auto;
    padding: 6px 0;
    scrollbar-width: thin;
    scrollbar-color: #e0e0e0 transparent;
}
.ec-cart-items::-webkit-scrollbar       { width: 4px; }
.ec-cart-items::-webkit-scrollbar-track { background: transparent; }
.ec-cart-items::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

/* ─── Fila de cada item ─────────────────────────────────────── */
.ec-cart-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid #f2f2f2;
    transition: background 0.15s;
}
.ec-cart-item:last-child { border-bottom: none; }
.ec-cart-item:hover      { background: #fafafa; }

/* Miniatura */
.ec-ci-img {
    width: 54px;
    height: 54px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    border: 1px solid #ebebeb;
}

/* Info */
.ec-ci-info {
    flex: 1;
    min-width: 0;
}
.ec-ci-name {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #222;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}
.ec-ci-qty-price {
    display: block;
    font-size: 11px;
    color: #888;
}

/* Botón eliminar */
.ec-ci-remove {
    background: none;
    border: none;
    color: #ccc;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
    transition: color 0.15s;
    flex-shrink: 0;
}
.ec-ci-remove:hover { color: #e03030; }

/* ─── Footer: total + botón ─────────────────────────────────── */
.ec-cart-footer {
    padding: 12px 14px 14px;
    border-top: 1px solid #f0f0f0;
    background: #fafafa;
}
.ec-cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #555;
    margin-bottom: 12px;
}
.ec-cart-total strong {
    font-size: 16px;
    font-weight: 700;
    color: var(--ec-marca);
}
.ec-cart-footer .ec-dd-btn {
    display: block;
    text-align: center;
    width: 100%;
}

/* ─── Imagen voladora (animación add-to-cart) ────────────────── */
.cart-fly-img {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    border-radius: 8px;
    object-fit: cover;
    /* Las propiedades de transición se ponen por JS para controlar el timing */
}

/* ─── Feedback del botón "Agregar" ──────────────────────────── */
.prod-add-btn--added {
    background: var(--ec-marca) !important;
    letter-spacing: 0.5px;
}

/* ─── Sacudida del ícono del carrito ─────────────────────────── */
@keyframes cartShake {
    0%   { transform: rotate(0deg)   scale(1);    }
    20%  { transform: rotate(-14deg) scale(1.18); }
    40%  { transform: rotate(14deg)  scale(1.18); }
    60%  { transform: rotate(-7deg)  scale(1.1);  }
    80%  { transform: rotate(7deg)   scale(1.05); }
    100% { transform: rotate(0deg)   scale(1);    }
}
.cart-shake {
    animation: cartShake 0.65s ease forwards;
}

/* ─── Swatches de color (filtro del sidebar) ─────────────────── */
.tsb-color-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 6px 0 8px;
}

.tsb-color-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    position: relative;
}

/* Ocultar el checkbox nativo */
.tsb-color-swatch input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* Cuadrito de color */
.tsb-swatch-box {
    width: 28px;
    height: 28px;
    border-radius: 5px;
    border: 2px solid transparent;
    box-shadow: 0 0 0 1px #d0d0d0;
    transition: box-shadow 0.15s, border-color 0.15s, transform 0.15s;
    position: relative;
}

.tsb-color-swatch:hover .tsb-swatch-box {
    transform: scale(1.12);
    box-shadow: 0 0 0 2px var(--ec-marca);
}

.tsb-color-swatch input:checked + .tsb-swatch-box {
    border-color: var(--ec-marca);
    box-shadow: 0 0 0 2px var(--ec-marca);
}

/* Checkmark sobre el color */
.tsb-color-swatch input:checked + .tsb-swatch-box::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 13px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
    line-height: 1;
}

/* Etiqueta debajo del swatch */
.tsb-swatch-label {
    font-size: 10px;
    color: #666;
    text-align: center;
    line-height: 1.2;
    user-select: none;
}
