/* 
==============================================
Hoja de Estilos Responsivos para FullFit
==============================================
*/

/* 
----------------------------------------------
Punto de quiebre para Tablets y dispositivos medianos (hasta 992px)
----------------------------------------------
*/
@media (max-width: 991.98px) {
    /* --- Navbar --- */
    .navbar-collapse {
        background: rgba(33, 37, 41, 0.98);
        padding: 1rem;
        margin: 0.5rem 0;
        border-radius: 0.5rem;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    }
    
    .nav-search {
        width: 100%;
        margin: 1rem 0;
    }

    .navbar-nav {
        align-items: center;
    }

    .nav-link {
        text-align: center;
        padding: 0.8rem 1rem !important;
        width: 100%;
    }

    /* --- Hero Section --- */
    .hero h1, .hero-title {
        font-size: 3.5rem;
    }

    .hero .lead {
        font-size: 1.4rem;
    }

    /* --- Footer --- */
    .footer .text-md-end {
        text-align: center !important;
        margin-top: 1rem;
    }
}

/* 
----------------------------------------------
Punto de quiebre para Móviles (hasta 768px)
----------------------------------------------
*/
@media (max-width: 767.98px) {
    /* --- Global --- */
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }

    body {
        padding-top: 60px; /* Espacio para la navbar fija */
    }

    .container, .container-fluid {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }

    h2 {
        font-size: 1.8rem;
    }

    /* --- Navbar --- */
    .navbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        padding: 10px 0;
        z-index: 1030;
    }

    .navbar-brand {
        font-size: 1.3rem;
    }

    .navbar-toggler {
        font-size: 1.3rem;
    }

    /* --- Carrito Móvil --- */
    .mobile-cart {
        display: flex !important;
        position: relative;
        background: transparent;
        color: white;
        width: auto;
        height: auto;
        box-shadow: none;
        cursor: pointer;
        font-size: 1.4rem;
        margin-right: 1rem; /* Aumentado el espacio a la derecha */
    }

    .mobile-cart i {
        font-size: 1.2rem; /* Ligeramente más grande para mejor visibilidad */
    }

    .mobile-cart .cart-badge {
        position: absolute;
        top: -8px;      /* Ajustado para el nuevo tamaño */
        right: -8px;    /* Ajustado para el nuevo tamaño */
        font-size: 0.65rem; /* Tamaño de fuente más pequeño */
        padding: 0.15rem 0.4rem; /* Padding reducido */
        min-width: 18px; /* Ancho mínimo */
        height: 18px;    /* Altura */
        background: white;
        color: var(--primary-color);
        border: 1px solid var(--primary-color); /* Borde más fino */
        font-weight: bold;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* 🔵 2️⃣ HERO SECTION REDUCIDO PARA MÓVIL - Liberar espacio para productos */
    .hero {
        height: auto;
        min-height: 15vh; /* Reducido aún más para liberar espacio */
        padding: 20px 0 30px 0; /* Padding reducido */
        display: flex;
        align-items: center;
        margin-top: 0;
    }
    
    .hero h1, .hero-title {
        font-size: 2.5rem;
        margin-bottom: 1.5rem;
    }
    
    .hero .lead {
        font-size: 1.1rem;
        margin-bottom: 2rem;
    }
    
    .hero .btn-primary, .hero .btn-outline-light {
        padding: 0.8rem 1.5rem;
        font-size: 0.9rem;
        width: 100%;
        margin-bottom: 10px;
    }

    .hero .d-flex.gap-3 {
        flex-direction: column;
    }
    
    .hero-background {
        object-position: 65% center; /* Centra la parte más interesante de la imagen */
    }

    .hero .col-md-3 {
        width: 50%;
    }

    /* 🔵 1️⃣ PRODUCTOS EN FILAS DE 2 COLUMNAS EN MÓVIL */
    #productsGrid {
        display: grid !important;
        grid-template-columns: 1fr 1fr; /* 2 columnas iguales */
        gap: 15px; /* Espacio entre productos */
        margin-top: 20px;
    }

    #productsGrid .col-md-4 {
        width: 100% !important;
        margin-bottom: 0 !important;
        padding: 0 !important;
    }

    /* Ajustar tarjetas de producto para móvil */
    .product-card {
        font-size: 0.9rem;
    }

    .product-card .card-title {
        font-size: 1rem;
        line-height: 1.2;
        margin-bottom: 0.5rem;
    }

    .product-card .card-text {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }

    .product-card .card-body {
        padding: 0.8rem;
    }

    /* 🔵 2️⃣ BOTONES SIEMPRE VISIBLES EN MÓVIL */
    /* Eliminar efectos hover en móvil y mostrar botones siempre */
    .product-overlay {
        position: static !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        background: none !important;
        padding: 0 !important;
        margin: 0 !important;
        height: auto !important;
        min-height: auto !important;
        display: block !important;
    }

    .product-overlay .text-center {
        background: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
    }

    .product-overlay .text-center i {
        display: none !important; /* Ocultar ícono en móvil */
    }

    .product-overlay .text-center p {
        display: none !important; /* Ocultar texto explicativo en móvil */
    }

    .product-overlay .btn {
        position: static !important;
        width: 100% !important;
        margin: 0.5rem 0 0 0 !important;
        padding: 0.5rem 0.8rem !important;
        font-size: 0.85rem !important;
        border-radius: 20px !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
    }

    /* Agregar botones directamente en el card-body para móvil */
    .product-card .card-body::after {
        content: '';
        display: block;
        margin-top: 0.5rem;
    }

    /* ============================================= */
    /* 🔹 1. BARRA DE FILTROS Y BÚSQUEDA (MÓVIL)    */
    /* ============================================= */

    /* Contenedor principal de la barra de filtros */
    .filter-bar {
        padding: 1rem !important;
        margin-bottom: 1rem !important;
        border-radius: 12px !important; /* Bordes más suaves */
        gap: 0.8rem !important; /* Espacio entre elementos */
        overflow-x: visible !important;
    }

    .filter-bar .d-flex {
        flex-direction: column !important; /* Apilar verticalmente en móvil */
        width: 100% !important;
        gap: 0.8rem !important;
    }

    /* Estilo mejorado para la barra de búsqueda */
    .filter-bar .search-compact {
        width: 100% !important;
        order: 1; /* La búsqueda siempre primero */
    }

    .filter-bar .search-compact .input-group {
        border: 1px solid #dee2e6;
        border-radius: 25px; /* Bordes redondeados */
        padding: 0.2rem;
        background-color: #fff;
        transition: box-shadow 0.2s ease-in-out;
    }

    .filter-bar .search-compact .input-group:focus-within {
        box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25); /* Efecto de foco */
        border-color: #80bdff;
    }

    .filter-bar .search-compact .form-control {
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
        padding-left: 1rem;
    }

    .filter-bar .search-compact .btn {
        border-radius: 50% !important; /* Botón de búsqueda circular */
        width: 38px;
        height: 38px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .filter-bar .btn-group {
        flex-shrink: 1 !important;
        order: 2;
        flex-wrap: wrap !important;
        gap: 0.3rem !important;
    }

    .filter-bar .btn-group .btn,
    .filter-bar .dropdown-toggle {
        font-size: 0.85rem !important;
        padding: 0.4rem 0.8rem !important;
        border-radius: 16px !important;
        margin: 0 !important;
        white-space: nowrap !important;
    }

    .filter-bar .form-select {
        font-size: 0.85rem !important;
        padding: 0.4rem 0.8rem !important;
        width: auto !important;
        min-width: 120px !important;
        order: 3;
        flex-shrink: 1 !important;
    }

    .filter-bar .ms-auto {
        margin-left: 0 !important;
        width: 100% !important;
        justify-content: space-between !important;
    }

/* Ajustar el selector de ordenamiento para evitar superposición */
.filter-bar .position-relative > #sortBy {
    padding-right: 2.8rem !important; /* Aumentar padding-right para dar más espacio al ícono */
}

    /* --- Categorías --- */
    .category-card {
        margin-bottom: 1.5rem;
        min-height: 250px;
    }

    /* --- Call to Action (CTA) --- */
    .cta {
        text-align: center;
    }

    .cta .text-lg-end {
        text-align: center !important;
        margin-top: 1.5rem;
    }

    /* Ajuste para el texto del CTA en móviles */
    .cta p.lead {
        font-size: 1rem; /* Reducir tamaño de fuente del párrafo */
    }

    /* --- Products Header --- */
    .products-header h1 {
        font-size: 2.2rem; /* Ajustar tamaño de fuente del título principal */
    }
    .products-header p.lead {
        font-size: 1rem; /* Ajustar tamaño de fuente del párrafo */
    }
    /* 🔵 2️⃣ HEADER DE PRODUCTOS MÁS COMPACTO - Productos visibles apenas se entra */
    .products-header {
        margin-top: 0 !important;
        padding-top: 1rem !important; /* Aún más reducido */
        padding-bottom: 0.5rem !important; /* Mínimo padding */
    }

    /* Ocultar o reducir el mensaje de scroll para acercar productos a filtros */
    .scroll-down-indicator {
        display: none !important; /* Eliminar completamente para liberar espacio */
    }

    /* 🔵 3️⃣ MODAL DE DETALLE DE PRODUCTO OPTIMIZADO PARA MÓVIL */
    #productDetailModal .modal-dialog {
        margin: 0 !important;
        max-width: 100% !important;
        height: 100vh !important;
    }

    #productDetailModal .modal-content {
        height: 100vh !important;
        border-radius: 0 !important;
        border: none !important;
    }

    #productDetailModal .modal-body {
        padding: 1rem !important;
        overflow-y: auto !important;
        height: calc(100vh - 120px) !important; /* Restar altura del header y footer */
    }

    #productDetailModal .row {
        flex-direction: column !important;
    }

    #productDetailModal .col-md-6 {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Imagen más pequeña en móvil */
    #productDetailModal .product-detail-image {
        margin-bottom: 1rem !important;
        position: relative;
    }

    #productDetailModal .product-detail-image img {
        width: 100% !important;
        max-width: 280px !important; /* Imagen más pequeña */
        height: auto !important;
        max-height: 200px !important; /* Altura máxima reducida */
        object-fit: contain !important;
        margin: 0 auto !important;
        display: block !important;
    }

    /* Aviso "Toca para ampliar" */
    #productDetailModal .product-detail-image::after {
        content: "📱 Toca para ampliar";
        position: absolute;
        bottom: 5px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0,0,0,0.7);
        color: white;
        padding: 4px 8px;
        border-radius: 12px;
        font-size: 0.75rem;
        font-weight: 500;
        z-index: 10;
        pointer-events: none;
    }

    /* Información del producto */
    #productDetailModal .product-detail-info {
        padding: 0 !important;
    }

    #productDetailModal .product-detail-info h3 {
        font-size: 1.3rem !important;
        margin-bottom: 0.8rem !important;
    }

    #productDetailModal #productDetailPrice {
        font-size: 1.5rem !important;
        margin-bottom: 1rem !important;
    }

    #productDetailModal #productDetailDescription {
        font-size: 0.9rem !important;
        line-height: 1.4 !important;
        margin-bottom: 1rem !important;
    }

    /* Selector de sabor en móvil */
    #productDetailModal #flavorSelectorContainer {
        margin-bottom: 1rem !important;
        width: 100% !important;
    }

    #productDetailModal #flavorSelectorContainer .form-select {
        width: 100% !important;
        font-size: 0.9rem !important;
    }

    /* Selector de cantidad optimizado para móvil */
    #productDetailModal .quantity-selector {
        background: #f8f9fa !important;
        border-radius: 25px !important;
        padding: 8px 16px !important;
        margin: 1rem 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
        max-width: 200px !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    #productDetailModal .quantity-btn {
        width: 36px !important;
        height: 36px !important;
        font-size: 1.2rem !important;
        border-radius: 50% !important;
        margin: 0 8px !important;
    }

    #productDetailModal .quantity-input {
        width: 50px !important;
        height: 36px !important;
        font-size: 1.2rem !important;
        text-align: center !important;
        border-radius: 8px !important;
        margin: 0 !important;
    }

    /* Botón "Añadir al carrito" en móvil */
    #productDetailModal .btn-lg.w-100 {
        font-size: 1rem !important;
        padding: 0.8rem 0 !important;
        border-radius: 25px !important;
        margin-top: 1rem !important;
        position: sticky !important;
        bottom: 0 !important;
        z-index: 10 !important;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1) !important;
    }

    /* ============================================= */
    /* 🔹 2. CARRITO DE COMPRAS (MÓVIL)             */
    /* ============================================= */

    /* --- Estructura General del Modal --- */
    #cartModal .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100vh;
    }

    #cartModal .modal-content {
        height: 100vh;
        border-radius: 0;
        border: none;
        display: flex;
        flex-direction: column; /* Asegura el layout vertical */
    }

    #cartModal .modal-header {
        border-bottom: 1px solid #dee2e6;
    }

    /* --- Cuerpo del Carrito con Scroll --- */
    #cartModal .modal-body {
        padding: 1rem;
        overflow-y: auto;
        flex-grow: 1; /* Permite que el cuerpo ocupe el espacio disponible */
        background-color: #f8f9fa; /* Fondo sutil para diferenciar */
    }

    /* --- Ocultar Tabla Original en Móvil --- */
    #cartModal .table-responsive {
        overflow-x: hidden !important;
    }
    #cartModal table {
        width: 100%;
        border-collapse: collapse;
    }
    #cartModal thead {
        display: none;
    }

    /* --- Diseño de Tarjeta por Producto (NUEVO - Full Width) --- */
    #cartItems tr {
        display: block; /* Cambiado de grid a block */
        background: #fff;
        border: 1px solid #e9ecef;
        border-radius: 12px;
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    }

    #cartItems td {
        display: flex; /* Usar flex para alinear items */
        flex-wrap: wrap; /* Permitir que los elementos se envuelvan */
        justify-content: flex-start; /* Alinear al inicio */
        align-items: center;
        padding: 0.75rem 0; /* Espaciado vertical */
        border-bottom: 1px solid #f1f1f1; /* Separador sutil */
        width: 100%;
    }

    #cartItems tr td:last-child {
        border-bottom: none; /* No border on the last item */
    }

    /* --- Ocultar el label de "Producto" y mostrarlo como un bloque --- */
    #cartItems td[data-label="Producto"] {
        flex-direction: row; /* Imagen y texto en una fila */
        align-items: center;
        padding-bottom: 1rem; /* Más espacio debajo del producto */
    }

    #cartItems td[data-label="Producto"]::before {
        display: none; /* Ocultar el label "Producto" */
    }

    #cartItems td[data-label="Producto"] .d-flex {
        width: 100%;
    }

    /* --- Estilos para los demás labels y valores --- */
    #cartItems td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #495057;
        font-size: 0.9rem;
    }

    #cartItems td[data-label="Precio"] span,
    #cartItems td[data-label="Subtotal"] span {
        font-weight: 700;
        font-size: 1rem;
        color: #0d6efd;
        white-space: normal !important; /* Permitir que el precio se ajuste */
        margin-left: auto; /* Empujar el valor a la derecha */
        padding-left: 1rem; /* Añadir espacio entre la etiqueta y el valor */
        text-align: right; /* Alinear el texto a la derecha */
    }

    #cartItems td[data-label="Cantidad"] .quantity-controls {
        flex-grow: 1;
        justify-content: flex-end; /* Alinear controles a la derecha */
    }

    #cartItems td[data-label="Eliminar"] {
        justify-content: flex-end; /* Alinear botón a la derecha */
        padding: 0.2rem 0;
    }

    #cartItems td[data-label="Eliminar"]::before {
        display: none; /* Ocultar label, el botón es suficiente */
    }

    #cartItems .remove-btn {
        background-color: transparent;
        color: #dc3545;
        border: none;
        font-size: 1.2rem;
        padding: 0.2rem 0.5rem;
    }

    /* --- Footer Fijo con Resumen y Acciones --- */
    #cartModal .modal-footer {
        position: sticky;
        bottom: 0;
        width: 100%;
        background: #fff;
        border-top: 1px solid #dee2e6;
        box-shadow: 0 -5px 15px rgba(0,0,0,0.1);
        padding: 1rem;
        z-index: 1055;
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    /* Contenedor para el total */
    .cart-total-summary {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: baseline;
    }

    .cart-total-summary span {
        font-size: 1rem;
        color: #495057;
    }

    .cart-total-summary h4 {
        font-size: 1.5rem;
        color: #0d6efd;
        margin: 0;
    }

    /* Contenedor para los botones */
    .cart-footer-buttons {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.8rem;
    }

    .cart-footer-buttons .btn {
        width: 100%;
        padding: 0.75rem;
        font-size: 0.9rem;
        font-weight: 600;
    }

    /* 🔵 3️⃣ CHECKOUT OPTIMIZADO PARA MÓVIL - Menos desplazamiento */
    .checkout-section {
        padding: 2rem 0 !important; /* Reducir padding vertical */
    }

    .checkout-card {
        margin-bottom: 1.5rem !important; /* Reducir espacio entre tarjetas */
        padding: 1.5rem !important; /* Reducir padding interno */
    }

    .checkout-title {
        font-size: 1.3rem !important; /* Título más pequeño */
        margin-bottom: 1rem !important; /* Menos margen */
        padding-bottom: 0.5rem !important; /* Menos padding */
    }

    /* Formulario más compacto */
    .checkout-card .row.g-3 {
        gap: 0.8rem !important; /* Reducir gap entre campos */
    }

    .checkout-card .form-control,
    .checkout-card .form-select {
        padding: 0.6rem 0.8rem !important; /* Campos más pequeños */
        font-size: 0.9rem !important;
    }

    .checkout-card .form-label {
        font-size: 0.85rem !important; /* Labels más pequeñas */
        margin-bottom: 0.3rem !important; /* Menos espacio */
    }

    /* Métodos de pago más compactos */
    .payment-method-card {
        padding: 0.8rem !important; /* Menos padding */
        margin-bottom: 0.8rem !important; /* Menos margen */
    }

    /* Resumen del pedido más compacto */
    .checkout-summary {
        padding: 1rem !important; /* Menos padding */
    }

    .summary-item {
        padding: 0.5rem 0 !important; /* Menos padding vertical */
        font-size: 0.9rem !important; /* Texto más pequeño */
    }

    .summary-total {
        font-size: 1.1rem !important; /* Total más pequeño */
        padding-top: 0.8rem !important;
        margin-top: 0.8rem !important;
    }

    /* Botón de checkout más compacto */
    .btn-checkout {
        padding: 0.8rem 1.5rem !important; /* Menos padding */
        font-size: 0.95rem !important; /* Texto más pequeño */
    }

    /* Items del checkout más compactos */
    .cart-item {
        padding: 0.6rem 0 !important; /* Menos padding */
    }

    .cart-product-image {
        width: 45px !important; /* Imagen más pequeña */
        height: 45px !important;
    }

    /* Resumen del carrito sin scroll horizontal */
    .cart-summary .row {
        flex-direction: column !important;
    }

    .cart-summary .col-md-6 {
        width: 100% !important;
        margin-bottom: 1rem !important;
    }

    .cart-totals {
        width: 100% !important;
    }

    .cart-totals .d-flex {
        flex-wrap: nowrap !important;
        justify-content: space-between !important;
        align-items: center !important;
    }

    /* --- Footer --- */
    .footer {
        text-align: center;
    }

    .footer-brand, .social-links {
        justify-content: center;
    }

    .footer-title::after {
        left: 50%;
        transform: translateX(-50%);
    }

    .footer .text-md-start {
        text-align: center !important;
    }

    /* --- Tabla del Carrito Responsiva --- */
    .table-responsive {
        border: none;
        overflow-x: visible !important; /* Eliminar scroll horizontal */
    }

    #cartItems table, 
    #cartItems thead, 
    #cartItems tbody, 
    #cartItems th, 
    #cartItems td, 
    #cartItems tr {
        display: block;
    }

    #cartItems thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    /* --- Modales --- */
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        min-height: 100vh;
    }

/* Sticky footer for cart summary */
#cartModal .modal-body {
    position: relative; /* Needed for sticky positioning of children */
    padding-bottom: 200px; /* Add padding to the bottom to prevent content from being hidden by the sticky footer */
}

.card.cart-summary {
    position: sticky;
    bottom: 20px; /* Stick to the bottom of the modal body */
    z-index: 10;
    background-color: #f8f9fa; /* Match background */
    border-top: 1px solid #ddd; /* Add a separator */
    padding-top: 1rem; /* Add some padding */
    padding-bottom: 1rem; /* Add some padding */
    margin-top: 1rem; /* Add space above summary */
}

    .modal-content {
        min-height: 100vh;
        border-radius: 0;
        border: none;
    }

    .modal-body {
        overflow-y: auto;
    }

    /* --- Lightbox --- */
    .lightbox-content {
        max-width: 95vw;
        max-height: 80vh;
    }
    .lightbox-close {
        top: 15px;
        right: 20px;
        font-size: 2rem;
    }

    .filter-bar .search-compact {
        flex-grow: 1;
    }

    .filter-bar .btn-group {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* 
----------------------------------------------
Punto de quiebre para Móviles Pequeños (hasta 576px)
----------------------------------------------
*/
@media (max-width: 575.98px) {
    .hero h1, .hero-title {
        font-size: 2.2rem;
    }

    .hero .lead {
        font-size: 1rem;
    }

    .footer .col-md-2 {
        width: 50%;
    }

    /* Ajuste para íconos de categoría en móviles pequeños */
    .category-icon {
        font-size: 3rem; /* Reducir tamaño del ícono */
    }
}
