/* =============================================
   YO SÍ SÉ - ESTILOS ADICIONALES SEGUROS
   Solo agrega mejoras sin romper lo existente
   ============================================= */

/* =============== MEJORAS VISUALES (No destructivas) =============== */

/* Mejora de transiciones globales */
* {
    transition: none !important; /* Desactivar primero */
}

/* Aplicar transiciones solo donde se necesitan */
a, button, .btn, .product-card, .wishlist-btn,
.nav-link, .search-input, .modal, .dropdown-menu {
    transition: all 0.3s ease !important;
}

/* =============== CORRECCIONES ESPECÍFICAS =============== */

/* Fix para el botón de wishlist */
.wishlist-btn {
    z-index: 10;
    cursor: pointer;
}

.wishlist-btn:not(.active) i.bi-heart-fill {
    display: none;
}

.wishlist-btn.active i.bi-heart {
    display: none;
}

.wishlist-btn.active i.bi-heart-fill {
    display: inline-block;
    color: #ef4444;
}

/* Fix para search suggestions */
.search-suggestions {
    position: absolute;
    background: white;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    border-radius: 8px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
}

.search-suggestions.active {
    display: block !important;
}

.search-suggestions:not(.active) {
    display: none !important;
}

/* Fix para location indicators */
.location-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
}

.location-indicator.active {
    background: #10b981;
    color: white;
}

.location-indicator.error,
.location-indicator.denied,
.location-indicator.unavailable {
    background: #fef3c7;
    color: #92400e;
}

.location-indicator.prompt {
    background: #dbeafe;
    color: #1e40af;
}

/* Fix para el navbar en scroll */
.navbar {
    transition: transform 0.3s ease, box-shadow 0.3s ease !important;
}

.navbar.scrolled {
    box-shadow: 0 2px 10px rgba(0,0,0,0.1) !important;
}

/* Fix para productos grid responsive */
.products-grid,
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .products-grid,
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }
}

/* Fix para modales Bootstrap */
.modal.show {
    display: block !important;
}

.modal-backdrop {
    background-color: rgba(0,0,0,0.5);
}

/* Fix para notifications */
.notification-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    pointer-events: none;
}

.notification {
    pointer-events: auto;
    margin-bottom: 10px;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Fix para back to top button */
#backToTop,
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 48px;
    height: 48px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

#backToTop.show,
.back-to-top.show {
    display: flex !important;
}

#backToTop:hover,
.back-to-top:hover {
    background: #1d4ed8;
    transform: translateY(-4px);
}

/* =============== MEJORAS DE ACCESIBILIDAD =============== */

/* Focus visible para teclado */
*:focus-visible {
    outline: 2px solid #2563eb !important;
    outline-offset: 2px !important;
}

/* Skip to content link */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: #2563eb;
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-to-content:focus {
    top: 0;
}

/* =============== MEJORAS DE PERFORMANCE =============== */

/* Lazy loading images */
img[data-src] {
    filter: blur(5px);
    transition: filter 0.3s;
}

img[data-src].loaded {
    filter: blur(0);
}

/* Skeleton loading */
.skeleton {
    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; }
}

/* =============== MEJORAS ESPECÍFICAS DE COMPONENTES =============== */

/* Product cards hover mejora */
.product-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease !important;
}

.product-card:hover {
    transform: translateY(-4px) !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1) !important;
}

/* Dropdown mejorado */
.dropdown-menu {
    animation: fadeIn 0.2s ease;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    border: 1px solid rgba(0,0,0,0.05);
}

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

/* Forms mejora */
.form-control:focus,
input:focus,
textarea:focus,
select:focus {
    border-color: #2563eb !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1) !important;
}

/* Buttons mejora */
.btn {
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::after {
    width: 300px;
    height: 300px;
}

/* Badge mejoras */
.badge {
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
}

/* =============== UTILIDADES ADICIONALES =============== */

/* Sombras mejoradas */
.shadow-sm { box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important; }
.shadow { box-shadow: 0 4px 6px rgba(0,0,0,0.1) !important; }
.shadow-lg { box-shadow: 0 10px 25px rgba(0,0,0,0.1) !important; }
.shadow-xl { box-shadow: 0 20px 40px rgba(0,0,0,0.15) !important; }

/* Bordes redondeados */
.rounded-sm { border-radius: 0.25rem !important; }
.rounded { border-radius: 0.5rem !important; }
.rounded-lg { border-radius: 0.75rem !important; }
.rounded-xl { border-radius: 1rem !important; }
.rounded-2xl { border-radius: 1.5rem !important; }
.rounded-full { border-radius: 9999px !important; }

/* Colores de texto */
.text-primary { color: #2563eb !important; }
.text-success { color: #22c55e !important; }
.text-danger { color: #ef4444 !important; }
.text-warning { color: #f59e0b !important; }
.text-info { color: #3b82f6 !important; }

/* Backgrounds */
.bg-primary-light { background-color: #eff6ff !important; }
.bg-success-light { background-color: #f0fdf4 !important; }
.bg-danger-light { background-color: #fef2f2 !important; }
.bg-warning-light { background-color: #fffbeb !important; }

/* =============== MOBILE RESPONSIVE FIXES =============== */

@media (max-width: 768px) {
    /* Mobile menu fix */
    .navbar-nav {
        background: white;
        box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    }

    .navbar-nav.active {
        display: flex !important;
    }

    /* Search box mobile */
    .search-container {
        padding: 0 1rem;
    }

    .search-box {
        width: 100%;
    }

    /* Modals mobile */
    .modal-dialog {
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }

    /* Product cards mobile */
    .product-card {
        margin-bottom: 1rem;
    }
}

/* =============== PRINT STYLES =============== */

@media print {
    .navbar,
    .footer,
    .back-to-top,
    .notification-container,
    .modal,
    .btn-print-hide {
        display: none !important;
    }

    .container {
        max-width: 100%;
    }

    a[href]:after {
        content: none !important;
    }
}

/* =============== DARK MODE SUPPORT (Opcional) =============== */

@media (prefers-color-scheme: dark) {
    /* Solo si quieres auto dark mode */
    /*
    body {
        background: #1a1a1a;
        color: #e0e0e0;
    }

    .navbar,
    .product-card,
    .modal-content,
    .search-suggestions {
        background: #2a2a2a;
        color: #e0e0e0;
    }
    */
}

/* =============== ANIMATIONS MEJORADAS =============== */

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.animate-pulse {
    animation: pulse 2s infinite;
}

.animate-shake {
    animation: shake 0.5s;
}

/* =============== LOADING STATES =============== */

.loading-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2563eb;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* =============== TOOLTIPS CUSTOM =============== */

[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
}

/* =============== SCROLL BAR CUSTOM =============== */

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* =============== FIX ESPECÍFICOS PARA ERRORES CONOCIDOS =============== */

/* Fix para el error de GeolocationPositionError */
.location-error-message {
    padding: 1rem;
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    border-radius: 4px;
    margin-bottom: 1rem;
}

/* Fix para wishlist 404 */
.wishlist-btn[data-product-slug] {
    cursor: pointer;
}

/* Fix para syntax error en main.js - asegurar que los elementos existen */
.search-input,
.search-btn,
.voice-search-btn {
    pointer-events: auto;
}

/* =============== MEJORAS FINALES =============== */

/* Asegurar que los enlaces son clickeables */
a, button, [role="button"], .btn {
    cursor: pointer;
}

/* Mejorar legibilidad */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Prevenir text overflow */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Container max width fix */
.container {
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
}

@media (min-width: 576px) {
    .container { max-width: 540px; }
}

@media (min-width: 768px) {
    .container { max-width: 720px; }
}

@media (min-width: 992px) {
    .container { max-width: 960px; }
}

@media (min-width: 1200px) {
    .container { max-width: 1140px; }
}

@media (min-width: 1400px) {
    .container { max-width: 1320px; }
}

/* Toast notifications */
.toast {
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Wishlist button hover cuando no está autenticado */
.wishlist-btn:not(.authenticated):hover::after {
    content: "Iniciar sesión";
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
}

/* Animación para búsqueda por voz */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
        transform: scale(1.05);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
        transform: scale(1);
    }
}

.voice-search-btn.recording {
    background-color: #fef2f2 !important;
    border-color: #ef4444 !important;
}

.voice-search-btn.recording i {
    animation: pulse 1.5s infinite;
}

/* Estilo para input mientras se habla */
.search-input[style*="italic"] {
    color: #6b7280;
}

/* Selector de tipo de búsqueda - VERSIÓN CORREGIDA */
.search-type-selector {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: #f8f9fa;
    border-radius: 10px;
    cursor: pointer;
    user-select: none;
    transition: all 0.3s ease;
    min-width: 120px;
    z-index: 10; /* Asegurar que esté por encima */
}

.search-type-selector:hover {
    background: #e9ecef;
}

.search-type-selector.active {
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1001; /* Mayor z-index cuando está activo */
}

.search-type-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999; /* Z-index alto para asegurar visibilidad */
    min-width: 200px;
    max-height: 300px;
    overflow-y: auto;
}

.search-type-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.search-type-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #495057;
    background: white;
    border: none;
    width: 100%;
    text-align: left;
}

.search-type-option:hover {
    background: #f8f9fa;
    color: #212529;
    padding-left: 20px;
}

.search-type-option.active {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    color: #667eea;
    font-weight: 600;
}

.search-type-option i {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.search-type-option span {
    font-size: 14px;
    font-weight: 500;
}

/* Fix para el chevron */
.search-type-selector .bi-chevron-down {
    font-size: 12px;
    transition: transform 0.3s ease;
    color: #6c757d;
    margin-left: auto;
    pointer-events: none;
}

/* Asegurar que el selector padre tenga overflow visible */
.search-box,
.search-container,
.search-input-group {
    position: relative;
    overflow: visible !important;
}

/* Para dispositivos móviles */
@media (max-width: 768px) {
    .search-type-dropdown {
        position: fixed;
        left: 10px;
        right: 10px;
        top: auto;
        bottom: auto;
        margin-top: 60px;
        width: calc(100% - 20px);
        max-width: 400px;
        margin-left: auto;
        margin-right: auto;
    }
}

/* ==================== CORRECCIÓN SUGERENCIAS DE BÚSQUEDA HERO ==================== */

/* Contenedor del formulario de búsqueda hero */
.hero-search-form {
    position: relative;
    z-index: 10;
}

/* Grupo de input debe ser relativo para contener las sugerencias */
.hero-search .search-input-group {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-2xl);
    padding: var(--space-xs);
    transition: all var(--transition);
    z-index: 20;
}

/* Las sugerencias deben estar FUERA del search-input-group */
.hero-search .search-suggestions {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.15);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

/* Estado activo de las sugerencias */
.hero-search .search-suggestions.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Contenido de sugerencias */
.hero-search .suggestion-item {
    padding: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    cursor: pointer;
    transition: background var(--transition-fast);
    border-bottom: 1px solid var(--gray-50);
    background: white;
}

.hero-search .suggestion-item:last-child {
    border-bottom: none;
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.hero-search .suggestion-item:first-child {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.hero-search .suggestion-item:hover {
    background: var(--gray-50);
}

.hero-search .suggestion-content {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex: 1;
}

.hero-search .suggestion-content img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: var(--radius);
    background: var(--gray-100);
}

.hero-search .suggestion-info {
    flex: 1;
    min-width: 0;
}

.hero-search .suggestion-title {
    font-weight: 500;
    color: var(--gray-800);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hero-search .suggestion-title strong {
    color: var(--primary);
    font-weight: 600;
}

.hero-search .suggestion-meta {
    font-size: 0.875rem;
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hero-search .badge {
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.hero-search .badge.badge-success {
    background: var(--accent-light);
    color: var(--accent-dark);
}

/* Loading state */
.hero-search .search-loading {
    padding: var(--space-xl);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
}

.hero-search .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* No results */
.hero-search .no-results {
    padding: var(--space-xl);
    text-align: center;
    color: var(--gray-500);
}

.hero-search .no-results i {
    font-size: 2rem;
    color: var(--gray-300);
    margin-bottom: var(--space-sm);
}

/* Overlay para cerrar sugerencias */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
    display: none;
}

.search-overlay.active {
    display: block;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .hero-search .search-suggestions {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        max-height: 70vh;
        z-index: 1001;
    }

    .hero-search .search-suggestions.active {
        animation: slideUp 0.3s ease;
    }

    @keyframes slideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }

    .hero-search .suggestion-item {
        padding: var(--space-lg);
    }
}

/* Dark mode support */
body.dark-mode .hero-search .search-suggestions {
    background: var(--gray-50);
    border-color: var(--gray-200);
}

body.dark-mode .hero-search .suggestion-item {
    background: var(--gray-50);
    border-bottom-color: var(--gray-100);
}

body.dark-mode .hero-search .suggestion-item:hover {
    background: var(--gray-100);
}

body.dark-mode .hero-search .suggestion-title {
    color: var(--gray-800);
}

body.dark-mode .hero-search .suggestion-meta {
    color: var(--gray-500);
}

/* Z-index management para evitar conflictos */
.hero-search {
    position: relative;
    z-index: 10;
}

.hero-content {
    position: relative;
    z-index: 1;
}

/* Asegurar que los botones de acción no se superpongan */
.hero-content .d-flex.gap-3 {
    position: relative;
    z-index: 5;
}

/* Estadísticas también deben estar debajo */
.hero-stats {
    position: relative;
    z-index: 5;
}
