.contenedor-carrito {
    --c-rosa: var(--rosa, #d32f2f);
    --c-crema: var(--crema, #fff5f5);
    --c-texto: var(--texto-oscuro, #222);
    --c-borde: #ececec;
    --c-radio: 14px;
    --c-sombra: 0 6px 24px rgba(0, 0, 0, .05);

    max-width: 1200px;
    margin: clamp(20px, 4vw, 48px) auto;
    padding: 0 clamp(14px, 3vw, 24px);
    min-height: 50vh;
}

.contenedor-carrito *,
.contenedor-carrito *::before,
.contenedor-carrito *::after {
    box-sizing: border-box;
}

/* ---------- LAYOUT GENERAL ---------- */
.layout-carrito {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: clamp(20px, 3vw, 40px);
    align-items: start;
}

.layout-checkout {
    grid-template-columns: minmax(0, 1fr) 400px;
}

/* ---------- LISTA DE PRODUCTOS ---------- */
.carrito-items {
    min-width: 0;
    background: #fff;
    border: 1px solid var(--c-borde);
    border-radius: var(--c-radio);
    box-shadow: var(--c-sombra);
    overflow: hidden;
}

.carrito-header-row,
.carrito-item-row {
    display: grid;
    grid-template-columns: minmax(0, 2.4fr) 1fr 1.2fr 1fr 36px;
    align-items: center;
    column-gap: 16px;
    padding: 16px 24px;
}

.carrito-header-row {
    background: var(--c-crema);
    color: var(--c-texto);
    font-weight: 700;
    font-size: .78rem;
    letter-spacing: .6px;
    text-transform: uppercase;
}

.col-producto,
.col-precio,
.col-cantidad,
.col-subtotal {
    flex: none;
    padding: 0;
    text-align: center;
}

.col-producto { text-align: left; }

.carrito-item-row {
    padding-top: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--c-borde);
    transition: background .25s;
}

.carrito-item-row:last-child { border-bottom: none; }
.carrito-item-row:hover { background: #fcfcfc; }

.cart-product-info {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.cart-product-info img {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid #eee;
}

.cart-product-info h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    color: #111;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cart-price-val,
.cart-subtotal-val {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--c-rosa);
}

.cart-price-val { color: #555; font-weight: 600; }

.cart-qty-ctrl {
    display: flex;
    justify-content: center;
    align-items: center;
}

.cart-qty-ctrl .qty-box {
    display: inline-flex;
    align-items: center;
    background: #f4f4f4;
    border-radius: 999px;
    padding: 4px;
    margin: 0;
}

.cart-qty-ctrl button {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 50%;
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    line-height: 1;
    color: #555;
    transition: .2s;
}

.cart-qty-ctrl button:hover {
    background: var(--c-crema);
    color: var(--c-rosa);
    border-color: var(--c-rosa);
}

.cart-qty-ctrl input {
    width: 42px;
    text-align: center;
    border: none;
    background: transparent;
    font-weight: 700;
    font-size: 1rem;
    -moz-appearance: textfield;
}

.cart-qty-ctrl input::-webkit-outer-spin-button,
.cart-qty-ctrl input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.cart-remove-btn {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #999;
    font-size: 1.5rem;
    line-height: 1;
    text-decoration: none;
    transition: .25s;
}

.cart-remove-btn:hover {
    color: var(--c-rosa);
    background: var(--c-crema);
}

/* ---------- RESUMEN (CARRITO) ---------- */
.carrito-resumen,
.resumen-compra {
    background: #fff;
    border: 1px solid var(--c-borde);
    border-radius: var(--c-radio);
    padding: clamp(20px, 3vw, 30px);
    box-shadow: var(--c-sombra);
    position: sticky;
    top: 24px;
}

.carrito-resumen h3,
.resumen-compra h3 {
    margin: 0 0 20px;
    padding-bottom: 14px;
    font-size: 1.2rem;
    color: var(--c-texto);
    border-bottom: 1px solid #eee;
}

.resumen-linea,
.linea-resumen {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    color: #555;
    font-size: 1rem;
}

.resumen-total,
.linea-resumen.total {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 20px;
    padding-top: 18px;
    border-top: 2px solid #eee;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--c-texto);
}

.resumen-total span:last-child,
.linea-resumen.total span:last-child {
    color: var(--c-rosa);
}

.btn-checkout-cart {
    display: block;
    width: 100%;
    margin-top: 26px;
    padding: 15px;
    background: var(--c-rosa);
    color: #fff;
    text-align: center;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.05rem;
    border-radius: 999px;
    transition: background .3s, transform .2s;
}

.btn-checkout-cart:hover {
    background: color-mix(in srgb, var(--c-rosa) 82%, #000);
    transform: translateY(-2px);
}

/* ---------- MINI LISTA (CHECKOUT) ---------- */
.mini-lista-productos {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 4px;
}

.mini-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mini-item img {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #eee;
}

.mini-info { min-width: 0; font-size: .9rem; }
.mini-info span { color: #888; font-size: .8rem; }
.mini-info p { margin: 2px 0; color: #333; line-height: 1.25; }
.mini-info strong { color: var(--c-rosa); }

/* =========================================
   CHECKOUT (3 PASOS)
   ========================================= */
.checkout-pasos {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.progress-bar {
    isolation: isolate;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 44px;
    padding: 0 10px;
}

.step {
    position: relative;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    color: #aaa;
}

.step::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #ddd;
    transition: .3s;
}

.step span {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: .82rem;
    font-weight: 500;
    color: #999;
}

.step.active { color: #fff; }
.step.active::before { background: var(--c-rosa); border-color: var(--c-rosa); }
.step.active span { color: var(--c-rosa); }

.step-line {
    flex: 1;
    height: 0;
    margin: 0 12px;
    border-top: 2px dashed #ddd;
}

.checkout-section {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: var(--c-radio);
    transition: .3s;
}

.checkout-section.active {
    border-color: var(--c-rosa);
    box-shadow: var(--c-sombra);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 28px;
    background: #fdfdfd;
    border-bottom: 1px solid #eee;
    border-radius: var(--c-radio) var(--c-radio) 0 0;
}

.step-number {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border: 1px solid #999;
    border-radius: 50%;
    color: #666;
    font-weight: 700;
}

.checkout-section.active .step-number {
    border-color: var(--c-rosa);
    background: var(--c-rosa);
    color: #fff;
}

.section-header h2 {
    flex: 1;
    margin: 0;
    font-size: 1.25rem;
    color: #999;
}

.checkout-section.active .section-header h2 { color: var(--c-texto); }

.btn-edit {
    display: none;
    padding: 6px 14px;
    background: #f4f4f4;
    border: 1px solid #ddd;
    border-radius: 6px;
    color: #333;
    cursor: pointer;
    font-size: .85rem;
}

.checkout-section.completed:not(.active) .btn-edit { display: block; }
.checkout-section:not(.active) .section-content { display: none; }

.section-summary {
    display: none;
    padding: 14px 28px 18px 72px;
    color: #666;
    font-size: .95rem;
    line-height: 1.5;
}

.checkout-section.completed:not(.active) .section-summary { display: block; }

.section-content { padding: 28px; }

.txt-muted {
    margin: 0 0 22px;
    color: #666;
    font-size: .95rem;
}

.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    margin-bottom: 7px;
    font-size: .9rem;
    font-weight: 600;
    color: #555;
}

.form-control {
    width: 100%;
    padding: 13px 15px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem; /* 16px: evita el zoom automático en iPhone */
    transition: .25s;
}

.form-control:focus {
    border-color: var(--c-rosa);
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-rosa) 15%, transparent);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.btn-continuar,
.btn-step {
    display: inline-block;
    padding: 13px 36px;
    background: var(--c-rosa);
    color: #fff;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    transition: transform .2s, opacity .2s;
}

.btn-step { width: auto; margin-top: 8px; }
.btn-continuar:hover,
.btn-step:hover { transform: translateY(-2px); opacity: .92; }

.delivery-tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.d-tab input { display: none; }

.d-tab-btn {
    display: block;
    padding: 12px 28px;
    border: 1px solid #ccc;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
    color: #666;
    text-align: center;
    transition: .25s;
}

.d-tab input:checked + .d-tab-btn {
    background: var(--c-rosa);
    border-color: var(--c-rosa);
    color: #fff;
}

.step-actions {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
}

.btn-back {
    background: none;
    border: none;
    color: #666;
    text-decoration: underline;
    cursor: pointer;
    font-size: 1rem;
}

.comprobante-options {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.comprobante-options label {
    flex: 1 1 140px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: .2s;
}

.comprobante-options input { accent-color: var(--c-rosa); }

.comprobante-options label:has(input:checked) {
    border-color: var(--c-rosa);
    background: var(--c-crema);
}

#wallet_container { min-height: 60px; }

/* Accesibilidad: foco visible con teclado */
.contenedor-carrito a:focus-visible,
.contenedor-carrito button:focus-visible,
.contenedor-carrito input:focus-visible {
    outline: 2px solid var(--c-rosa);
    outline-offset: 2px;
}

/* =========================================
   RESPONSIVE
   ========================================= */

/* Laptops pequeñas */
@media (max-width: 1100px) {
    .layout-carrito { grid-template-columns: minmax(0, 1fr) 320px; }
    .layout-checkout { grid-template-columns: minmax(0, 1fr) 340px; }
    .carrito-header-row,
    .carrito-item-row { padding-left: 16px; padding-right: 16px; column-gap: 10px; }
}

/* Tablets: el resumen baja */
@media (max-width: 900px) {
    .layout-carrito,
    .layout-checkout { grid-template-columns: 1fr; }

    .carrito-resumen,
    .resumen-compra { position: static; }
}

/* Móviles: cada producto es una tarjeta */
@media (max-width: 700px) {
    .carrito-header-row { display: none; }

    .carrito-item-row {
        position: relative;
        grid-template-columns: 1fr auto;
        row-gap: 12px;
        padding: 16px;
    }

    .cart-product-info {
        grid-column: 1 / -1;
        padding-right: 36px;
        gap: 14px;
    }

    .cart-product-info img { width: 72px; height: 72px; }

    .cart-price-val {
        grid-column: 1 / -1;
        display: flex;
        justify-content: space-between;
        text-align: left;
        font-size: .95rem;
        font-weight: 600;
        color: #333;
    }

    .cart-price-val::before {
        content: "Precio unitario";
        color: #888;
        font-weight: 500;
    }

    .cart-qty-ctrl { justify-content: flex-start; }

    .cart-qty-ctrl button { width: 38px; height: 38px; }

    .cart-subtotal-val { text-align: right; font-size: 1.15rem; }

    .cart-subtotal-val::before {
        content: "Total";
        display: block;
        font-size: .7rem;
        font-weight: 500;
        letter-spacing: .5px;
        text-transform: uppercase;
        color: #999;
    }

    .cart-remove-btn {
        position: absolute;
        top: 10px;
        right: 10px;
    }

    .section-header { padding: 16px 18px; }
    .section-content { padding: 20px 18px; }
    .section-summary { padding: 12px 18px 16px; }
    .section-header h2 { font-size: 1.1rem; }
}

/* Móviles pequeños */
@media (max-width: 600px) {
    .form-row { grid-template-columns: 1fr; gap: 0; }

    .progress-bar { margin-bottom: 28px; padding: 0; }
    .step span { display: none; }

    .delivery-tabs .d-tab { flex: 1; }
    .d-tab-btn { padding: 12px 8px; }

    .step-actions { flex-direction: column-reverse; align-items: stretch; gap: 10px; }
    .step-actions .btn-continuar,
    .step-actions .btn-step,
    .btn-step { width: 100%; text-align: center; }
    .btn-back { padding: 10px; }
}

@media (max-width: 380px) {
    .cart-product-info img { width: 60px; height: 60px; }
    .cart-product-info h3 { font-size: .92rem; }
    .carrito-resumen,
    .resumen-compra { padding: 18px; }
}