/*
=====================================
FIX-WEB.CSS - CORRECCIONES CRÍTICAS
Soluciona problemas de scroll infinito
=====================================
*/

/* ====================================
   CORRECCIONES BÁSICAS LAYOUT
==================================== */

/* Resetear box-sizing para evitar problemas */
* {
    box-sizing: border-box;
}

/* Sobrescribir reglas generales de imágenes para la galería de productos */
.product-gallery img {
    max-width: none !important;
    display: block;
}

/* Imagen principal del producto - tamaño grande */
.product-gallery .main-image {
    height: 600px !important;
    min-height: 600px !important;
}

.product-gallery .main-image img {
    height: 600px !important;
    width: 100% !important;
    object-fit: contain !important;
}

/* Miniaturas mantienen altura automática */
.product-gallery .thumbnails img {
    height: auto;
}

/* Corregir body y html */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden; /* Evitar scroll horizontal */
    overflow-y: auto; /* Permitir scroll vertical */
}

body {
    min-height: 100vh;
    /* Removed flex layout that was causing issues with content visibility */
}

/* Contenedor principal que toma el espacio restante */
.main-content {
    /* Removed flex rules that were causing layout issues */
}

/* Corregir contenedores que pueden causar overflow */
.container,
.container-fluid {
    max-width: 100%;
    padding-left: 15px;
    padding-right: 15px;
    margin-left: auto;
    margin-right: auto;
}

/* ====================================
   CORRECCIONES ESPECÍFICAS BOOTSTRAP
==================================== */

/* Corregir filas que pueden salirse */
.row {
    margin-left: -15px;
    margin-right: -15px;
    display: flex;
    flex-wrap: wrap;
}

.row > * {
    padding-left: 15px;
    padding-right: 15px;
}

/* Prevenir overflow en columnas */
[class*="col-"] {
    min-width: 0;
    word-wrap: break-word;
}

/* ====================================
   CORRECCIONES PARA IMÁGENES
==================================== */

/* Prevenir que las imágenes causen overflow */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Corregir imágenes en cards */
.card-img-top,
.card-img-bottom {
    width: 100%;
    max-width: 100%;
    object-fit: contain;
}

/* ====================================
   CORRECCIONES PARA COMPONENTES
==================================== */

/* Corregir hero section */
.hero-section {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

/* Corregir cards */
.card {
    max-width: 100%;
    overflow: hidden;
}

/* Corregir navbar */
.navbar {
    width: 100%;
    max-width: 100%;
}

/* Corregir footer */
footer {
    width: 100%;
    max-width: 100%;
    margin-top: auto; /* Para que se pegue al bottom */
}

/* ====================================
   CORRECCIONES PARA FORMULARIOS
==================================== */

/* Prevenir overflow en inputs */
.form-control,
.form-select {
    max-width: 100%;
    box-sizing: border-box;
}

/* Corregir input groups */
.input-group {
    max-width: 100%;
    display: flex;
    flex-wrap: nowrap;
}

/* ====================================
   CORRECCIONES PARA TABLAS
==================================== */

/* Hacer tablas responsive */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    max-width: 100%;
    margin-bottom: 0;
}

/* ====================================
   CORRECCIONES PARA MODALES
==================================== */

/* Prevenir overflow en modales */
.modal-dialog {
    max-width: calc(100vw - 30px);
    margin: 15px auto;
}

.modal-content {
    max-width: 100%;
    overflow: hidden;
}

/* ====================================
   CORRECCIONES RESPONSIVE
==================================== */

/* Extra small devices */
@media (max-width: 575.98px) {
    .container {
        padding-left: 10px;
        padding-right: 10px;
    }
    
    .row {
        margin-left: -10px;
        margin-right: -10px;
    }
    
    .row > * {
        padding-left: 10px;
        padding-right: 10px;
    }
}

/* ====================================
   CORRECCIONES PARA ELEMENTOS FLOTANTES
==================================== */

/* Corregir botones flotantes */
.floating-buttons,
.whatsapp-float,
.scroll-top {
    position: fixed;
    z-index: 1040;
    max-width: 60px;
    max-height: 60px;
}

/* ====================================
   CORRECCIONES PARA ANIMACIONES
==================================== */

/* Reducir animaciones si el usuario lo prefiere */
@media (prefers-reduced-motion: reduce) {
    *,
    ::before,
    ::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ====================================
   DEBUGGING UTILITIES (TEMPORALES)
==================================== */

/* Descomentar estas líneas solo para debugging */
/*
* {
    outline: 1px solid red !important;
}

.container,
.container-fluid {
    outline: 2px solid blue !important;
}

.row {
    outline: 2px solid green !important;
}

[class*="col-"] {
    outline: 1px solid orange !important;
}
*/

/* ====================================
   CORRECCIONES ESPECÍFICAS PARA EL SCROLL
==================================== */

/* Corregir posibles elementos que causan scroll infinito */
.infinite-scroll-container,
.lazy-load-container {
    max-height: none !important;
    overflow: visible !important;
}

/* Asegurar que no hay elementos con height infinito */
[style*="height: 100000"],
[style*="height: 999999"],
.infinite-height {
    height: auto !important;
    max-height: 100vh !important;
}

/* Corregir posibles problemas con sticky elements */
.sticky-top,
.position-sticky {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 1020;
}

/* ====================================
   CORRECCIONES PARA PRODUCTOS GRID
==================================== */

/* Asegurar que el grid de productos no cause overflow */
.productos-grid {
    width: 100%;
    max-width: 100%;
}

.producto-item {
    min-width: 0;
    max-width: 100%;
}

/* Corregir cards de productos */
.product-card {
    height: auto;
    max-height: none;
    width: 100%;
    max-width: 100%;
}

/* ====================================
   CORRECCIONES FINALES
==================================== */

/* Ocultar scrollbar horizontal si aparece */
body {
    overflow-x: hidden;
}

/* Asegurar que todos los elementos respeten el ancho del viewport */
* {
    max-width: 100vw;
}

/* Corregir elementos que podrían salirse del viewport */
.w-100 {
    width: 100% !important;
    max-width: 100% !important;
}

/* Corregir flexbox que puede causar overflow */
.d-flex {
    min-width: 0;
}

.flex-fill {
    min-width: 0;
}

/* ====================================
   RESET DE MÁRGENES PROBLEMÁTICOS
==================================== */

/* Resetear márgenes que pueden causar problemas */
h1, h2, h3, h4, h5, h6,
p, ul, ol, dl,
blockquote, pre {
    margin-top: 0;
}

/* Último elemento no debe tener margin-bottom */
*:last-child {
    margin-bottom: 0 !important;
}

/* ====================================
   CORRECCIONES PARA BOTONES FAVORITOS
==================================== */

/* Prevenir comportamientos automáticos de Bootstrap en botones de favoritos */
[data-favorito-toggle] {
    /* Evitar que Bootstrap active estados automáticamente */
    outline: none !important;
    box-shadow: none !important;
}

[data-favorito-toggle]:focus {
    outline: none !important;
    box-shadow: none !important;
}

[data-favorito-toggle]:active {
    outline: none !important;
    box-shadow: none !important;
}

/* Evitar que el botón de favorito quede con fondo rojo */
[data-favorito-toggle].btn-outline-danger:active,
[data-favorito-toggle].btn-outline-danger.active,
[data-favorito-toggle].btn-outline-secondary:active,
[data-favorito-toggle].btn-outline-secondary.active {
    background-color: transparent !important;
    border-color: currentColor !important;
    color: inherit !important;
}

/* Cuando el favorito está activo, solo el ícono debe ser rojo */
[data-favorito-toggle].favorito-activo {
    background-color: transparent !important;
    border-color: #6c757d !important;
    color: #6c757d !important;
}

[data-favorito-toggle].favorito-activo i {
    color: #dc3545 !important;
}

/* Estados hover para botones de favorito */
[data-favorito-toggle]:hover {
    background-color: rgba(108, 117, 125, 0.1) !important;
    border-color: #6c757d !important;
    color: #6c757d !important;
}

[data-favorito-toggle].favorito-activo:hover {
    background-color: rgba(220, 53, 69, 0.1) !important;
    border-color: #dc3545 !important;
    color: #dc3545 !important;
}

/* ====================================
   CORRECCIÓN BÁSICA PARA DESCRIPCIÓN DE PRODUCTO
==================================== */

/* Asegurar visibilidad básica de la descripción del producto */
.producto-descripcion {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.producto-descripcion .card {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* ====================================
   PRINT STYLES
==================================== */

@media print {
    /* Evitar saltos de página problemáticos */
    .no-print {
        display: none !important;
    }

    * {
        overflow: visible !important;
    }

    body {
        overflow: visible !important;
    }
}
    
/* ====================================
   MEJORAS GALERÍA DE PRODUCTO
==================================== */

.product-gallery {
    /* Removed sticky positioning that was causing layout issues */
}

.product-gallery .main-image {
    height: 280px !important;
    background: #f8f9fa;
    border-radius: 12px;
    overflow: hidden;
    display: flex !important;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 1px solid #e9ecef;
    margin-bottom: 15px;
}

.product-gallery .main-product-image {
    max-width: 100% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
    cursor: zoom-in;
    transition: transform 0.2s ease;
}

.product-gallery .main-product-image:hover {
    transform: scale(1.02);
}

.product-gallery .gallery-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #666;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.product-gallery .main-image:hover .gallery-nav-btn {
    opacity: 1;
}

.product-gallery .gallery-nav-btn:hover {
    background: rgba(255, 255, 255, 1);
    color: #333;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.product-gallery .gallery-nav-prev {
    left: 15px;
}

.product-gallery .gallery-nav-next {
    right: 15px;
}

.product-gallery .gallery-indicator {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    z-index: 10;
}

.product-gallery .thumbnails {
    margin-top: 15px;
}

.product-gallery .thumbnail-img {
    width: 100% !important;
    height: 70px !important;
    object-fit: contain !important;
    background: #f8f9fa;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent !important;
}

.product-gallery .thumbnail-img:hover {
    border-color: #0d6efd !important;
    transform: scale(1.05);
}

.product-gallery .thumbnail-img.active {
    border-color: #0d6efd !important;
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.2);
}

/* Modal de imagen */
.modal-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #666;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1060;
}

.modal-nav-btn:hover {
    background: rgba(255, 255, 255, 1);
    color: #333;
    transform: translateY(-50%) scale(1.1);
}

.modal-nav-prev {
    left: 20px;
}

.modal-nav-next {
    right: 20px;
}

.modal-indicator {
    font-size: 14px;
    color: #666;
}

/* Responsive */
@media (max-width: 768px) {
    .product-gallery .main-image {
        height: 220px !important;
        margin-bottom: 20px;
    }
    
    .product-gallery .gallery-nav-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    
    .product-gallery .gallery-nav-prev {
        left: 10px;
    }
    
    .product-gallery .gallery-nav-next {
        right: 10px;
    }
    
    .product-gallery .thumbnail-img {
        height: 60px !important;
    }
    
    .modal-nav-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .modal-nav-prev {
        left: 15px;
    }
    
    .modal-nav-next {
        right: 15px;
    }
}