/* ============================================
   CSS PROFESIONAL PARA MÓVILES CON POPUP DE FILTROS
   VERSIÓN OPTIMIZADA - SLIDER INTACTO + TIENDAS HORIZONTALES + INDICADORES
   ============================================ */

/* TABLETS Y MÓVILES GRANDES (768px - 991px) */
@media (max-width: 991px) {
    /* Ajustar padding general */
    body {
        font-size: 14px;
        line-height: 1.6;
        overflow-x: hidden;
    }
    
    /* Contenedor responsive */
    .container,
    .container-fluid {
        padding-left: 15px !important;
        padding-right: 15px !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Shop section padding reducido */
    .shop.spad {
        padding-top: 40px !important;
        padding-bottom: 40px !important;
    }
    
    .shop .row {
        margin-left: -10px !important;
        margin-right: -10px !important;
    }
    
    /* OCULTAR SIDEBAR EN TABLETS */
    .shop .col-lg-3 {
        display: none !important;
    }
    
    /* Contenido ocupa todo el ancho */
    .shop .col-lg-9 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
    
    /* Location search optimizado */
    .location-search {
        padding: 30px 0 !important;
    }
    
    .location-search h2 {
        font-size: 22px !important;
        margin-bottom: 12px !important;
    }
    
    .location-search p {
        font-size: 13px !important;
        margin-bottom: 20px !important;
    }
    
    .location-search .col-lg-4,
    .location-search .col-md-4 {
        flex: 0 0 33.333333% !important;
        max-width: 33.333333% !important;
        padding-left: 8px !important;
        padding-right: 8px !important;
    }
    
    .location-search select,
    .location-search input,
    .location-search button {
        height: 45px !important;
        font-size: 13px !important;
    }
    
    /* Stats section */
    .stats-section {
        padding: 40px 0 !important;
    }
    
    .stats-section .col-lg-3 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
        margin-bottom: 20px !important;
    }
    
    .stats-section h3 {
        font-size: 28px !important;
    }
    
    .stats-section p {
        font-size: 13px !important;
    }
}

/* ============================================
   MÓVILES MEDIANOS Y PEQUEÑOS (< 768px)
   ============================================ */

@media (max-width: 767px) {
    /* Typography móvil */
    body {
        font-size: 13px;
        overflow-x: hidden !important;
    }
    
    /* Padding general reducido */
    .container,
    .container-fluid {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
    
    /* Shop section */
    .shop.spad {
        padding-top: 20px !important;
        padding-bottom: 30px !important;
    }
    
    .shop .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
        position: relative;
    }
    
    /* OCULTAR SIDEBAR COMPLETAMENTE */
    .shop .col-lg-3 {
        display: none !important;
    }
    
    /* Contenido ocupa 100% */
    .shop .col-lg-9 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    /* ============================================
       BOTÓN FLOTANTE PARA FILTROS
       ============================================ */
    
    .filter-floating-btn {
        position: fixed;
        bottom: 20px;
        right: 20px;
        z-index: 999;
        background: linear-gradient(135deg, #7fad39, #9bc53d);
        color: white;
        width: 60px;
        height: 60px;
        border-radius: 50%;
        border: none;
        box-shadow: 0 4px 20px rgba(127, 173, 57, 0.4);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 24px;
        cursor: pointer;
        transition: all 0.3s ease;
        animation: pulse 2s infinite;
    }
    
    .filter-floating-btn:active {
        transform: scale(0.95);
    }
    
    .filter-floating-btn .fa {
        position: relative;
        z-index: 1;
    }
    
    @keyframes pulse {
        0%, 100% {
            box-shadow: 0 4px 20px rgba(127, 173, 57, 0.4);
        }
        50% {
            box-shadow: 0 4px 30px rgba(127, 173, 57, 0.6);
        }
    }
    
    .filter-floating-btn .filter-badge {
        position: absolute;
        top: -5px;
        right: -5px;
        background: #e74c3c;
        color: white;
        width: 24px;
        height: 24px;
        border-radius: 50%;
        font-size: 11px;
        font-weight: 700;
        display: flex;
        align-items: center;
        justify-content: center;
        border: 2px solid white;
        animation: bounce 0.5s ease;
    }
    
    @keyframes bounce {
        0%, 100% { transform: scale(1); }
        50% { transform: scale(1.2); }
    }
    
    /* ============================================
       POPUP/MODAL DE FILTROS
       ============================================ */
    
    .filter-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.7);
        z-index: 1000;
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
        backdrop-filter: blur(4px);
    }
    
    .filter-overlay.active {
        display: block;
        opacity: 1;
    }
    
    .filter-modal {
        position: fixed;
        bottom: -100%;
        left: 0;
        width: 100%;
        max-height: 85vh;
        background: white;
        border-radius: 25px 25px 0 0;
        z-index: 1001;
        transition: bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.2);
        display: flex;
        flex-direction: column;
    }
    
    .filter-modal.active {
        bottom: 0;
    }
    
    .filter-modal-header {
        padding: 20px;
        border-bottom: 2px solid #f1f1f1;
        display: flex;
        align-items: center;
        justify-content: space-between;
        background: linear-gradient(135deg, #7fad39, #9bc53d);
        border-radius: 25px 25px 0 0;
        position: sticky;
        top: 0;
        z-index: 10;
    }
    
    .filter-modal-header h4 {
        margin: 0;
        color: white;
        font-size: 18px;
        font-weight: 700;
    }
    
    .filter-modal-close {
        background: rgba(255, 255, 255, 0.2);
        border: none;
        color: white;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        font-size: 20px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.3s ease;
    }
    
    .filter-modal-close:active {
        background: rgba(255, 255, 255, 0.3);
        transform: scale(0.9);
    }
    
    .filter-modal-drag {
        width: 40px;
        height: 4px;
        background: rgba(255, 255, 255, 0.5);
        border-radius: 2px;
        margin: 0 auto 10px;
    }
    
    .filter-modal-content {
        padding: 20px;
        overflow-y: auto;
        flex: 1;
        -webkit-overflow-scrolling: touch;
    }
    
    .filter-modal-content::-webkit-scrollbar {
        width: 6px;
    }
    
    .filter-modal-content::-webkit-scrollbar-track {
        background: #f1f1f1;
    }
    
    .filter-modal-content::-webkit-scrollbar-thumb {
        background: #7fad39;
        border-radius: 3px;
    }
    
    .filter-modal-footer {
        padding: 15px 20px;
        border-top: 2px solid #f1f1f1;
        background: white;
        display: flex;
        gap: 10px;
        position: sticky;
        bottom: 0;
        z-index: 10;
    }
    
    .filter-modal-footer button {
        flex: 1;
        padding: 12px;
        border: none;
        border-radius: 12px;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.3s ease;
    }
    
    .filter-btn-clear {
        background: #f8f9fa;
        color: #666;
        border: 2px solid #e9ecef !important;
    }
    
    .filter-btn-clear:active {
        background: #e9ecef;
    }
    
    .filter-btn-apply {
        background: linear-gradient(135deg, #7fad39, #9bc53d);
        color: white;
        box-shadow: 0 2px 10px rgba(127, 173, 57, 0.3);
    }
    
    .filter-btn-apply:active {
        transform: scale(0.98);
    }
    
    .filter-modal .shop__sidebar {
        background: transparent;
        border-radius: 0;
        box-shadow: none;
        padding: 0;
        max-height: none;
    }
    
    .filter-modal .shop__sidebar__search {
        padding: 0 0 20px 0 !important;
        background: transparent;
        border-bottom: 1px solid #e9ecef;
        margin-bottom: 20px;
    }
    
    .filter-modal .shop__sidebar__search input {
        height: 48px !important;
        font-size: 14px !important;
        border: 2px solid #e9ecef !important;
        border-radius: 12px !important;
    }
    
    .filter-modal .shop__sidebar__accordion {
        padding: 0;
    }
    
    .filter-modal .shop__sidebar .card {
        border: none;
        border-bottom: 1px solid #f1f1f1;
        margin-bottom: 0;
    }
    
    .filter-modal .shop__sidebar .card-heading a {
        padding: 15px 0 !important;
        font-size: 14px !important;
        background: transparent !important;
    }
    
    .filter-modal .shop__sidebar .card-body {
        padding: 10px 0 15px 0 !important;
        background: transparent !important;
    }
    
    .filter-modal .shop__sidebar ul {
        max-height: 250px;
    }
    
    .filter-modal .shop__sidebar ul li a {
        padding: 10px 12px !important;
        font-size: 13px !important;
    }
    
    .filter-modal .shop__sidebar__info {
        display: none;
    }
    
    /* ============================================
       CONTENEDOR HORIZONTAL DE TIENDAS (CARRUSEL)
       ============================================ */
    
    /* Wrapper para los indicadores */
    .shop .container {
        position: relative;
    }
    
    /* Contenedor principal de tiendas */
    .shop .col-lg-9 > .tienda-block:first-child {
        margin-left: 0 !important;
    }
    
    /* Wrapper horizontal para las tiendas */
    .shop .col-lg-9 {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        scroll-snap-type: x mandatory !important;
        -webkit-overflow-scrolling: touch !important;
        scroll-behavior: smooth !important;
        gap: 15px !important;
        padding: 15px 12px !important;
        position: relative;
    }
    
    /* Ocultar scrollbar pero mantener funcionalidad */
    .shop .col-lg-9::-webkit-scrollbar {
        display: none;
    }
    
    .shop .col-lg-9 {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
    
    /* ============================================
       INDICADORES DE MÁS CONTENIDO
       ============================================ */
    
    /* Gradiente izquierdo - Aparece cuando hay contenido a la izquierda */
    .shop .col-lg-9::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 60px;
        height: 100%;
        background: linear-gradient(to right, 
            rgba(255, 255, 255, 0.95) 0%, 
            rgba(255, 255, 255, 0.7) 50%,
            rgba(255, 255, 255, 0) 100%);
        pointer-events: none;
        z-index: 5;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    /* Gradiente derecho - Aparece cuando hay contenido a la derecha */
    .shop .col-lg-9::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        width: 60px;
        height: 100%;
        background: linear-gradient(to left, 
            rgba(255, 255, 255, 0.95) 0%, 
            rgba(255, 255, 255, 0.7) 50%,
            rgba(255, 255, 255, 0) 100%);
        pointer-events: none;
        z-index: 5;
        opacity: 1;
        transition: opacity 0.3s ease;
    }
    
    /* Indicador con flecha izquierda */
    .shop .row::before {
        content: '\f053';
        font-family: 'Font Awesome 5 Free';
        font-weight: 900;
        position: absolute;
        left: 5px;
        top: 50%;
        transform: translateY(-50%);
        width: 40px;
        height: 40px;
        background: rgba(127, 173, 57, 0.95);
        color: white;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 16px;
        z-index: 10;
        pointer-events: none;
        opacity: 0;
        transition: all 0.3s ease;
        box-shadow: 0 4px 15px rgba(127, 173, 57, 0.4);
        animation: bounceLeft 2s ease-in-out infinite;
    }
    
    /* Indicador con flecha derecha */
    .shop .row::after {
        content: '\f054';
        font-family: 'Font Awesome 5 Free';
        font-weight: 900;
        position: absolute;
        right: 5px;
        top: 50%;
        transform: translateY(-50%);
        width: 40px;
        height: 40px;
        background: rgba(127, 173, 57, 0.95);
        color: white;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 16px;
        z-index: 10;
        pointer-events: none;
        opacity: 1;
        transition: all 0.3s ease;
        box-shadow: 0 4px 15px rgba(127, 173, 57, 0.4);
        animation: bounceRight 2s ease-in-out infinite;
    }
    
    /* Animaciones de rebote para los indicadores */
    @keyframes bounceLeft {
        0%, 100% {
            transform: translateY(-50%) translateX(0);
        }
        50% {
            transform: translateY(-50%) translateX(-5px);
        }
    }
    
    @keyframes bounceRight {
        0%, 100% {
            transform: translateY(-50%) translateX(0);
        }
        50% {
            transform: translateY(-50%) translateX(5px);
        }
    }
    
    /* Mostrar/ocultar indicadores según el scroll */
    .shop .row.scroll-left::before {
        opacity: 1;
    }
    
    .shop .row.scroll-right::after {
        opacity: 1;
    }
    
    .shop .row.scroll-end::after {
        opacity: 0;
    }
    
    /* Puntos indicadores en la parte inferior */
    .shop-scroll-indicators {
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 8px;
        padding: 15px 0;
        position: relative;
        z-index: 6;
    }
    
    .shop-scroll-indicator {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: #ddd;
        transition: all 0.3s ease;
    }
    
    .shop-scroll-indicator.active {
        width: 24px;
        border-radius: 4px;
        background: #7fad39;
    }
    
    /* Texto indicador arriba */
    .shop-scroll-hint {
        text-align: center;
        padding: 10px 0 5px;
        font-size: 12px;
        color: #95a5a6;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        animation: fadeInOut 3s ease-in-out infinite;
    }
    
    .shop-scroll-hint i {
        font-size: 14px;
        color: #7fad39;
    }
    
    @keyframes fadeInOut {
        0%, 100% {
            opacity: 0.6;
        }
        50% {
            opacity: 1;
        }
    }
    
    /* ============================================
       CADA BLOQUE DE TIENDA
       ============================================ */
    
    .tienda-block {
        flex: 0 0 85vw !important;
        min-width: 85vw !important;
        max-width: 85vw !important;
        scroll-snap-align: center !important;
        padding: 15px !important;
        margin-bottom: 0 !important;
        border-radius: 15px !important;
        background: #fff !important;
        box-shadow: 0 2px 12px rgba(0,0,0,0.08) !important;
    }
    
    /* Header de tienda adaptado */
    .tienda-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
        width: 100% !important;
    }
    
    .tienda-header > div:first-child {
        width: 100% !important;
        display: flex !important;
        gap: 12px !important;
        align-items: flex-start !important;
    }
    
    .tienda-header img {
        width: 50px !important;
        height: 50px !important;
        flex-shrink: 0 !important;
    }
    
    .tienda-header h5 {
        font-size: 14px !important;
        line-height: 1.3 !important;
        margin: 0 0 4px 0 !important;
    }
    
    .tienda-header p {
        font-size: 10px !important;
        line-height: 1.3 !important;
        margin-bottom: 2px !important;
    }
    
    .tienda-header > div:last-child {
        width: 100% !important;
        margin-left: 0 !important;
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
        align-items: center !important;
        justify-content: space-between !important;
    }
    
    /* Badges y botones compactos */
    .badge {
        font-size: 9px !important;
        padding: 3px 7px !important;
        white-space: nowrap !important;
    }
    
    .btn-sm {
        padding: 6px 12px !important;
        font-size: 10px !important;
        border-radius: 15px !important;
        white-space: nowrap !important;
    }
    
    /* Botones scroll de tienda más discretos */
    .scroll-prev,
    .scroll-next {
        width: 28px !important;
        height: 28px !important;
        opacity: 0.8 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .scroll-prev {
        left: 2px !important;
    }
    
    .scroll-next {
        right: 2px !important;
    }
    
    .scroll-prev i,
    .scroll-next i {
        font-size: 12px !important;
    }
    
    /* Productos dentro de cada tienda */
    .productos-scroll {
        position: relative !important;
        width: 100% !important;
        margin-top: 10px !important;
    }
    
    .productos-scroll > div:not(.scroll-prev):not(.scroll-next) {
        display: flex !important;
        gap: 10px !important;
        overflow-x: auto !important;
        scroll-behavior: smooth !important;
        -webkit-overflow-scrolling: touch !important;
        scroll-snap-type: x mandatory !important;
        padding: 8px 0 !important;
    }
    
    /* Productos individuales - 2 por vista */
    .productos-scroll > div > div {
        flex: 0 0 calc(50% - 5px) !important;
        min-width: calc(50% - 5px) !important;
        max-width: calc(50% - 5px) !important;
        scroll-snap-align: start !important;
    }
    
    .productos-scroll img {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 1 !important;
        object-fit: cover !important;
    }
    
    .productos-scroll > div > div > a > div:first-child {
        height: auto !important;
        aspect-ratio: 1 !important;
    }
    
    .productos-scroll > div > div > a > div:last-child {
        padding: 8px !important;
    }
    
    .productos-scroll h6 {
        font-size: 11px !important;
        height: 32px !important;
        margin: 5px 0 !important;
        line-height: 1.3 !important;
    }
    
    .productos-scroll span[style*="font-size: 17px"] {
        font-size: 13px !important;
    }
    
    .productos-scroll span[style*="font-size: 11px"] {
        font-size: 10px !important;
    }
    
    .productos-scroll .fa-star {
        font-size: 8px !important;
    }
    
    /* ============================================
       LOCATION SEARCH MÓVIL
       ============================================ */
    
    .location-search {
        padding: 20px 0 !important;
    }
    
    .location-search h2 {
        font-size: 18px !important;
        margin-bottom: 10px !important;
    }
    
    .location-search p {
        font-size: 12px !important;
        margin-bottom: 15px !important;
    }
    
    .location-search .col-lg-4,
    .location-search .col-md-4,
    .location-search .col-sm-12 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        margin-bottom: 12px !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
    
    .location-search select,
    .location-search input {
        height: 48px !important;
        font-size: 14px !important;
        border-radius: 12px !important;
        width: 100% !important;
    }
    
    .location-search button {
        height: 48px !important;
        font-size: 15px !important;
        border-radius: 12px !important;
        width: 100% !important;
    }
    
    .location-search label {
        font-size: 13px !important;
        margin-bottom: 6px !important;
    }
    
    #filtros-adicionales {
        padding: 0 12px;
    }
    
    #filtros-adicionales .col-lg-4 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        margin-bottom: 12px !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    /* ============================================
       STATS SECTION MÓVIL
       ============================================ */
    
    .stats-section {
        padding: 30px 0 !important;
    }
    
    .stats-section .col-lg-3,
    .stats-section .col-md-6 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
        margin-bottom: 20px !important;
    }
    
    .stats-section h3 {
        font-size: 24px !important;
    }
    
    .stats-section p {
        font-size: 12px !important;
    }
    
    .stats-section > div:first-child {
        font-size: 36px !important;
    }
    
    /* ============================================
       NO PRODUCTS MESSAGE
       ============================================ */
    
    .no-products {
        padding: 40px 15px !important;
        margin: 0 12px !important;
    }
    
    .no-products > div:first-child {
        font-size: 48px !important;
    }
    
    .no-products h4 {
        font-size: 18px !important;
    }
    
    .no-products p {
        font-size: 13px !important;
    }
    
    .no-products .btn {
        padding: 10px 20px !important;
        font-size: 13px !important;
        margin: 5px !important;
    }
}

/* ============================================
   MÓVILES PEQUEÑOS (< 576px)
   ============================================ */

@media (max-width: 575px) {
    /* Tiendas un poco más grandes en pantallas muy pequeñas */
    .tienda-block {
        flex: 0 0 90vw !important;
        min-width: 90vw !important;
        max-width: 90vw !important;
    }
    
    /* Stats en columna única */
    .stats-section .col-lg-3,
    .stats-section .col-md-6 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }
    
    /* Indicadores más pequeños */
    .shop .row::before,
    .shop .row::after {
        width: 36px !important;
        height: 36px !important;
        font-size: 14px !important;
    }
}

/* ============================================
   OPTIMIZACIONES GENERALES
   ============================================ */

@media (max-width: 767px) {
    /* Prevenir scroll horizontal global */
    html,
    body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }
    
    /* Smooth scrolling */
    html {
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Touch targets mínimo 44px */
    a:not(.productos-scroll a),
    button:not(.scroll-prev):not(.scroll-next) {
        min-height: 44px;
    }
    
    /* Prevenir zoom en inputs */
    input[type="text"],
    input[type="search"],
    select,
    textarea {
        font-size: 16px !important;
    }
    
    /* Hardware acceleration */
    .filter-modal,
    .tienda-block,
    .productos-scroll,
    .shop .col-lg-9 {
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
        will-change: transform;
    }
    
    /* Mejorar tap highlights */
    * {
        -webkit-tap-highlight-color: rgba(127, 173, 57, 0.2);
    }
}

/* ============================================
   ANIMACIONES
   ============================================ */

@media (max-width: 767px) {
    .tienda-block {
        animation: fadeIn 0.4s ease-out;
    }
    
    @keyframes fadeIn {
        from {
            opacity: 0;
        }
        to {
            opacity: 1;
        }
    }
}