/* assets/css/carrito.css */

.page-carrito {
    background-color: #f8f9fa;
    min-height: 80vh;
    padding: 40px 10px;
    /* Espacio extra abajo para que el sticky footer no tape el último producto en móvil */
    padding-bottom: 100px; 
}

.page-title {
    margin-top: 0;
    margin-bottom: 30px;
    color: #333;
    font-weight: 800;
    font-size: 28px;
}

/* --- LAYOUT PRINCIPAL --- */
.cart-layout {
    display: grid;
    grid-template-columns: 1fr 350px; /* Columna productos ancha | Resumen fijo */
    gap: 40px;
    align-items: start;
}

/* --- LISTADO (La Tabla) --- */
.cart-list {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #eee;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

/* Definición de columnas de la grilla (Header e Items iguales) */
/* Foto | Info | Precio | Cantidad | Subtotal | Borrar */
.cart-grid-row {
    display: grid;
    grid-template-columns: 90px 2fr 1fr 120px 1fr 50px; 
    gap: 20px;
    align-items: center;
    padding: 20px;
}

.cart-header-row {
    background: #f1f3f5;
    border-bottom: 1px solid #e9ecef;
    font-size: 13px;
    font-weight: 700;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cart-item {
    border-bottom: 1px solid #eee;
    transition: background 0.2s;
}
.cart-item:last-child { border-bottom: none; }
.cart-item:hover { background-color: #fafafa; }
.cart-item.has-error { background-color: #fff5f5; border-left: 4px solid #e74c3c; }

/* --- ELEMENTOS DEL ITEM --- */
.cart-item__img-box {
    width: 90px;
    height: 90px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #eee;
    background: #fff;
    cursor: pointer;
}
.cart-item__img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.cart-item__info { display: flex; flex-direction: column; gap: 5px; }

.item-link {
    text-decoration: none;
    color: #333;
    font-weight: 700;
    font-size: 16px;
    transition: color 0.2s;
}
.item-link:hover { color: #6aa8d5; }

.badge-tipo {
    display: inline-block;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
    width: fit-content;
}

/*
.venta-par { background: #d4edda; color: #155724; }
.venta-modulo { background: #f8d7da; color: #721c24; }
.venta-mixta { background-color: #fce186; color: #755f0b; }
*/

.venta-par, .venta-modulo , .venta-mixta {
  padding: 6px;
  background-color: #A9C4EB;
  color: #385975 ;
}

/* Estilo para la Curva del Módulo */
.curva-detail {
    font-size: 12px;
    color: #666;
    background: #f8f9fa;
    padding: 5px 8px;
    border-radius: 4px;
    border: 1px solid #eee;
    margin-top: 4px;
    line-height: 1.4;
}

.stock-msg { color: #e74c3c; font-size: 12px; font-weight: 700; margin-top: 5px; }

.cart-item__price { font-size: 15px; color: #555; }
.input-qty { width: 70px; padding: 6px; text-align: center; border: 1px solid #ddd; border-radius: 4px; font-weight: 700; }
.cart-item__subtotal { font-size: 16px; font-weight: 800; color: #333; }

.btn-trash { background: none; border: none; cursor: pointer; font-size: 18px; color: #bbb; transition: color 0.2s; }
.btn-trash:hover { color: #e74c3c; }

/* --- RESUMEN DE ESCRITORIO --- */
.cart-summary {
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    border: 1px solid #eee;
    position: sticky;
    top: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.04);
}
.summary-title { margin-top: 0; margin-bottom: 20px; font-size: 18px; font-weight: 700; }
.summary-row { display: flex; justify-content: space-between; margin-bottom: 12px; font-size: 14px; color: #555;}
.summary-row.total { font-size: 22px; font-weight: 800; color: #333; margin-top: 15px; border-top: 2px solid #eee; padding-top: 15px; }

.btn-checkout {
    width: 100%;
    padding: 15px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    font-size: 16px;
    margin-top: 20px;
    text-transform: uppercase;
    transition: background 0.2s;
}
.btn-checkout:hover { background: #219150; }
.btn-checkout.disabled { background: #ccc; cursor: not-allowed; }

.btn-continue { display: block; text-align: center; margin-top: 15px; color: #666; text-decoration: none; font-size: 14px; }
.btn-continue:hover { text-decoration: underline; }

/* Aviso método de pago */
.pago-info-box {
    background: #fffbf0;
    border: 1px solid #f0c060;
    border-left: 4px solid #e8b84b;
    border-radius: 8px;
    padding: 12px 14px;
    margin-top: 20px;
}
.pago-info-text strong {
    display: block;
    font-size: 13px;
    font-weight: 800;
    color: #7a5c00;
    margin-bottom: 4px;
}
.pago-info-text p {
    margin: 0;
    font-size: 12px;
    color: #8a6a00;
    line-height: 1.5;
}

/* Empty State */
.empty-state { text-align: center; padding: 80px 20px; background: #fff; border-radius: 8px; margin: 0 auto; max-width: 600px; box-shadow: 0 5px 20px rgba(0,0,0,0.05); }
.empty-icon { font-size: 60px; margin-bottom: 20px; display: block; opacity: 0.5; }
.btn-primary { background: #6aa8d5; color: white; padding: 12px 30px; text-decoration: none; border-radius: 6px; font-weight: 700; display: inline-block; margin-top: 20px; }

/* Alertas */
.alert-stock { background: #fce4e4; color: #c0392b; padding: 15px; border-radius: 6px; margin-bottom: 30px; border: 1px solid #f5c6cb; }

/* --- BARRA FIJA MÓVIL (Sticky Footer) --- */
.mobile-sticky-footer {
    display: none; /* Oculto en PC por defecto */
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #fff;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    padding: 15px 20px;
    z-index: 1000;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    border-top: 1px solid #eee;
}

.msf-total {
    display: flex;
    flex-direction: column;
}
.msf-total span { font-size: 11px; color: #888; text-transform: uppercase; font-weight: 700; }
.msf-total strong { font-size: 20px; color: #333; font-weight: 800; }

.btn-checkout-mobile {
    background-color: #27ae60;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 25px;
    font-weight: 800;
    font-size: 14px;
    text-transform: uppercase;
    flex: 1; /* Ocupa el espacio restante */
    max-width: 200px;
    box-shadow: 0 4px 10px rgba(39, 174, 96, 0.3);
    cursor: pointer;
}
.btn-checkout-mobile.disabled { background: #ccc; cursor: not-allowed; box-shadow: none; }


/* ======== RESPONSIVE MOBILE ======== */
@media(max-width: 900px) {
    .page-carrito { padding: 20px 12px 140px; }
    .page-title { font-size: 22px; margin-bottom: 16px; }

    .cart-layout { grid-template-columns: 1fr; gap: 0; }
    .cart-header-row { display: none !important; }
    .cart-summary { display: none; }
    .mobile-sticky-footer { display: flex; }

    /* Lista sin fondo propio */
    .cart-list {
        background: transparent;
        border: none;
        box-shadow: none;
        overflow: visible;
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    /* Cada item: grid de 3 cols */
    .cart-item.cart-grid-row {
        display: grid;
        grid-template-columns: 76px 1fr 32px;
        grid-template-rows: auto auto auto;
        grid-template-areas:
            "img  info  del"
            "img  price del"
            "qty  qty   sub";
        gap: 4px 12px;
        padding: 14px;
        border-radius: 10px;
        border: 1px solid #eee;
        box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    }
    .cart-item.has-error { border-left: 4px solid #e74c3c; }

    .cart-item__img-box { grid-area: img; width: 76px; height: 76px; }
    .cart-item__info    { grid-area: info; align-self: start; }
    .item-link          { font-size: 14px; }
    .cart-item__price   { grid-area: price; font-size: 13px; color: #888; align-self: end; }
    .cart-item__qty     {
        grid-area: qty;
        border-top: 1px solid #f0f0f0;
        padding-top: 10px;
        display: flex;
        align-items: center;
        gap: 6px;
    }
    .cart-item__qty-label { display: none; }
    .cart-item__subtotal {
        grid-area: sub;
        border-top: 1px solid #f0f0f0;
        padding-top: 10px;
        text-align: right;
        font-size: 17px;
        font-weight: 800;
        color: #333;
        display: flex;
        align-items: center;
        justify-content: flex-end;
    }
    .cart-item__action { grid-area: del; display: flex; align-items: flex-start; justify-content: center; padding-top: 2px; }

    .input-qty { width: 58px; padding: 6px; font-size: 14px; }
    .btn-trash svg { width: 16px; height: 16px; }
}

@media (min-width: 901px) {
    .page-carrito { padding-bottom: 40px; }
}