/* ============================================= */
/* == DEFINICIÓN DE COLORES PARA TEMAS == */
/* ============================================= */

:root {
  /* TEMA CLARO (POR DEFECTO) */
  --color-fondo: #ffffff;
  --color-texto: #212529;
  --color-texto-secundario: #6c757d;
  --color-tarjeta-fondo: #FFFFFF;
  --color-borde: #dee2e6;
  --color-borde-claro: #eee;
  --color-sutil: rgba(0, 0, 0, 0.04);
  --color-sombra: rgba(0,0,0,0.1);
}

[data-theme="dark"] {
  /* TEMA OSCURO */
  --color-fondo: #121212;
  --color-texto: #E0E0E0;
  --color-texto-secundario: #040505;
  --color-tarjeta-fondo: #1E1E1E;
  --color-borde: #444444;
  --color-borde-claro: #333333;
  --color-sutil: rgba(255, 255, 255, 0.05);
  --color-sombra: rgba(255,255,255,0.05);
}

/* --- ESTILOS GENERALES --- */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--color-fondo);
    color: var(--color-texto);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ========================================================== */
/* --- CARRITO (OFFCANVAS) --- */
/* ========================================================== */

/* ✅ FIX — el offcanvas-body necesita una altura fija (100% del
   offcanvas) para que el flex-column interno (#cart-items con
   flex-grow-1 + .cart-footer con mt-auto) pueda repartirse el
   espacio correctamente. Sin esto, el contenedor crece con el
   contenido en vez de quedarse fijo, y nada tiene de dónde hacer
   scroll interno — por eso el footer "flotaba" en medio de los
   productos al meter más de 5 items. */
.offcanvas-header { 
    justify-content: space-between; 
}

.offcanvas-body { 
    padding: 0; 
    height: 100%;
    overflow: hidden;
}

/* ✅ FIX — antes tenía 'height:100%' (choca con flex-grow-1 del HTML)
   y NO tenía overflow-y:auto, así que la lista nunca scrolleaba
   internamente: todo el offcanvas se desbordaba en bloque, arrastrando
   al footer fuera de su posición fija. Ahora #cart-items scrollea
   solo, y .cart-footer (mt-auto) se queda siempre pegado abajo. */
#cart-items { 
    list-style: none; 
    margin-bottom: 0; 
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0;
}

/* --- NUEVO DISEÑO CART ITEM --- */
.cart-item {
    display: flex;
    flex-direction: row;
    padding: 1rem;
    border-bottom: 1px solid var(--color-borde-claro);
    gap: 0.75rem;
    background-color: var(--color-tarjeta-fondo);
}

/* Imagen grande a la izquierda */
.cart-item img {
    width: 90px;
    height: 90px;
    object-fit: contain;
    border-radius: 8px;
    flex-shrink: 0;
    background-color: var(--color-sutil);
}

/* Contenido derecho: todo en columna */
.cart-item-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

/* Nombre del producto */
.cart-item-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-texto);
    line-height: 1.3;
    white-space: normal;
    margin: 0;
}

/* Precio */
.cart-item-price-row {
    font-size: 0.88rem;
    color: var(--color-texto-secundario);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.cart-item-price-row .price-original {
    text-decoration: line-through;
    color: var(--color-texto-secundario);
}

.cart-item-price-row .price-final {
    font-weight: 700;
    color: #dc2626;
}

.cart-item-price-row .price-normal {
    font-weight: 700;
    color: var(--color-texto);
}

.cart-item-price-row .price-unit {
    color: var(--color-texto-secundario);
}

/* Ciudad */
.cart-item-ciudad {
    font-size: 0.78rem;
    color: var(--color-texto-secundario);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* Separador antes de "En carro" */
.cart-item-controls-area {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--color-borde-claro);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cart-item-en-carro {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.cart-item-en-carro .en-carro-label {
    font-size: 0.72rem;
    color: var(--color-texto-secundario);
    font-weight: 400;
}

.cart-item-en-carro .en-carro-cantidad {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-texto);
}

/* Botones de cantidad */
.cart-item .button-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.cart-item .btn-quantity {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.cart-item .btn-quantity[data-delta="1"],
.cart-item .btn-quantity[data-delta="-1"] {
    background-color: #F7C044;
    color: #333;
}

.cart-item .btn-quantity[data-delta="1"]:hover,
.cart-item .btn-quantity[data-delta="-1"]:hover {
    opacity: 0.85;
}

.cart-footer { 
    padding: 1rem; 
    background-color: var(--color-tarjeta-fondo); 
    border-top: 1px solid var(--color-borde-claro); 
    flex-shrink: 0;
}

.dropdown-toggle::after { 
    display: none; 
}

.offcanvas-header .btn-close { 
    padding: 0; 
    margin: 0; 
}

/* --- ESTILOS PARA MENSAJE DE CARRITO VACÍO CON ÍCONO SVG --- */
.empty-cart-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 2rem;
}

.empty-cart-icon {
    width: 120px;
    height: 120px;
    stroke: var(--color-borde);
    stroke-width: 1.5;
    margin-bottom: 1.5rem;
}

.empty-cart-container h4 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--color-texto);
    margin: 0 0 0.5rem 0;
}

.empty-cart-container p {
    font-size: 1rem;
    color: var(--color-texto-secundario);
    margin: 0;
}

/* ========================================================== */
/* --- CARRUSEL DE HOME --- */
/* ========================================================== */
.carousel,
.carousel-inner {
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.carousel-inner img {
    width: 100%;
    height: auto;
    object-fit: cover;
    display: block;
}

/* ========================================================== */
/* ✅ CORRECCIÓN PARA MÓVILES */
/* ========================================================== */

@media (max-width: 768px) {
    .carousel,
    .carousel-inner {
        border-radius: 12px;
    }
    
    .carousel-item {
        height: 180px;
    }
    
    .carousel-item img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center;
    }
}

@media (max-width: 576px) {
    .carousel,
    .carousel-inner {
        border-radius: 10px;
        max-height: 120px;
    }
    
    .carousel-item {
        height: 120px;
        max-height: 120px;
    }
    
    .carousel-item img {
        width: 100%;
        height: 100%;
        max-height: 120px;
        object-fit: contain;
        object-position: center;
        background-color: #f8f9fa;
    }

    .carousel-control-prev-icon,
    .carousel-control-next-icon {
        width: 1.5rem;
        height: 1.5rem;
    }
    
    .carousel-indicators [data-bs-target] {
        width: 8px;
        height: 8px;
    }
}

@media (max-width: 400px) {
    .carousel,
    .carousel-inner {
        border-radius: 8px;
        max-height: 100px;
    }
    
    .carousel-item {
        height: 100px;
        max-height: 100px;
    }
    
    .carousel-item img {
        width: 100%;
        height: 100%;
        max-height: 100px;
        object-fit: contain;
        object-position: center;
        background-color: #f8f9fa;
    }
}

@media (max-width: 360px) {
    .carousel,
    .carousel-inner {
        max-height: 90px;
    }
    
    .carousel-item {
        height: 90px;
        max-height: 90px;
    }
    
    .carousel-item img {
        width: 100%;
        height: 100%;
        max-height: 90px;
        object-fit: contain;
        object-position: center;
        background-color: #f8f9fa;
    }
}

/* ========================================================== */
/* == BOTÓN FINALIZAR COMPRA + SWEETALERT PEDIDO MÍNIMO == */
/* ========================================================== */

/* Botón verde — aplica tanto por clase como por ID */
.btn-finalizar-carrito,
#btn-finalizar-compra {
    background-color: #249F5F !important;
    color: #fff !important;
    border: none !important;
    border-radius: 4px !important;
    font-weight: 500 !important;
    padding: .5rem 1rem !important;
    transition: background-color 0.2s ease !important;
    text-decoration: none !important;
    display: block !important;
    text-align: center !important;
    cursor: pointer !important;
    font-size: 1rem !important;
}

.btn-finalizar-carrito:hover,
#btn-finalizar-compra:hover {
    background-color: #26b879 !important;
    color: #fff !important;
}

.btn-finalizar-carrito:focus,
.btn-finalizar-carrito:focus-visible,
.btn-finalizar-carrito:active,
#btn-finalizar-compra:focus,
#btn-finalizar-compra:focus-visible,
#btn-finalizar-compra:active {
    background-color: #26b879 !important;
    color: #fff !important;
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

/* Override global SweetAlert2 — botón confirmar */
.swal2-confirm {
    border-radius: 4px !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.swal2-confirm:focus {
    box-shadow: none !important;
    outline: none !important;
}

/* SweetAlert pedido mínimo */
.swal-minimo-popup {
    border-radius: 16px !important;
    padding: 2rem 1.5rem 1.75rem !important;
    max-width: 400px !important;
}

.swal-minimo-actions {
    margin-top: 1.25rem !important;
    width: 100% !important;
    padding: 0 !important;
}

.swal-minimo-confirm {
    background-color: #249F5F !important;
    color: #fff !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    border-radius: 4px !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    padding: .7rem 1rem !important;
    width: 100% !important;
    cursor: pointer !important;
    transition: background-color .2s ease !important;
    font-family: inherit !important;
}

.swal-minimo-confirm:hover,
.swal-minimo-confirm:focus,
.swal-minimo-confirm:active {
    background-color: #26b879 !important;
    color: #fff !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}