/* Mejorar visual de los selectores de entrega */
.forma-entrega-row {
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: 100%;
    margin-bottom: 10px;
    align-items: stretch;
}

.cart-footer-mobile {
    display: none;
}

.entrega-card {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 18px 18px 14px 18px;
    border-radius: 12px;
    border: 2px solid #e3e8f0;
    background: #f9fbff;
    box-shadow: 0 2px 10px rgba(43, 124, 255, 0.04);
    display: flex;
    align-items: center;
    gap: 14px;
    transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
    cursor: pointer;
    position: relative;
    max-height: 5vw;
}

.entrega-card.selected {
    border-color: #2b7cff;
    background: #eaf3ff;
    box-shadow: 0 4px 18px rgba(43, 124, 255, 0.10);
}

.entrega-card:hover {
    border-color: #ff2b2b;
    background: #f5faff;
}

.entrega-icon {
    font-size: 1.5rem;
    margin-right: 10px;
    display: flex;
    align-items: center;
    color: #2b7cff;
}

.entrega-card-correo .entrega-icon {
    color: #ff9800;
}

.entrega-txt {
    font-size: 1rem;
    color: #232b3a;
    font-weight: 600;
    line-height: 0.9;
    display: flex;
    flex-direction: column;
}

.entrega-txt small {
    font-weight: 400;
    color: #6b7280;
    font-size: 0.93em;
}

@media (max-width: 600px) {
    .entrega-card {
        padding: 14px 10px 12px 10px;
        font-size: 0.97rem;
    }

    .entrega-txt {
        font-size: 0.97rem;
    }
}

/* === CARRITO MODERNO (FULL WIDTH + MEJOR DISTRIBUCIÓN) === */

.cart-section .container {
    margin: 0;
    width: 100%;
    max-width: 100%;
    padding: 0 24px;
}

.cart-summary {
    background: #fff;
    padding: 24px 20px;
    box-shadow: 0 4px 18px rgba(43, 124, 255, 0.06);
    border-radius: 10px;
    width: 100%;
    max-width: 420px;
    height: fit-content;
}

/* Resumen del pedido: filas y separación */
.cart-summary h3 {
    margin: 0 0 14px 0;
    font-size: 1.15rem;
    color: #1f2937;
}

.cart-summary .summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f1f5ff;
}

.cart-summary .summary-row:last-of-type {
    border-bottom: none;
}

.cart-summary .summary-row .entrega-card {
    width: 100%;
}

/* Shipping block: when the summary-row contains more complex content, allow column layout */
.cart-summary .summary-row.column,
.cart-summary .summary-row[style*="flex-direction:column"] {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
    padding: 8px 0 !important;
    border-bottom: none !important;
}

.cart-summary .forma-entrega-row {
    margin-top: 6px;
    gap: 12px;
}

.cart-summary .entrega-card {
    padding: 12px;
    border-radius: 10px;
}

.cart-summary .entrega-txt {
    line-height: 1.15;
}

.cart-summary .entrega-txt small {
    font-size: 0.92rem;
    color: #6b7280;
}

.cart-summary #precio-envio {
    margin-left: 8px;
}

.cart-summary .total {
    font-weight: 700;
    font-size: 1.05rem;
    padding-top: 12px;
    border-top: 1px solid #eef4ff;
    margin-top: 8px;
}

.cart-summary .btn-block {
    display: block;
    width: 100%;
    margin-top: 12px;
}

/* SECCIONES */

.cart-section,
.confirm-purchase-section {
    padding: 40px 16px 60px;
    min-height: 70vh;
    background: #f7faff;
}

/* EMPTY CART */

.empty-cart {
    text-align: center;
    padding: 50px 20px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 6px 24px rgba(43, 124, 255, 0.08);
    margin: 40px auto;
    max-width: 800px;

    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: center;
}

/* LAYOUT PRINCIPAL */

.cart-content {
    display: grid;
    grid-template-columns: 1fr 420px;
    /* resumen más ancho */
    gap: 28px;

    width: 100%;
    align-items: flex-start;
    /* evita que se estiren */
}

/* PRODUCTOS */

.cart-items {
    background: #fff;
    padding: 24px 20px;
    width: 100%;
    box-shadow: 0 4px 18px rgba(43, 124, 255, 0.06);
    border-radius: 10px;
    min-width: 0;
    height: fit-content;
    /* altura según contenido */
}

/* TABLA */

.cart-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 10px;
}

.cart-table th {
    background: #eef4ff;
    color: #ff2b2b;
    font-weight: 600;
    font-size: 0.95rem;
    border: none;
    padding: 12px 8px;
    text-align: left;
}

.cart-table td {
    background: #fff;
    border: none;
    box-shadow: none;
    border-radius: 0;
    padding: 12px 8px;
    vertical-align: middle;
    font-size: 0.95rem;
    transition: background 0.18s;
}

/* HOVER */

.cart-table tr:hover td {
    background: #f7faff;
}

/* PRODUCTO */

.cart-product-info {
    display: flex;
    gap: 12px;
    align-items: center;
}

.cart-product-info img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(43, 124, 255, 0.08);
    background: #f7faff;
}


/* SELECTORES DE ENTREGA: uno debajo del otro */
.forma-entrega-row {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    margin-bottom: 8px;
}

/* TITULO */
.cart-product-info a {
    font-weight: 700;
    font-size: 1rem;
    color: #232b3a;
    text-decoration: none;
    transition: color 0.18s, text-shadow 0.18s;
    letter-spacing: 0.01em;
    font-family: 'Montserrat', 'Poppins', Arial, sans-serif;
    line-height: 1.2;
}

.cart-product-info a:hover,
.cart-product-info a:focus {
    color: #ff2b2b;
    text-shadow: 0 2px 8px rgba(255, 43, 43, 0.08);
    outline: none;
}

/* TOTAL */

.item-total {
    font-weight: 700;
    color: #ff2b2b;
    font-size: 1rem;
}

/* RESPONSIVE */

@media (max-width: 992px) {
    .cart-content {
        grid-template-columns: 1fr;
    }

    .cart-summary {
        max-width: 100%;
    }

    .empty-cart {
        grid-template-columns: 1fr;
        text-align: center;
    }
}

@media (max-width: 600px) {
    .cart-items {
        padding: 16px;
    }

    .cart-product-info {
        gap: 10px;
    }

    .cart-product-info img {
        width: 52px;
        height: 52px;
    }

    .cart-table th {
        font-size: 0.85rem;
    }

    .cart-table td {
        font-size: 0.85rem;
        padding: 10px 6px;
    }
}

/* === Nuevo layout mobile: tarjetas por producto === */
@media (max-width: 767px) {
    /* mobile card layout */

    .cart-list, .cart-cards { display: block; }

    .cart-card {
        position: relative;
        display: flex;
        gap: 12px;
        align-items: flex-start;
        background: #fff;
        padding: 12px;
        border-radius: 12px;
        box-shadow: 0 6px 18px rgba(43,124,255,0.04);
        margin-bottom: 12px;
    }

    .cart-card-remove {
        position: absolute;
        top: 8px;
        right: 8px;
        background: #fff;
        border: none;
        width: 36px;
        height: 36px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        color: #fff;
        background: #ff4b4b;
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(255,75,75,0.12);
    }

    .cart-card-media img {
        width: 60px;
        height: 60px;
        object-fit: contain;
        border-radius: 8px;
        background: #f7faff;
        box-shadow: 0 2px 6px rgba(43,124,255,0.06);
    }

    .cart-card-media { flex: 0 0 60px; }
    .cart-card-body { flex: 1 1 auto; display: flex; flex-direction: column; gap: 8px; min-width: 0; }

    .cart-card-title { font-weight: 700; color: #232b3a; text-decoration: none; display: block; font-size: 0.98rem; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; }
    .cart-card-unit-price { color: #6b7280; font-size: 0.9rem; }

    .cart-card-controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 6px; }

    .quantity-input { display: flex; align-items: center; gap: 8px; }
    .qty-btn { width: 44px; height: 44px; min-width: 44px; min-height: 44px; border-radius: 10px; border: 1px solid #e6eefc; background: #fff; font-size: 1rem; display:inline-flex; align-items:center; justify-content:center; }
    .qty-btn.pressed, .qty-btn:active { transform: translateY(1px); box-shadow: inset 0 2px 6px rgba(0,0,0,0.06); }
    .qty-field { width: 64px; height: 44px; text-align: center; border-radius: 10px; border: 1px solid #eef4ff; }

    .cart-card-total { font-weight: 800; color: #ff2b2b; font-size: 1rem; text-align: right; min-width: 90px; }

    /* ensure main content has bottom spacing on small screens */
    .cart-section { padding-bottom: 60px; }
}

/* Desktop: keep previous summary visible */
@media (min-width: 768px) {
    .cart-footer-sticky { display: none; }
}

/* Convert existing table into stacked cards on small screens (mobile-only) */
@media (max-width: 767px) {
    /* Mostrar solo el bloque de envío del resumen en móvil (ocultar resto) */
    .desktop-summary {
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        margin-top: 12px;
        padding: 12px;
        background: #fff;
        box-shadow: 0 4px 18px rgba(43,124,255,0.04);
        border-radius: 10px;
        box-sizing: border-box;
    }

    /* Ocultar elementos del resumen que no aplican en móvil (subtotal, total, botones) */
    .desktop-summary h3,
    .desktop-summary .summary-row:first-of-type,
    .desktop-summary .summary-row.total,
    .desktop-summary > a {
        display: none !important;
    }

    /* Forzar que las opciones de envío sean visibles y ocupen ancho completo */
    .desktop-summary .summary-row.column,
    .desktop-summary .forma-entrega-row,
    .desktop-summary .shipping-price {
        display: block !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .desktop-summary .forma-entrega-row { gap: 16px; padding-top: 8px; padding-bottom: 2vw !important; }
    .desktop-summary .shipping-price { display:flex; align-items:center; justify-content:space-between; padding-top:8px; }

    /* Ajustes específicos para móviles: evitar recortes y solapamientos en las tarjetas de envío */
    .desktop-summary .entrega-card {
        max-height: none !important;
        padding-right: 48px !important; /* dejar espacio para el indicador de seleccionado */
    }

    .desktop-summary .entrega-txt { line-height: 1.1 !important;  }

    .desktop-summary #selector-local{
        margin-top: 2vw !important; margin-bottom: 2vw !important;
    }

    .desktop-summary .entrega-card.selected::after {
        top: 50% !important;
        transform: translateY(-50%) !important;
        right: 12px !important;
    }
    .cart-table thead, .cart-table th { display: none !important; }
    /* make each table row act as a flexible card and center items vertically */
    .cart-table, .cart-table tbody, .cart-table td { display: block; width: 100%; box-sizing: border-box; }

    .cart-table tr {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        position: relative;
        background: #fff;
        padding: 12px;
        border-radius: 12px;
        box-shadow: 0 6px 18px rgba(43,124,255,0.04);
        margin-bottom: 12px;
    }

    .cart-table td { padding: 6px 0; border-bottom: none; display:flex; align-items:center; }

    /* Product cell becomes the flexible area (image + title) */
    .cart-table td.product-cell { order: 1; flex: 1 1 55%; padding: 10px; display: flex; align-items: center; gap: 12px; min-width: 0; }
    .cart-product-info { display:flex; gap:12px; align-items:center; min-width:0; }
    .cart-product-info img { width: 72px; height: 72px; object-fit: contain; flex-shrink: 0; }

    /* Unit price */
    .cart-table td:nth-child(2) { color: #6b7280; font-size: 0.95rem; }

    /* Quantity controls */
    .cart-table td:nth-child(3) { margin-top: 6px; }
    .cart-table td:nth-child(3) .quantity-input { display:flex; align-items:center; gap:8px; }

    /* Item total (emphasized) */
    .cart-table td:nth-child(4) { font-weight: 800; color: #111827 !important; text-align: right; min-width: 90px; }

    /* Hide original action column (we show remove as absolute button) */
    .cart-table td:nth-child(5) { display: none; }

    /* Style remove button inside the row: icon-only, grey, no background */
    .cart-table .remove-item {
        position: absolute;
        top: 8px;
        right: 8px;
        width: 36px;
        height: 36px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: transparent;
        color: #6b7280;
        border-radius: 6px;
        border: none;
        box-shadow: none;
        font-size: 1rem;
    }

    .cart-items { overflow: visible; }
    .cart-section { padding-bottom: 80px; }

    /* Quantity controls: ensure same height and inline layout */
    .cart-table td:nth-child(3) .quantity-input { display:flex; align-items:center; gap:8px; }
    .qty-btn { width: 40px; height: 40px; min-width: 40px; min-height: 40px; border-radius: 8px; }
    .qty-field { width: 52px; height: 40px; text-align: center; border-radius: 8px; }

    /* Ensure image and content vertically centered */
    .cart-table tr { align-items: center; }

    /* Mobile footer styles (visible only on small screens) */
    .cart-footer-mobile { display: block; margin-top: 12px; }
    .cart-footer-inner { padding: 0px 0; padding-inline: 2vw; background: white; }
    .cart-footer-sep { border: none; border-top: 1px solid #eef4ff; margin: 6px 0 12px; }
    .cart-footer-row { display:flex; align-items:center; justify-content:space-between; gap:12px; }
    .cart-footer-row .cart-footer-label { font-size: 1rem; color: #374151; }
    .cart-footer-row .cart-footer-amount { font-size: 1.125rem; font-weight: 800; color: #2b7cff; }
    .mobile-checkout { margin-top: 12px; }

    /* If alternate card markup exists, hide it to avoid duplicates */
    .cart-card, .cart-cards { display: none !important; }
}
