/* Asegurar footer abajo: layout de columna y que .cart-page crezca */
html,
body {
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* El contenido principal (carrito) debe ocupar el espacio disponible */
.cart-page {
    flex: 1 0 auto;
}

/* Estilos para el footer (mejorar presencia y evitar que se vea "subido") */
footer {
    margin-top: 40px;
    padding: 28px 0;
    background: #222;
    color: #fff;
    text-align: center;
    flex-shrink: 0;
}

/* Estilos específicos para carrito (mantener el estilo global en styles.css) */
.cart-page {
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 20px;
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.cart-left {
    flex: 1;
}

.cart-right {
    width: 360px;
    position: sticky;
    top: 100px;
}

h1.cart-title {
    font-size: 32px;
    margin-bottom: 10px;
    color: #111;
}

.note {
    color: #444;
    margin: 10px 0 20px;
    font-size: 14px;
    line-height: 1.5;
}

.cart-item {
    display: flex;
    gap: 18px;
    background: #fff;
    border: 1px solid #e6e6e6;
    padding: 16px;
    border-radius: 6px;
    margin-bottom: 12px;
    align-items: center;
}

.cart-item img {
    width: 120px;
    height: 100px;
    object-fit: contain;
    background: white;
    border-radius: 6px;
    flex-shrink: 0;
}

.item-info {
    flex: 1;
    min-width: 0;
}

.item-title {
    font-weight: 700;
    color: #111;
    margin-bottom: 6px;
    font-size: 16px;
}

.item-meta {
    color: #666;
    font-size: 14px;
    margin-bottom: 8px;
}

.qty-box {
    display: flex;
    align-items: center;
    gap: 8px;
}

.qty-btn {
    width: 34px;
    height: 34px;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 18px;
    transition: all 0.2s;
}

.qty-btn:hover {
    background: #f5f5f5;
    border-color: #999;
}

.qty-btn:active {
    transform: scale(0.95);
}

.qty-input {
    width: 48px;
    text-align: center;
    border: 1px solid #ddd;
    height: 34px;
    border-radius: 4px;
    font-weight: 600;
}

.remove-btn {
    background: transparent;
    border: 0;
    color: #333;
    cursor: pointer;
    font-size: 18px;
    padding: 8px;
    transition: color 0.2s;
}

.remove-btn:hover {
    color: #ff4444;
}

.recommendations {
    margin-top: 24px;
}

.rec-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.rec-card {
    background: #fff;
    border: 1px solid #eee;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

.rec-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.rec-card img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    background: #f4f4f4;
    border-radius: 4px;
    min-height: 100px;
    /* reserva espacio para evitar reflow/parpadeo */
    display: block;
    transition: opacity 260ms ease;
    /* suaviza la aparición */
    opacity: 0;
    /* se pondrá a 1 desde JS al cargarse */
}

.summary {
    background: #fff;
    border: 1px solid #e6e6e6;
    padding: 20px;
    border-radius: 6px;
}

.summary.small {
    display: none;
}

.summary h3 {
    margin: 0 0 12px 0;
    font-size: 18px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin: 8px 0;
    color: #222;
    font-size: 15px;
}

.summary-total {
    font-weight: 900;
    font-size: 1.1rem;
}

.pay-btn {
    display: block;
    width: 100%;
    background: #000;
    color: #fff;
    padding: 14px;
    text-align: center;
    border: 0;
    cursor: pointer;
    margin-top: 12px;
    text-transform: uppercase;
    font-weight: 700;
    transition: background 0.2s;
    border-radius: 6px;
    font-size: 15px;
}

.pay-btn:hover {
    background: #333;
}

.pay-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.pay-methods {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.pay-methods span {
    border: 1px solid #ccc;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: .9em;
    font-weight: 700;
    color: #333;
}

.footer-help {
    margin-top: 28px;
    font-size: .95rem;
    line-height: 1.6;
}

.whatsapp-link {
    color: #007a3d;
    font-weight: 700;
    text-decoration: none;
}

.whatsapp-link:hover {
    text-decoration: underline;
}

.empty {
    color: #666;
    padding: 20px;
    background: #fafafa;
    border-radius: 6px;
    border: 1px dashed #eee;
    text-align: center;
}

/* feature-row */
.feature-row {
    display: flex;
    align-items: center;
    margin-top: 18px;
    font-weight: 700;
    font-size: 14px;
}

.feature-row i {
    font-size: 1.1em;
    margin-right: 8px;
    color: #222;
}

.feature-row span {
    border-bottom: 1px solid #000;
    text-decoration: none;
}

/* payment form */
#payment-section {
    background: #fff;
    padding: 20px;
    border-radius: 6px;
    border: 1px solid #e6e6e6;
    margin-top: 20px;
}

#payment-section h2 {
    margin-bottom: 10px;
}

#payment-section form {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#payment-section label {
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 14px;
}

#payment-section input {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 15px;
}

#payment-section button {
    padding: 12px;
    background-color: #000;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 700;
    font-size: 15px;
    margin-top: 10px;
}

#payment-section button:hover {
    background-color: #333;
}

#confirmation-section {
    background: #e8f5e9;
    padding: 30px;
    border-radius: 6px;
    text-align: center;
    margin-top: 20px;
}

#confirmation-section h2 {
    color: #2e7d32;
    margin-bottom: 10px;
}

/* Spinner/overlay */
.overlay {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, .85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.overlay .spinner {
    border: 6px solid #f3f3f3;
    border-top: 6px solid #333;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   RESPONSIVE DESIGN - TABLET
   ============================================ */
@media (max-width: 1024px) {
    .cart-page {
        padding: 0 15px;
    }

    .cart-right {
        width: 320px;
    }

    h1.cart-title {
        font-size: 28px;
    }
}

/* ============================================
   RESPONSIVE DESIGN - MÓVIL
   ============================================ */
@media (max-width: 768px) {
    .cart-page {
        flex-direction: column;
        padding: 0 12px;
        margin: 20px auto;
        gap: 20px;
    }

    .cart-left {
        width: 100%;
    }

    .cart-right {
        width: 100%;
        position: static;
        order: -1;
        /* Mueve el resumen arriba en móvil */
    }

    /* Mostrar resumen pequeño en móvil */
    .summary.small {
        display: block;
        background: #f8f8f8;
        padding: 12px 15px;
        border-radius: 6px;
        margin-bottom: 15px;
        font-size: 14px;
    }

    .summary.small strong {
        font-size: 18px;
        color: #000;
    }

    /* Resumen completo en móvil - ahora visible */
    .cart-right {
        background: #f9f9f9;
        padding: 15px;
        border-radius: 10px;
    }

    .cart-right .summary {
        padding: 15px;
    }

    .cart-right .summary h3 {
        font-size: 16px;
    }

    .summary-row {
        font-size: 14px;
    }

    .pay-btn {
        padding: 16px;
        font-size: 16px;
        font-weight: 700;
    }

    .pay-methods {
        flex-wrap: wrap;
        justify-content: center;
    }

    .footer-help {
        font-size: 14px;
        text-align: center;
    }

    h1.cart-title {
        font-size: 24px;
        margin-bottom: 8px;
    }

    .note {
        font-size: 13px;
        margin: 8px 0 15px;
    }

    /* Tarjetas de carrito en móvil */
    .cart-item {
        flex-direction: column;
        gap: 12px;
        padding: 12px;
        align-items: stretch;
    }

    .cart-item img {
        width: 100%;
        height: 180px;
        object-fit: contain;
    }

    .item-info {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .item-title {
        font-size: 15px;
    }

    .item-meta {
        font-size: 13px;
    }

    /* Controles de cantidad y eliminar en una fila */
    .item-info>div:last-child {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .qty-box {
        gap: 6px;
    }

    .qty-btn {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }

    .qty-input {
        width: 50px;
        height: 36px;
        font-size: 16px;
    }

    .remove-btn {
        font-size: 20px;
        padding: 10px;
    }

    /* Grid de recomendaciones en móvil */
    .rec-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .rec-card {
        padding: 8px;
    }

    .rec-card img {
        height: 120px;
    }

    /* Feature rows en móvil */
    .feature-row {
        font-size: 12px;
        margin-top: 12px;
    }

    .feature-row i {
        font-size: 1em;
    }

    /* Payment section en móvil */
    #payment-section {
        padding: 15px;
        margin-top: 15px;
    }

    #payment-section h2 {
        font-size: 20px;
    }

    #payment-section input {
        font-size: 16px;
        /* Evita zoom en iOS */
    }

    #confirmation-section {
        padding: 20px;
    }

    /* Botón de pago flotante en móvil */
    .mobile-checkout {
        display: block;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        padding: 12px 15px;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        z-index: 100;
    }

    .mobile-checkout .pay-btn {
        margin: 0;
        padding: 16px;
        font-size: 16px;
    }

    /* Espacio extra al final para el botón flotante */
    .cart-left {
        padding-bottom: 80px;
    }
}

/* ============================================
   RESPONSIVE DESIGN - MÓVIL PEQUEÑO
   ============================================ */
@media (max-width: 480px) {
    .cart-page {
        padding: 0 10px;
        margin: 15px auto;
    }

    h1.cart-title {
        font-size: 22px;
    }

    .cart-item img {
        height: 160px;
    }

    .item-title {
        font-size: 14px;
    }

    .rec-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .rec-card img {
        height: 100px;
    }

    .feature-row {
        font-size: 11px;
    }

    #payment-section {
        padding: 12px;
    }

    #payment-section h2 {
        font-size: 18px;
    }
}

/* ============================================
   MEJORAS TÁCTILES PARA MÓVIL
   ============================================ */
@media (hover: none) and (pointer: coarse) {

    /* Aumentar área táctil en botones */
    .qty-btn,
    .remove-btn,
    .rec-card {
        min-height: 44px;
        /* Tamaño mínimo recomendado por Apple */
        min-width: 44px;
    }

    /* Mejorar feedback táctil */
    .qty-btn:active,
    .remove-btn:active,
    .rec-card:active,
    .pay-btn:active {
        opacity: 0.7;
    }
}