/* ============================================
   ESTILOS DEL NUEVO BUSCADOR CON MODO IA
   ============================================ */

/* Cabecera con imagen de fondo */
.NH_cabecera_bg {
    background-image: url(https://docenzia1.b-cdn.net/img_home_docenzia.webp);
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center center;
    position: relative;
    margin-bottom: 50px;
    margin-top: -120px;
    z-index: 1;
}

/* Contenedor principal del buscador */
.buscador_at {
    position: relative;
    width: 100%;
    margin: 0 auto;
}

/* Wrapper del buscador con esquinas redondeadas */
.search-wrapper {
    background: white;
    border-radius: 50px;
    padding: 4px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    position: relative;
}

/* Contenedor flex para los elementos del buscador */
.search-container {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px;
}

/* Icono de lupa a la izquierda */
.search-icon {
    margin-left: 20px;
    color: #9ca3af;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-icon svg {
    width: 22px;
    height: 22px;
}

/* Input del buscador - Actualizado para mantener compatibilidad */
.buscador_at input[type="text"] {
    flex: 1;
    border: none !important;
    outline: none !important;
    font-size: 16px;
    color: #1f2937;
    padding: 14px 8px !important;
    background: transparent !important;
    font-weight: 400;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    width: 100%;
    margin: 0 !important;
}

.buscador_at input[type="text"]::placeholder {
    color: #9ca3af;
}

.buscador_at input[type="text"]:focus {
    outline: none !important;
    background: transparent !important;
}

/* ============================================
   BOTÓN MODO IA MEJORADO - Estilo Google Premium
   ============================================ */

.ai-mode-button {
    background: #f9fafb;
    border: 1.5px solid #e5e7eb;
    border-radius: 24px;
    padding: 10px 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    font-size: 14px;
    color: #6b7280;
    font-weight: 600;
    margin-right: 12px;
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: visible;
}

/* Efecto de borde animado al hover - Estilo Docenzia */
.ai-mode-button::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(
        90deg,
        #FDA629,
        #F59200,
        #E68A00,
        #FBBF24,
        #10b981,
        #FDA629
    );
    background-size: 300% 300%;
    border-radius: 25px;
    opacity: 0;
    z-index: -1;
    transition: opacity 0.3s ease;
    animation: gradientRotate 3s linear infinite;
}

@keyframes gradientRotate {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.ai-mode-button::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f9fafb;
    border-radius: 23px;
    z-index: -1;
}

.ai-mode-button:hover::before {
    opacity: 1;
}

.ai-mode-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

/* Estado activo del botón - Azul #4752c4 */
.ai-mode-button.active {
    background: #4752c4;
    color: white;
    border: 1.5px solid transparent;
    box-shadow: 0 4px 12px rgba(71, 82, 196, 0.4);
}

.ai-mode-button.active::before {
    background: linear-gradient(
        90deg,
        #5865f2,
        #4752c4,
        #3b47a8,
        #5865f2,
        #34d399,
        #4752c4,
        #5865f2
    );
    opacity: 1;
    animation: gradientRotate 2s linear infinite;
}

.ai-mode-button.active::after {
    background: #4752c4;
}

.ai-mode-button.active:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(71, 82, 196, 0.5);
}

/* Icono del botón */
.ai-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.ai-icon svg {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
}

.ai-mode-button:hover .ai-icon svg {
    transform: rotate(20deg) scale(1.1);
}

.ai-mode-button.active .ai-icon svg {
    color: white;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* Texto del botón */
.ai-mode-button span:not(.ai-icon):not(.ai-badge) {
    position: relative;
    z-index: 1;
}

/* Badge ON mejorado - CORREGIDO */
.ai-badge {
    position: absolute;
    top: -10px;
    right: -10px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    font-size: 10px;
    padding: 3px 7px;
    border-radius: 12px;
    font-weight: 700;
    display: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
    z-index: 10;
    white-space: nowrap;
}

.ai-mode-button.active .ai-badge {
    display: block;
    animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 4px 12px rgba(16, 185, 129, 0.6);
    }
}

/* Animación suave al cambiar de estado */
.ai-mode-button * {
    transition: all 0.3s ease;
}

/* Efectos visuales cuando el modo IA está activo - Branding Docenzia */
@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    }
    25% {
        box-shadow: 0 20px 60px rgba(253, 166, 41, 0.3),
                    0 0 40px rgba(245, 146, 0, 0.2);
    }
    50% {
        box-shadow: 0 20px 60px rgba(245, 146, 0, 0.35),
                    0 0 50px rgba(253, 166, 41, 0.25);
    }
    75% {
        box-shadow: 0 20px 60px rgba(253, 166, 41, 0.3),
                    0 0 40px rgba(245, 146, 0, 0.2);
    }
}

.search-wrapper.ai-active {
    animation: glowPulse 3s ease-in-out infinite;
}

/* Loading spinner - Branding Docenzia */
.loading-spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f4f6;
    border-top-color: #FDA629;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 12px;
}

.search-container.searching .loading-spinner {
    display: block;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   NOTIFICACIÓN DEBAJO DEL BUSCADOR
   ============================================ */
.ai-notification-below {
    position: relative;
    margin-top: 12px;
    margin-bottom: 8px;
    background: #10b981;
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
    font-size: 14px;
    font-weight: 600;
    z-index: 10;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    min-height: 42px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.ai-notification-below.show {
    opacity: 1;
    visibility: visible;
}

/* Modo IA activado - Verde */
.ai-notification-below.active {
    background: #10b981;
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
}

/* Modo IA desactivado - Gris */
.ai-notification-below.inactive {
    background: #6b7280;
    box-shadow: 0 8px 20px rgba(107, 114, 128, 0.3);
}

/* Advertencias - Naranja */
.ai-notification-below.warning {
    background: #f59e0b;
    box-shadow: 0 8px 20px rgba(245, 158, 11, 0.3);
}

/* Éxito - Verde */
.ai-notification-below.success {
    background: #10b981;
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
}

/* Error - Rojo */
.ai-notification-below.error {
    background: #ef4444;
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.3);
}

/* Info - Azul */
.ai-notification-below.info {
    background: #3b82f6;
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.3);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   RESULTADOS DEL BUSCADOR
   ============================================ */

/* CLASE ESPECÍFICA PARA ESTE BUSCADOR - Sobreescribe estilos globales */
.buscador-instantaneo .contenedor_resultados {
    border: 1px solid #FDA629 !important;
    background: #fff !important;
    position: absolute !important;
    top: 64px !important;
    width: 100% !important;
    left: 0 !important;
    right: 0 !important;
    text-align: left !important;
    z-index: 80 !important;
    -webkit-box-shadow: 0 8px 12px rgba(0, 0, 0, 0.25) !important;
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.25) !important;
    max-height: 485px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    border-radius: 12px !important;
    box-sizing: border-box !important;
    margin: 0 !important;
}

.buscador-instantaneo .contenedor_resultados:empty {
    display: none !important;
}

/* Ajustar padding interno para que coincida con el buscador */
.buscador-instantaneo .contenedor_resultados .tr_especialidades h4,
.buscador-instantaneo .contenedor_resultados .tr_centros h4 {
    padding: 10px 18px !important;
    margin: 0 !important;
}

.buscador-instantaneo .contenedor_resultados .tr_especialidades ul,
.buscador-instantaneo .contenedor_resultados .tr_centros ul {
    padding: 15px !important;
    margin: 0 !important;
}

/* Asegurar que los elementos internos no sobresalgan */
.buscador-instantaneo .contenedor_resultados .tr_centros ul li a {
    display: flex !important;
    gap: 10px !important;
    align-items: center !important;
    flex-wrap: wrap !important;
}

.buscador-instantaneo .contenedor_resultados .txt_tr_centros {
    width: auto !important;
    flex: 1 !important;
    min-width: 0 !important;
}

/* Sección de respuesta IA cuando está activo - Branding Docenzia */
.ai-response-section {
    padding: 16px 20px;
    background: linear-gradient(135deg, #FDA629 0%, #F59200 100%);
    color: white;
    border-radius: 12px 12px 0 0;
    display: none;
}

.ai-response-section h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-response-section p {
    margin: 0;
    line-height: 1.5;
    font-size: 14px;
}

.search-wrapper.ai-active + .contenedor_resultados .ai-response-section {
    display: block;
}

/* ============================================
   ENLACE BUSCADOR AVANZADO
   ============================================ */

.enlace_buscador_avanzado {
    text-align: center;
    margin-top: 1px;
}

.enlace_buscador_avanzado a {
    background: linear-gradient(135deg, #FDA629 0%, #F59200 100%);
    color: white;
    text-decoration: none;
    padding: 18px 36px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 24px rgba(253, 166, 41, 0.3);
    transition: all 0.2s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.enlace_buscador_avanzado a:hover {
    background: linear-gradient(135deg, #F59200 0%, #E68A00 100%);
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(253, 166, 41, 0.4);
}

.enlace_buscador_avanzado a img {
    filter: brightness(0) invert(1);
}

/* ============================================
   BOTÓN DE ENVÍO PARA MODO IA (MÓVILES)
   ============================================ */

.ai-submit-button {
    background: linear-gradient(135deg, #FDA629 0%, #F59200 100%);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-right: 8px;
    box-shadow: 0 4px 12px rgba(253, 166, 41, 0.3);
}

.ai-submit-button:hover {
    background: linear-gradient(135deg, #F59200 0%, #E68A00 100%);
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(253, 166, 41, 0.4);
}

.ai-submit-button:active {
    transform: scale(0.95);
}

.ai-submit-button svg {
    color: white;
    transform: rotate(0deg);
    transition: transform 0.2s ease;
}

.ai-submit-button:hover svg {
    transform: rotate(15deg);
}

/* Ocultar en desktop si hay Enter disponible */
@media (min-width: 1024px) {
    .ai-submit-button {
        display: none !important;
    }
}

/* ============================================
   RESPONSIVE - TABLET
   ============================================ */

@media (max-width: 1024px) {
    .search-icon {
        margin-left: 16px;
    }

    .ai-mode-button {
        padding: 9px 16px;
        font-size: 13.5px;
        margin-right: 10px;
    }
}

/* ============================================
   RESPONSIVE - MÓVIL
   ============================================ */

@media (max-width: 768px) {
    /* Eliminar margin-top negativo y ajustar logo/menú en móvil */
    .logomenu.logomenuhome {
        position: absolute;
        z-index: 100;
        width: 100%;
    }

    .NH_cabecera_bg {
        margin-top: 0 !important;
    }

    .search-icon {
        margin-left: 12px;
    }

    .search-icon svg {
        width: 18px;
        height: 18px;
    }

    .buscador_at input[type="text"] {
        font-size: 14px;
        padding: 12px 6px !important;
    }

    .ai-mode-button {
        padding: 8px 14px;
        font-size: 13px;
        margin-right: 8px;
    }

    .ai-icon {
        width: 16px;
        height: 16px;
    }

    .ai-icon svg {
        width: 16px;
        height: 16px;
    }

    .ai-badge {
        top: -8px;
        right: -8px;
        font-size: 9px;
        padding: 2px 6px;
        border-radius: 10px;
    }

    .enlace_buscador_avanzado a {
        padding: 14px 24px;
        font-size: 14px;
    }

    .buscador-instantaneo .contenedor_resultados {
        max-height: 285px !important;
    }

    .ai-notification-below {
        font-size: 12px;
        padding: 10px 16px;
        margin-top: 10px;
        margin-bottom: 6px;
        min-height: 38px;
    }

    .enlace_buscador_avanzado {
        margin-top: 16px;
    }

    .ai-submit-button {
        width: 40px;
        height: 40px;
        margin-right: 6px;
    }

    .ai-submit-button svg {
        width: 18px;
        height: 18px;
    }
}

/* ============================================
   RESPONSIVE - MÓVIL PEQUEÑO
   ============================================ */

@media (max-width: 480px) {
    /* Eliminar margin-top negativo y ajustar logo/menú en móvil pequeño */
    .logomenu.logomenuhome {
        position: absolute;
        z-index: 100;
        width: 100%;
    }

    .NH_cabecera_bg {
        margin-top: 0 !important;
    }

    .search-wrapper {
        padding: 3px;
    }

    .search-container {
        gap: 6px;
        padding: 3px;
    }

    .search-icon {
        margin-left: 10px;
    }

    .search-icon svg {
        width: 16px;
        height: 16px;
    }

    .buscador_at input[type="text"] {
        font-size: 13px;
        padding: 10px 4px !important;
    }

    .ai-mode-button {
        padding: 7px 12px;
        font-size: 12px;
        margin-right: 6px;
        gap: 6px;
    }

    .ai-icon {
        width: 14px;
        height: 14px;
    }

    .ai-icon svg {
        width: 14px;
        height: 14px;
    }

    .ai-badge {
        top: -7px;
        right: -7px;
        font-size: 8px;
        padding: 2px 5px;
    }

    .enlace_buscador_avanzado a {
        padding: 12px 20px;
        font-size: 13px;
        gap: 8px;
    }

    .ai-notification-below {
        font-size: 11px;
        padding: 8px 12px;
        margin-top: 8px;
        min-height: 36px;
    }
}

/* ============================================
   ANIMACIONES ADICIONALES Y EFECTOS PREMIUM
   ============================================ */

/* Efecto de brillos sutiles en el borde (opcional - más sutil) */
@keyframes shimmer {
    0% {
        background-position: -200% center;
    }
    100% {
        background-position: 200% center;
    }
}

/* Mejora de accesibilidad - Focus visible */
.ai-mode-button:focus-visible {
    outline: 2px solid #5865f2;
    outline-offset: 2px;
}

.buscador_at input[type="text"]:focus-visible {
    outline: 2px solid #5865f2;
    outline-offset: -2px;
    border-radius: 8px;
}

/* Prevenir selección de texto en el botón */
.ai-mode-button {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Suavizar todas las transiciones */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Optimización para dispositivos táctiles */
@media (hover: none) and (pointer: coarse) {
    .ai-mode-button:hover {
        transform: none;
    }

    .ai-mode-button:active {
        transform: scale(0.98);
    }
}

/* ============================================
   OCULTAR RESULTADOS CUANDO MODO IA ESTÁ ACTIVO
   ============================================ */
.search-wrapper.ai-active ~ .contenedor_resultados {
    display: none !important;
}
