/* ==========================================
   1. ESTRUCTURA PRINCIPAL DEL CARRITO
   ========================================== */
.cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.cart-overlay.open {
    opacity: 1;
    visibility: visible;
}

#cart-drawer {
    position: fixed;
    top: 0;
    right: -400px;
    width: 100%;
    max-width: 380px;
    height: 100vh;
    background-color: #ffffff;
    z-index: 99999;
    box-shadow: -5px 0 15px rgba(0,0,0,0.1);
    transition: right 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
}

#cart-drawer.open {
    right: 0;
}

/* ==========================================
   2. CABECERA DEL CARRITO
   ========================================== */
.cart-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.cart-drawer-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.close-cart-btn {
    background: none;
    border: 1px solid #ccc;
    font-size: 16px;
    cursor: pointer;
    border-radius: 4px;
    padding: 2px 8px;
}

#cart-drawer-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden; /* Evita que el contenedor principal haga scroll */
}

/* ==========================================
   3. LISTA DE PRODUCTOS
   ========================================== */
.cart-drawer-list {
    list-style: none !important; /* Elimina la viñeta negra (el punto) */
    padding: 0;
    margin: 0;
    flex: 1;
    overflow-y: auto; /* Permite scroll solo en la lista de productos */
}

/* Contenedor de cada producto (Alineación horizontal) */
.cart-drawer-item {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;
}

/* Agrupa la imagen y los detalles (Alineación horizontal) */
.cart-item-info {
    display: flex !important;
    align-items: center !important;
    gap: 15px !important;
    flex: 1;
}

/* Imagen del producto */
.cart-item-image img {
    width: 60px !important;
    height: 60px !important;
    object-fit: cover;
    border-radius: 4px;
    margin: 0 !important; /* Evita márgenes indeseados */
}

/* Detalles: Título, cantidad y precio (Alineación vertical) */
.cart-item-details {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.cart-item-title {
    margin: 0 !important;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
}

.cart-item-qty {
    font-size: 12px;
    color: #666;
}

.cart-item-price {
    font-size: 14px;
    font-weight: 700;
}

/* ==========================================
   4. BOTÓN ELIMINAR (Basurero)
   ========================================== */
.remove-cart-item {
    display: flex !important;
    align-items: center;
    justify-content: center;
    background-color: #fff0f0;
    border: 1px solid #ffcccc;
    color: #e53935;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    transition: background-color 0.2s;
    text-decoration: none;
    margin-left: 10px;
}

.remove-cart-item:hover {
    background-color: #e53935;
    color: #fff;
}

.remove-cart-item svg {
    width: 16px;
    height: 16px;
}

/* ==========================================
   5. FOOTER (Total y Botón Pagar)
   ========================================== */
.cart-drawer-footer {
    padding: 20px;
    background-color: #f9f9f9;
    border-top: 1px solid #eee;
}

.cart-drawer-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 16px;
    margin-bottom: 15px;
}

.total-price {
    font-weight: 700;
    font-size: 18px;
}

.checkout-button {
    display: block;
    width: 100%;
    background-color: #000;
    color: #fff;
    text-align: center;
    padding: 15px;
    font-weight: 700;
    text-decoration: none;
    border-radius: 4px;
    box-sizing: border-box; /* Asegura que no se desborde */
}

.checkout-button:hover {
    background-color: #333;
    color: #fff;
}


/* Quitar el punto negro y el espacio sobrante de la lista */
.cart-items-list {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Poner la imagen y el texto en la misma línea */
.cart-item {
    display: flex !important;
    align-items: center !important;
    padding: 15px 20px !important;
    border-bottom: 1px solid #eee;
}

/* Ajustar la imagen */
.cart-item img {
    margin-right: 0px !important;
    border-radius: 4px;
}

/* Ajustar los textos (Título y Cantidad) */
.cart-item-details {
    display: flex;
    flex-direction: column;
}

.cart-item-details h4 {
    margin: 0 0 5px 0 !important;
    font-size: 14px;
    font-weight: bold;
    line-height: 1.2;
}

.cart-item-details p {
    margin: 0 !important;
    font-size: 13px;
    color: #666;
}

/* Diseñar el espacio del botón de pago */
.cart-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    background-color: #fafafa;
}

/* Devolver el color negro y forma al botón de pago */
.btn-checkout {
    display: block !important;
    background-color: #000 !important;
    color: #fff !important;
    text-align: center !important;
    padding: 15px !important;
    text-decoration: none !important;
    font-weight: bold !important;
    border-radius: 5px !important;
    width: 100%;
    box-sizing: border-box;
}

.btn-checkout:hover {
    background-color: #333 !important;
    color: #fff !important;
}



/* Contenedor principal del producto: Separa lados izquierdo y derecho */
.cart-item {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 15px 20px !important;
    border-bottom: 1px solid #eee;
}

/* Agrupa la imagen y los textos a la izquierda */
.cart-item-info {
    display: flex !important;
    align-items: center !important;
}

.cart-item-info img {
    width: 80px;
    height: auto;
    margin-right: 15px;
    border-radius: 4px;
}

/* Textos (Título, Cantidad, Precio) */
.cart-item-details {
    display: flex;
    flex-direction: column;
}

.cart-item-details h4 {
    margin: 0 0 4px 0 !important;
    font-size: 14px;
    font-weight: bold;
    line-height: 1.2;
}

.cart-item-details p {
    margin: 0 !important;
    font-size: 12px;
    color: #666;
}

/* Estilo del Precio */
.cart-item-price {
    font-weight: 800 !important;
    color: #111 !important;
    font-size: 14px !important;
    margin-top: 4px !important;
}

/* Botón del Basurero a la derecha */
.remove-cart-item {
    background-color: #fff0f0;
    border: 1px solid #ffcccc;
    color: #e53935;
    border-radius: 6px;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    text-decoration: none;
}

.remove-cart-item:hover {
    background-color: #e53935;
    color: #fff;
}



/* ==========================================
   6. RESPONSIVE / MOBILE DESIGN (Añadir al final de cart-drawer (4).css)
   ========================================== */
@media (max-width: 768px) {
    #cart-drawer {
        /* Desactivar el posicionamiento lateral de escritorio */
        top: auto;
        right: 0 !important; 
        
        /* Configurar el cajón para que salga desde abajo */
        bottom: -100%;
        width: 100%;
        max-width: 100%;
        height: 80vh; /* Ocupará el 80% del alto de la pantalla */
        border-radius: 20px 20px 0 0; /* Bordes redondeados arriba para mejor estética */
        
        /* Animación de entrada y salida vertical */
        transition: bottom 0.3s ease-in-out;
    }

    #cart-drawer.open {
        /* Posición final cuando se abre el carrito */
        bottom: 0;
    }
}