/* ========================================
   ESTILO PREDETERMINADO - SISTEMA DINÁMICO
   ======================================== */
/* Este archivo contiene el estilo predeterminado del sistema */

/* Estilos generales */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
}

/* Header */
header {
    background-color: #343a40 !important; /* Gris oscuro */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Sobrescribir el color azul de Bootstrap para headers */
header.bg-primary {
    background-color: #343a40 !important; /* Gris oscuro */
}

/* Cards de categorías */
.categoria-card {
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    height: 100%; /* Altura uniforme */
    display: flex;
    flex-direction: column;
}

/* Contenido de categorías para distribución uniforme */
.categoria-card .card-body {
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Toma el espacio restante */
    justify-content: center; /* Centra el contenido */
}

.categoria-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.placeholder-img {
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8f9fa;
    border-radius: 8px;
}

/* Cards de productos */
.producto-card {
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    height: 100%; /* Altura uniforme */
    display: flex;
    flex-direction: column;
}

/* Contenido de productos para distribución uniforme */
.producto-card .card-body {
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Toma el espacio restante */
    justify-content: space-between; /* Distribuye el contenido */
}

.producto-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.producto-precio {
    font-size: 1.2rem;
    font-weight: bold;
    color: #28a745;
}

.producto-no-disponible {
    opacity: 0.6;
    pointer-events: none;
}

.producto-no-disponible .card-img-top {
    filter: grayscale(100%);
}

/* Botón volver flotante */
.volver-flotante {
    position: fixed;
    bottom: 30px;
    left: 30px;
    width: 60px;
    height: 60px;
    background-color: #6c757d;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    transition: transform 0.2s;
    z-index: 1000;
}

.volver-flotante:hover {
    transform: scale(1.1);
    background-color: #5a6268;
}

.volver-flotante i {
    font-size: 1.5rem;
}

/* Carrito flotante */
.carrito-flotante {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background-color: #007bff;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    transition: transform 0.2s;
    z-index: 1000;
}

.carrito-flotante:hover {
    transform: scale(1.1);
}

.carrito-flotante i {
    font-size: 1.5rem;
}

.carrito-flotante .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 0.8rem;
}

/* Breadcrumb */
.breadcrumb {
    background-color: transparent;
    padding: 0;
    margin-bottom: 20px;
}

.breadcrumb-item a {
    color: #007bff;
    text-decoration: none;
}

.breadcrumb-item a:hover {
    text-decoration: underline;
}

/* Modal del carrito */
.carrito-item {
    display: flex;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #eee;
    gap: 15px;
}

.carrito-item:last-child {
    border-bottom: none;
}

.carrito-item img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

.carrito-item-info {
    flex: 1;
}

.carrito-item-titulo {
    font-weight: bold;
    margin-bottom: 5px;
}

.carrito-item-detalle {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 5px;
}

.carrito-item-cantidad {
    margin-top: 10px;
}

.cantidad-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cantidad-controls button {
    width: 30px;
    height: 30px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.8rem;
}

.cantidad-valor {
    font-weight: bold;
    min-width: 30px;
    text-align: center;
    font-size: 1.1em;
}

.carrito-item-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

.carrito-item-precio {
    font-weight: bold;
    color: #28a745;
    font-size: 1.1em;
}

.carrito-item-actions .btn-danger {
    width: 35px;
    height: 35px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 768px) {
    .volver-flotante {
        bottom: 20px;
        left: 20px;
        width: 50px;
        height: 50px;
    }
    
    .volver-flotante i {
        font-size: 1.2rem;
    }
    
    .carrito-flotante {
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
    }
    
    .carrito-flotante i {
        font-size: 1.2rem;
    }
    
    .carrito-item {
        padding: 10px 0;
        gap: 10px;
    }
    
    .carrito-item img {
        width: 50px;
        height: 50px;
    }
    
    .cantidad-controls button {
        width: 28px;
        height: 28px;
        font-size: 0.7rem;
    }
    
    .carrito-item-actions .btn-danger {
        width: 32px;
        height: 32px;
        font-size: 0.7rem;
    }
}

@media (max-width: 576px) {
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    .volver-flotante {
        bottom: 15px;
        left: 15px;
        width: 45px;
        height: 45px;
    }
    
    .volver-flotante i {
        font-size: 1rem;
    }
    
    .carrito-flotante {
        bottom: 15px;
        right: 15px;
        width: 45px;
        height: 45px;
    }
    
    .carrito-flotante i {
        font-size: 1rem;
    }
}

/* Estilos para el mapa */
#mapa {
    border-radius: 8px;
    border: 1px solid #ddd;
}

/* Estilos para formularios */
.form-control:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.form-check-input:checked {
    background-color: #007bff;
    border-color: #007bff;
}

/* Alertas */
.alert {
    border-radius: 8px;
    border: none;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
}

/* Botones */
.btn {
    border-radius: 6px;
    font-weight: 500;
}

.btn-primary {
    background-color: #007bff;
    border-color: #007bff;
}

.btn-primary:hover {
    background-color: #0056b3;
    border-color: #0056b3;
}

.btn-success {
    background-color: #28a745;
    border-color: #28a745;
}

.btn-success:hover {
    background-color: #1e7e34;
    border-color: #1e7e34;
}

/* Loading spinner */
.spinner-border {
    width: 1rem;
    height: 1rem;
}

/* Animaciones */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

/* Estilos para evitar efectos no deseados en botones del carrito */
.carrito-item .btn {
    transition: all 0.2s ease;
    border: none;
    outline: none;
}

.carrito-item .btn:focus {
    box-shadow: none;
    outline: none;
}

.carrito-item .btn:active {
    transform: scale(0.95);
}

/* Evitar el efecto de overlay del modal en botones del carrito */
.modal .carrito-item .btn {
    position: relative;
    z-index: 1;
}

/* Prevenir el destello del modal al hacer clic en botones */
.modal .carrito-item .btn:focus {
    box-shadow: none !important;
}

.modal .carrito-item .btn:active {
    background-color: inherit !important;
}

/* Prevenir el oscurecimiento del fondo del modal */
.modal .carrito-item .btn {
    pointer-events: auto !important;
}

.modal .carrito-item .btn:hover {
    background-color: inherit !important;
}

/* Deshabilitar efectos de overlay del modal en botones específicos */
.modal .carrito-item .btn-increase,
.modal .carrito-item .btn-decrease,
.modal .carrito-item .btn-eliminar {
    position: relative;
    z-index: 1050 !important;
    background-color: inherit !important;
}

.modal .carrito-item .btn-increase:focus,
.modal .carrito-item .btn-decrease:focus,
.modal .carrito-item .btn-eliminar:focus {
    box-shadow: none !important;
    outline: none !important;
}

.modal .carrito-item .btn-increase:active,
.modal .carrito-item .btn-decrease:active,
.modal .carrito-item .btn-eliminar:active {
    background-color: inherit !important;
    transform: scale(0.95);
}

/* Solución definitiva para evitar el oscurecimiento del modal */
.modal-backdrop:not(.mercadopago-backdrop) {
    pointer-events: none !important;
}

.modal .carrito-item .btn-increase,
.modal .carrito-item .btn-decrease,
.modal .carrito-item .btn-eliminar {
    pointer-events: auto !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

/* Deshabilitar efectos de Bootstrap en botones específicos */
.modal .carrito-item .btn:not(.btn-increase):not(.btn-decrease):not(.btn-eliminar) {
    pointer-events: auto;
}

/* Asegurar que los botones del carrito no afecten el modal */
.modal .carrito-item .btn-increase:before,
.modal .carrito-item .btn-decrease:before,
.modal .carrito-item .btn-eliminar:before {
    content: none !important;
}

/* Prevenir acumulación de overlays */
.modal-backdrop {
    opacity: 0.5 !important;
}

.modal-backdrop + .modal-backdrop {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Asegurar que el modal tenga el z-index correcto */
.modal {
    z-index: 1055 !important;
}

/* Prevenir que los botones creen nuevos backdrops */
.modal .carrito-item .btn {
    position: relative;
    z-index: 1056 !important;
}

/* Limpiar estado del body cuando hay modal */
body.modal-open {
    overflow: hidden !important;
    padding-right: 0 !important;
}

/* Estilos específicos para Firefox */
@-moz-document url-prefix() {
    /* Prevenir acumulación de overlays en Firefox */
    .modal-backdrop {
        opacity: 0.5 !important;
        pointer-events: auto !important;
    }
    
    .modal-backdrop + .modal-backdrop {
        opacity: 0 !important;
        pointer-events: none !important;
        display: none !important;
    }
    
    /* Asegurar que los botones del carrito funcionen correctamente en Firefox */
    .modal .carrito-item .btn {
        position: relative;
        z-index: 1056 !important;
        pointer-events: auto !important;
    }
    
    /* Prevenir que Firefox cree múltiples backdrops */
    .modal {
        z-index: 1055 !important;
    }
    
    /* Forzar el comportamiento correcto del body en Firefox */
    body.modal-open {
        overflow: hidden !important;
        padding-right: 0 !important;
        position: fixed !important;
        width: 100% !important;
    }
}

/* Estilos generales para prevenir problemas de modal */
.modal-backdrop {
    opacity: 0.5 !important;
}

/* Prevenir múltiples backdrops */
.modal-backdrop + .modal-backdrop {
    opacity: 0 !important;
    pointer-events: none !important;
    display: none !important;
}

/* Asegurar que el modal de Mercado Pago funcione correctamente */
.mercadopago-modal .modal-backdrop {
    pointer-events: auto !important;
}

.mercadopago-modal {
    z-index: 1055 !important;
}

.mercadopago-modal .modal-dialog {
    z-index: 1056 !important;
}

.mercadopago-modal .modal-content {
    z-index: 1057 !important;
}

.mercadopago-modal .btn {
    pointer-events: auto !important;
    position: relative;
    z-index: 1058 !important;
}

/* Asegurar que el modal esté siempre visible */
.modal.show {
    display: block !important;
    z-index: 1055 !important;
}

/* Prevenir que el body se quede bloqueado */
body.modal-open {
    overflow: hidden !important;
}

/* Limpiar estado del body cuando no hay modales */
body:not(.modal-open) {
    overflow: auto !important;
    padding-right: 0 !important;
    position: static !important;
    width: auto !important;
}

/* Estilos para el modal de stock insuficiente */
.stock-insufficient-icon {
    position: relative;
    display: inline-block;
    margin-bottom: 1rem;
}

.stock-insufficient-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(220, 53, 69, 0.9);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.9;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 0.7;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.9;
    }
}

/* Animación de entrada para el modal */
.modal.fade .modal-dialog {
    transition: transform 0.3s ease-out;
}

.modal.show .modal-dialog {
    transform: none;
}

/* Estilos adicionales para el modal de stock */
#modalStockInsuficiente .modal-content {
    border: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

#modalStockInsuficiente .modal-header {
    border-bottom: 2px solid #dc3545;
}

#modalStockInsuficiente .alert-info {
    background-color: #f8f9fa;
    border-color: #dee2e6;
    color: #495057;
}

/* Estilos generales para modales */
.modal-content {
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.modal-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    border-top-left-radius: 0.375rem;
    border-top-right-radius: 0.375rem;
    padding: 1rem;
}

.modal-header .modal-title {
    color: #212529;
    font-weight: 600;
    margin: 0;
}

.modal-body {
    background-color: #ffffff;
    color: #212529;
    padding: 1rem;
}

.modal-footer {
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    border-bottom-left-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
    padding: 1rem;
}

/* Estilos específicos para el modal de producto */
#modalProducto .modal-content {
    background-color: #ffffff;
}

#modalProducto .modal-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

#modalProducto .modal-body {
    background-color: #ffffff;
}

#modalProducto .modal-footer {
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

/* Estilos específicos para el modal del carrito */
#modalCarrito .modal-content {
    background-color: #ffffff;
}

#modalCarrito .modal-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

#modalCarrito .modal-body {
    background-color: #ffffff;
}

#modalCarrito .modal-footer {
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

/* Estilos para agregados */
#seccion-agregados {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #dee2e6;
}

#lista-agregados {
    max-height: 200px;
    overflow-y: auto;
    background-color: #f8f9fa;
}

#lista-agregados .form-check {
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    border-radius: 0.25rem;
    transition: background-color 0.2s;
}

#lista-agregados .form-check:hover {
    background-color: #e9ecef;
}

#lista-agregados .form-check:last-child {
    margin-bottom: 0;
}

.carrito-item-agregados {
    margin-top: 0.25rem;
    padding-top: 0.25rem;
    border-top: 1px solid #f0f0f0;
}

.carrito-item-agregados small {
    font-size: 0.8rem;
    line-height: 1.2;
}

/* Animación para checkboxes de agregados */
#lista-agregados .form-check-input:checked + .form-check-label {
    font-weight: 600;
    color: #0d6efd;
}

#lista-agregados .form-check-input:checked {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

/* Botón de emergencia para limpiar estado del modal */
.emergencia-modal {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background-color: #dc3545;
    color: white;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    opacity: 0;
    pointer-events: none;
}

.emergencia-modal:hover {
    background-color: #c82333;
    transform: scale(1.1);
}

/* Mostrar botón de emergencia solo cuando hay problemas reales */
.emergencia-modal.show {
    display: flex !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Estilos para los indicadores de pasos */
.step-indicator {
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 10px;
    border-radius: 8px;
    flex: 1;
    max-width: 200px;
}

.step-indicator:hover {
    background-color: #f8f9fa;
}

.step-indicator.active {
    color: #007bff;
}

.step-indicator.completed {
    color: #28a745;
}

.step-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #e9ecef;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin: 0 auto 8px;
    transition: all 0.3s ease;
    font-size: 1.1rem;
}

.step-indicator.active .step-number {
    background-color: #007bff;
    color: white;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.step-indicator.completed .step-number {
    background-color: #28a745;
    color: white;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

.step-title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
}

/* Animaciones para los pasos */
.step-content {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Estilos para el mapa */
#mapa {
    border: 2px solid #dee2e6;
    transition: border-color 0.3s ease;
}

#mapa:hover {
    border-color: #007bff;
}

/* Responsive para indicadores de pasos */
@media (max-width: 768px) {
    .step-indicator {
        padding: 8px 5px;
        max-width: none;
    }
    
    .step-number {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
    
    .step-title {
        font-size: 12px;
    }
}

@media (max-width: 576px) {
    .step-indicator {
        padding: 5px 2px;
    }
    
    .step-number {
        width: 30px;
        height: 30px;
        font-size: 0.9rem;
    }
    
    .step-title {
        font-size: 11px;
    }
} 

/* ========================================
   SISTEMA DE OPTIMIZACIÓN DE IMÁGENES
   ======================================== */

/* Configuración base para todas las imágenes */
.card-img-top {
    object-fit: cover;
    object-position: center;
    transition: transform 0.3s ease;
}

/* Hover effect para mejor UX */
.card:hover .card-img-top {
    transform: scale(1.05);
}

/* ========================================
   SISTEMA LEGACY PARA OTRAS DIMENSIONES
   ======================================== */

/* CATEGORÍAS - Sistema actual */
.categoria-card .card-img-top.legacy-size {
    /* Desktop: Altura fija para uniformidad */
    height: 200px;
    width: 100%;
    object-fit: cover;
    object-position: center;
    flex-shrink: 0; /* Evita que la imagen se comprima */
}

/* PRODUCTOS - Sistema actual */
.producto-card .card-img-top.legacy-size {
    /* Desktop: Altura fija para uniformidad */
    height: 200px;
    width: 100%;
    object-fit: cover;
    object-position: center;
    flex-shrink: 0; /* Evita que la imagen se comprima */
}

/* PRODUCTO ESPECÍFICO (Modal) */
#modalProductoImagen {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: contain;
    border-radius: 8px;
}

/* LOGO */
header .img-fluid {
    max-height: 60px;
    width: auto;
    object-fit: contain;
}

/* LOGO HEADER - Ocupa toda la altura del header */
.logo-header {
    height: 100%;
    max-height: none;
    width: auto;
    object-fit: contain;
}

/* Ajustar alineación del contenido del header para que esté alineado con el logo */
header .row.align-items-center {
    align-items: flex-start !important;
}

/* Ajustar el contenedor de información para alinearlo con la parte superior */
header .col-md-6.text-end {
    padding-top: 0.5rem;
}

/* CARRITO */
.carrito-item img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
}

/* ========================================
   RESPONSIVE DESIGN OPTIMIZADO
   ======================================== */

@media (max-width: 768px) {
    /* CATEGORÍAS - Tablet (Sistema legacy) */
    .categoria-card .card-img-top.legacy-size {
        /* Tablet: Altura fija para uniformidad */
        height: 150px;
        width: 100%;
        object-fit: cover;
        object-position: center;
        flex-shrink: 0;
    }
    
    /* PRODUCTOS - Móvil (Sistema legacy) */
    .producto-card .card-img-top.legacy-size {
        /* Móvil: Altura fija para uniformidad */
        height: 150px;
        width: 100%;
        object-fit: cover;
        object-position: center;
        flex-shrink: 0;
    }
    
    /* CARRITO - Móvil */
    .carrito-item img {
        width: 50px;
        height: 50px;
    }
    
    /* LOGO - Móvil */
    header .img-fluid {
        max-height: 50px;
    }
    
    /* LOGO HEADER - Móvil - Mantiene altura completa */
    .logo-header {
        height: 100%;
        max-height: none;
    }
}

@media (max-width: 576px) {
    /* CATEGORÍAS - Móvil (Sistema legacy) */
    .categoria-card .card-img-top.legacy-size {
        height: 120px;
        object-fit: cover;
        object-position: center;
        flex-shrink: 0;
    }
    
    /* PRODUCTOS - Móvil pequeño (Sistema legacy) */
    .producto-card .card-img-top.legacy-size {
        height: 120px;
        object-fit: cover;
        object-position: center;
        flex-shrink: 0;
    }
    
    /* CARRITO - Móvil pequeño */
    .carrito-item img {
        width: 45px;
        height: 45px;
    }
}

/* ========================================
   FALLBACKS Y PLACEHOLDERS MEJORADOS
   ======================================== */

.placeholder-img {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px dashed #dee2e6;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    transition: all 0.3s ease;
}

.placeholder-img:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
    border-color: #adb5bd;
}

/* ========================================
   OPTIMIZACIONES ADICIONALES
   ======================================== */

/* Lazy loading para mejor rendimiento */
.card-img-top {
    loading: lazy;
}

/* Prevenir layout shift */
.card-img-top {
    aspect-ratio: auto;
}

/* Mejor calidad en pantallas de alta densidad */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .card-img-top {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* ========================================
   ESTADOS ESPECIALES
   ======================================== */

/* Producto no disponible */
.producto-no-disponible .card-img-top {
    filter: grayscale(100%) brightness(0.7);
    opacity: 0.6;
}

/* Loading state */
.card-img-top.loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ========================================
   SISTEMA DE BÚSQUEDA
   ======================================== */
.search-container {
    position: relative;
    margin-bottom: 1.5rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.search-input {
    width: 100%;
    padding: 15px 50px 15px 20px;
    border: 2px solid #e9ecef;
    border-radius: 30px;
    font-size: 16px;
    background-color: #ffffff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 4px 20px rgba(0,123,255,0.3);
    transform: translateY(-2px);
}

.search-input::placeholder {
    color: #6c757d;
    opacity: 0.8;
}

.search-icon {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    font-size: 18px;
    pointer-events: none;
    transition: color 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 4px 20px rgba(0,123,255,0.3);
    transform: translateY(-2px);
}

.search-input:focus + .search-icon {
    color: #007bff;
}

/* Resultados de búsqueda */
.search-results {
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    position: relative;
}

.search-result-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f8f9fa;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background-color: #f8f9fa;
}

.search-result-item.active {
    background-color: #e3f2fd;
    border-left: 4px solid #007bff;
}

.search-result-image {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.search-result-info {
    flex: 1;
}

.search-result-title {
    font-weight: 600;
    color: #212529;
    margin-bottom: 2px;
    font-size: 14px;
}

.search-result-category {
    font-size: 12px;
    color: #6c757d;
    font-style: italic;
}

.search-result-price {
    font-weight: 600;
    color: #28a745;
    font-size: 14px;
    margin-left: auto;
}

/* Imágenes de resultados de búsqueda - Miniaturas */
.search-result-item img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    object-position: center;
    border-radius: 6px;
    flex-shrink: 0;
}

/* Fallback para imágenes sin src */
.search-result-item img[src*="data:image/svg+xml"] {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
}

/* Mensaje sin resultados */
/* Sin resultados */
.search-no-results {
    padding: 20px;
    text-align: center;
    color: #6c757d;
    font-style: italic;
}

/* Loading de búsqueda */
.search-loading {
    padding: 20px;
    text-align: center;
    color: #6c757d;
}

.search-loading .spinner-border {
    width: 1.5rem;
    height: 1.5rem;
    margin-right: 8px;
}

/* Responsive para búsqueda */
@media (max-width: 768px) {
    .search-container {
        margin-bottom: 1rem;
        max-width: 100%;
    }
    
    .search-input {
        padding: 12px 45px 12px 16px;
        font-size: 16px; /* Evita zoom en iOS */
        border-radius: 25px;
    }
    
    .search-icon {
        right: 16px;
        font-size: 16px;
    }
    
    .search-results {
        max-height: 300px;
    }
    
    .search-result-item {
        padding: 10px 14px;
    }
    
    .search-result-image {
        width: 35px;
        height: 35px;
    }
}

@media (max-width: 576px) {
    .search-container {
        margin-bottom: 0.75rem;
    }
    
    .search-input {
        padding: 10px 40px 10px 14px;
        font-size: 14px;
        border-radius: 20px;
    }
    
    .search-icon {
        right: 14px;
        font-size: 14px;
    }
    
    .search-results {
        max-height: 250px;
    }
    
    .search-result-item {
        padding: 8px 12px;
        gap: 8px;
    }
    
    .search-result-image {
        width: 30px;
        height: 30px;
    }
    
    .search-result-title {
        font-size: 13px;
    }
    
    .search-result-category {
        font-size: 11px;
    }
    
    .search-result-price {
        font-size: 13px;
    }
} 