/* AI GNLBot - Estilo Moderno Inspirado en Chat de Equipo v2.1 */
:root {
    --chatbot-primary: #001E3D;
    --chatbot-secondary: #8BC34A;
    --chatbot-primary-light: rgba(0, 30, 61, 0.1);
    --chatbot-secondary-light: rgba(139, 195, 74, 0.1);
    --chatbot-shadow: 0 4px 20px rgba(0, 30, 61, 0.15);
    --chatbot-shadow-hover: 0 6px 25px rgba(0, 30, 61, 0.2);
    --chatbot-gradient-primary: linear-gradient(135deg, #8BC34A 0%, #001E3D 100%);
    --chatbot-gradient-secondary: linear-gradient(135deg, #8BC34A 0%, #7CB342 100%);
    --chatbot-gradient-mixed: linear-gradient(135deg, #8BC34A 0%, #001E3D 100%);
    --chatbot-bg-light: #f8faf9;
    --chatbot-border-radius: 16px;
}

/* SVG Gradientes para Iconos */
.ai-chatbot-svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* Eliminar cualquier elemento azul no deseado */
.ai-chatbot-widget *,
.ai-chatbot-toggle *,
.ai-chatbot-container * {
    box-sizing: border-box;
}

/* Widget Principal del Chatbot - Estilo Chat de Equipo */
.ai-chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 350px;
    height: 500px;
    max-height: calc(100vh - 40px);
    background: white;
    border-radius: var(--chatbot-border-radius);
    pointer-events: none;
    box-shadow: var(--chatbot-shadow);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    overflow: hidden;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, opacity;
    border: 1px solid rgba(0, 30, 61, 0.08);
}

/* Esquina Inferior Derecha (Por defecto) */
.ai-chatbot-widget.bottom-right {
    bottom: 20px;
    right: 20px;
    transform: translateY(15px); /* Posición inicial para la animación */
}

/* Esquina Inferior Izquierda */
.ai-chatbot-widget.bottom-left {
    bottom: 20px;
    left: 20px;
    transform: translateY(15px);
}

/* Esquina Superior Derecha */
.ai-chatbot-widget.top-right {
    top: 20px;
    right: 20px;
    transform: translateY(-15px); /* La animación viene desde arriba */
}

/* Esquina Superior Izquierda */
.ai-chatbot-widget.top-left {
    top: 20px;
    left: 20px;
    transform: translateY(-15px);
}

.ai-chatbot-widget.show {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* Botón Flotante Toggle solo con imagen */
.ai-chatbot-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 70px;
    height: 70px;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--chatbot-shadow);
    z-index: 1000000;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 3px solid white;
    will-change: transform, box-shadow;
    overflow: hidden;
}

/* Posiciones del botón toggle en desktop */
.ai-chatbot-toggle.bottom-right {
    bottom: 20px;
    right: 20px;
    left: auto;
    top: auto;
}

.ai-chatbot-toggle.bottom-left {
    bottom: 20px;
    left: 20px;
    right: auto;
    top: auto;
}

.ai-chatbot-toggle.top-right {
    top: 20px;
    right: 20px;
    left: auto;
    bottom: auto;
}

.ai-chatbot-toggle.top-left {
    top: 20px;
    left: 20px;
    right: auto;
    bottom: auto;
}

.ai-chatbot-toggle::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('https://galapagos-tours.org/wp-content/uploads/2025/02/Galapagos-Islands.png');
    background-size: cover;
    background-position: center;
    border-radius: 50%;
    z-index: 1;
}

.ai-chatbot-toggle:hover {
    transform: scale(1.05);
    box-shadow: var(--chatbot-shadow-hover);
}

.ai-chatbot-toggle:active {
    transform: scale(0.95);
}

.ai-chatbot-toggle img,
.ai-chatbot-toggle svg {
    display: none !important; /* Oculta cualquier icono SVG anterior */
}

/* Header del Chat - Estilo Moderno con Avatar y degradado */
.ai-chatbot-header {
    background: var(--chatbot-gradient-primary);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    min-height: 60px;
    height: 60px;
    position: relative;
    border-radius: var(--chatbot-border-radius) var(--chatbot-border-radius) 0 0;
    box-shadow: 0 2px 4px rgba(0, 30, 61, 0.1);
}

.ai-chatbot-header::before {
    content: '';
    width: 36px;
    height: 36px;
    background-image: url('https://galapagos-tours.org/wp-content/uploads/2025/02/Galapagos-Islands.png');
    background-size: cover;
    background-position: center;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    flex-shrink: 0;
    display: block;
}

.ai-chatbot-header-info {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.ai-chatbot-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: white !important;
    line-height: 1.2;
}

.ai-chatbot-header .team-info {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-chatbot-header .status-indicator {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #4CAF50;
    border-radius: 50%;
    margin-right: 4px;
}

/* Botón de Cerrar - Estilo Minimalista */
.ai-chatbot-close {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.ai-chatbot-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.ai-chatbot-close svg {
    width: 14px;
    height: 14px;
    stroke-width: 2;
}

/* Área de Mensajes - OPTIMIZADA PARA SCROLL PERFECTO */
.ai-chatbot-messages {
    flex: 1;
    padding: 12px 14px;
    padding-bottom: 75px;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    background: var(--chatbot-bg-light);
    position: relative;
    /* ALTURA FIJA PARA SCROLL CONFIABLE */
    height: 350px !important;
    min-height: 350px !important;
    max-height: 450px !important;
    /* Scroll completamente invisible */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* Internet Explorer 10+ */
    
    /* COMPORTAMIENTO DE SCROLL OPTIMIZADO */
    display: block !important;
    box-sizing: border-box !important;
}

/* Scrollbar invisible para todos los navegadores WebKit */
.ai-chatbot-messages::-webkit-scrollbar { 
    display: none;
    width: 0px; 
    background: transparent; 
    opacity: 0;
}
.ai-chatbot-messages::-webkit-scrollbar-track { 
    display: none;
    background: transparent; 
    opacity: 0;
}
.ai-chatbot-messages::-webkit-scrollbar-thumb { 
    display: none;
    background: transparent; 
    opacity: 0;
}
.ai-chatbot-messages::-webkit-scrollbar-thumb:hover { 
    display: none;
    background: transparent; 
    opacity: 0;
}
.ai-chatbot-messages::-webkit-scrollbar-corner {
    display: none;
    background: transparent;
}

/* Mensajes - Estilo Moderno sin Avatars con espaciado optimizado */
.ai-message,
.user-message {
    margin-bottom: 8px;
    display: flex;
    align-items: flex-start;
    animation: messageSlide 0.3s ease-out;
    position: relative;
    padding: 0 4px;
}

/* Clasificación específica por tipo de mensaje */
[data-sender="user"] {
    justify-content: flex-end;
}

[data-sender="bot"] {
    justify-content: flex-start;
}

[data-message-type="user_message"] {
    justify-content: flex-end;
}

[data-message-type="bot_message"] {
    justify-content: flex-start;
}

@keyframes messageSlide {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-message { 
    justify-content: flex-start; 
}
.user-message { 
    justify-content: flex-end; 
}

/* Burbujas de Mensaje - Diseño Moderno con espaciado optimizado */
.message-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 18px;
    line-height: 1.3;
    font-size: 14px;
    word-wrap: break-word;
    position: relative;
    transition: all 0.2s ease;
    margin: 0;
}

/* Burbujas específicas por tipo */
.user-bubble {
    background: var(--chatbot-gradient-primary);
    color: white;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 2px 8px rgba(0, 30, 61, 0.15);
}

.bot-bubble {
    background: white;
    color: #2c3e50;
    border: 1px solid rgba(0, 30, 61, 0.08);
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* Mensaje del Asistente - Estilo Izquierdo */
.ai-message .message-bubble {
    background: white;
    color: #2c3e50;
    border: 1px solid rgba(0, 30, 61, 0.08);
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* Mensaje del Usuario - Estilo Derecho con degradado */
.user-message .message-bubble {
    background: var(--chatbot-gradient-primary);
    color: white;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 2px 8px rgba(0, 30, 61, 0.15);
}

/* Marca de Tiempo optimizada */
.message-time {
    font-size: 10px;
    color: rgba(0, 30, 61, 0.4);
    text-align: right;
    margin: 4px 0 0 0;
    display: block;
    line-height: 1;
}

/* Tiempo específico para usuarios y bots */
.user-time {
    color: rgba(255, 255, 255, 0.9) !important;
    text-align: right;
}

.bot-time {
    color: rgba(0, 30, 61, 0.5) !important;
    text-align: left;
}

/* Tiempo en mensajes del usuario (blanco para visibilidad) */
.user-message .message-time {
    color: rgba(255, 255, 255, 0.8);
}

/* Área de Input - Estilo Moderno */
.ai-chatbot-input-area {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 16px;
    border-top: 1px solid rgba(0, 30, 61, 0.08);
    border-radius: 0 0 var(--chatbot-border-radius) var(--chatbot-border-radius);
}

.ai-chatbot-input {
    display: flex;
    align-items: flex-end;
    width: 100%;
    gap: 8px;
}

.ai-chatbot-input textarea {
    flex: 1;
    border: 1px solid rgba(0, 30, 61, 0.12);
    border-radius: 20px;
    padding: 10px 16px;
    outline: none;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
    background: #f8faf9;
    resize: none;
    overflow-y: hidden;
    line-height: 1.4;
    max-height: 80px;
}

.ai-chatbot-input textarea:focus {
    border-color: var(--chatbot-secondary);
    background: white;
    box-shadow: 0 0 0 2px rgba(139, 195, 74, 0.15);
}

.ai-chatbot-input textarea::placeholder {
    color: rgba(0, 30, 61, 0.5);
    font-weight: 400;
    font-size: 14px;
}

/* Botón de Envío - Ícono con degradado sin fondo circular */
.ai-chatbot-send {
    background: transparent !important;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
    outline: none;
}

.ai-chatbot-send:hover:not(:disabled) {
    background: transparent !important;
    transform: scale(1.15);
}

.ai-chatbot-send:active:not(:disabled) {
    transform: scale(0.9);
}

.ai-chatbot-send:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

.ai-chatbot-send:focus {
    outline: none;
    background: transparent !important;
}

.ai-chatbot-send svg {
    width: 32px;
    height: 32px;
    transition: all 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0, 30, 61, 0.15));
}

.ai-chatbot-send:hover:not(:disabled) svg {
    filter: drop-shadow(0 4px 8px rgba(0, 30, 61, 0.3));
}

.ai-chatbot-send:disabled svg {
    filter: grayscale(100%) opacity(0.5);
}

/* Indicador de Escritura - Estilo Moderno con degradado */
.typing-indicator {
    display: none;
    padding: 6px 0;
    animation: messageSlide 0.3s ease-out;
}

.typing-indicator.show { 
    display: block; 
}

.typing-dots {
    display: inline-flex;
    gap: 4px;
    padding: 10px 16px;
    background: white;
    border-radius: 18px 18px 18px 4px;
    border: 1px solid rgba(0, 30, 61, 0.08);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--chatbot-gradient-secondary);
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes typing {
    0%, 80%, 100% { 
        transform: scale(0.8); 
        opacity: 0.5; 
    }
    40% { 
        transform: scale(1.2); 
        opacity: 1; 
    }
}

/* Responsive Design optimizado para móviles */
@media (max-width: 768px) {
    /* Widget del chat en móviles - Tamaño más compacto y estético */
    .ai-chatbot-widget {
        width: calc(100vw - 32px);
        height: 520px;
        max-height: calc(100vh - 140px);
        bottom: 16px;
        right: 16px;
        left: 16px;
        border-radius: 20px;
        margin: 0 auto;
    }
    
    /* Ajustes para diferentes posiciones en móvil */
    .ai-chatbot-widget.bottom-right,
    .ai-chatbot-widget.bottom-left {
        bottom: 16px;
        top: auto;
        left: 16px;
        right: 16px;
    }
    
    .ai-chatbot-widget.top-right,
    .ai-chatbot-widget.top-left {
        top: 80px;
        bottom: auto;
        left: 16px;
        right: 16px;
    }

    .ai-chatbot-messages {
        padding: 12px;
        padding-bottom: 85px;
        height: calc(100% - 126px);
        max-height: calc(100% - 126px);
    }

    .ai-chatbot-input-area {
        padding: 12px;
        border-radius: 0 0 20px 20px;
        height: 70px;
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
    }

    .ai-chatbot-close {
        top: 14px;
        right: 14px;
        width: 32px;
        height: 32px;
        border-radius: 8px;
    }

    .ai-chatbot-close svg {
        width: 16px;
        height: 16px;
    }

    .message-bubble {
        max-width: 80%;
        padding: 10px 14px;
        font-size: 14px;
        line-height: 1.4;
    }

    /* Botón flotante centrado en la parte inferior en móviles */
    .ai-chatbot-toggle {
        width: 64px;
        height: 64px;
        bottom: 20px;
        right: 50%;
        left: auto;
        transform: translateX(50%);
        box-shadow: 0 4px 16px rgba(0, 30, 61, 0.25);
        border-width: 2px;
    }
    
    .ai-chatbot-toggle:hover {
        transform: translateX(50%) scale(1.05);
    }
    
    .ai-chatbot-toggle:active {
        transform: translateX(50%) scale(0.95);
    }

    .ai-chatbot-toggle::before {
        width: 64px;
        height: 64px;
    }
    
    /* Header más compacto en móvil */
    .ai-chatbot-header {
        padding: 12px 16px;
        min-height: 56px;
        height: 56px;
        border-radius: 20px 20px 0 0;
    }
    
    .ai-chatbot-header::before {
        width: 32px;
        height: 32px;
    }
    
    .ai-chatbot-header h3 {
        font-size: 15px;
    }
    
    .ai-chatbot-header .team-info {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    /* Ajustes adicionales para pantallas muy pequeñas */
    .ai-chatbot-widget {
        width: calc(100vw - 24px);
        height: 480px;
        max-height: calc(100vh - 120px);
        bottom: 12px;
        right: 12px;
        left: 12px;
        border-radius: 18px;
    }
    
    .ai-chatbot-widget.top-right,
    .ai-chatbot-widget.top-left {
        top: 70px;
    }

    .ai-chatbot-messages {
        padding: 10px;
        padding-bottom: 80px;
        height: calc(100% - 120px);
        max-height: calc(100% - 120px);
    }

    .ai-chatbot-input-area {
        padding: 10px 12px;
        height: 64px;
        border-radius: 0 0 18px 18px;
    }
    
    .ai-chatbot-header {
        padding: 10px 14px;
        min-height: 52px;
        height: 52px;
        border-radius: 18px 18px 0 0;
    }
    
    .ai-chatbot-header::before {
        width: 28px;
        height: 28px;
    }
    
    .ai-chatbot-header h3 {
        font-size: 14px;
    }

    .message-bubble {
        padding: 9px 12px;
        font-size: 13px;
        max-width: 78%;
    }

    .ai-chatbot-toggle {
        width: 58px;
        height: 58px;
        bottom: 18px;
    }

    .ai-chatbot-toggle::before {
        width: 58px;
        height: 58px;
    }
}

@media (max-width: 360px) {
    /* Ajustes para pantallas extra pequeñas */
    .ai-chatbot-widget {
        width: calc(100vw - 20px);
        height: 450px;
        max-height: calc(100vh - 100px);
        bottom: 10px;
        right: 10px;
        left: 10px;
    }
    
    .ai-chatbot-toggle {
        width: 54px;
        height: 54px;
        bottom: 16px;
    }
    
    .ai-chatbot-toggle::before {
        width: 54px;
        height: 54px;
    }
}

@media (max-height: 600px) {
    .ai-chatbot-widget {
        bottom: 10px;
        height: calc(100vh - 80px);
    }
    .ai-chatbot-toggle {
        bottom: 10px;
    }
}

/* Estilos específicos para mensajes de disponibilidad */
.ai-message .message-content {
    line-height: 1.5;
    white-space: pre-line; /* Preserva saltos de línea */
}

.ai-message .message-content strong {
    font-weight: 600;
    color: var(--chatbot-primary);
}

.ai-message .message-content hr {
    border: none;
    height: 1px;
    background: rgba(0, 30, 61, 0.1);
    margin: 12px 0;
}

/* Mejorar la legibilidad de emojis y texto */
.message-content {
    font-size: 14px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Espaciado mejorado para listas */
.ai-message .message-content br + br {
    line-height: 0.5;
}

/* Estilo para enlaces en mensajes */
.message-content a {
    color: var(--chatbot-secondary);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1px dotted var(--chatbot-secondary);
    transition: all 0.3s ease;
    padding: 2px 4px;
    border-radius: 4px;
    background: linear-gradient(135deg, rgba(139, 195, 74, 0.1) 0%, rgba(139, 195, 74, 0.05) 100%);
}

.message-content a:hover {
    color: var(--chatbot-primary);
    background: linear-gradient(135deg, rgba(139, 195, 74, 0.2) 0%, rgba(139, 195, 74, 0.1) 100%);
    border-bottom: 1px solid var(--chatbot-secondary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(139, 195, 74, 0.3);
}

/* Estilo específico para enlaces de yates */
.message-content a[href*="yacht"],
.message-content a[href*="boat"],
.message-content a[href*="yacht"],
.message-content a[href*="ship"] {
    background: linear-gradient(135deg, rgba(139, 195, 74, 0.15) 0%, rgba(0, 30, 61, 0.1) 100%);
    border: 1px solid rgba(139, 195, 74, 0.3);
    padding: 4px 8px;
    border-radius: 6px;
    display: inline-block;
    margin: 2px 0;
}

.message-content a[href*="yacht"]:hover,
.message-content a[href*="boat"]:hover,
.message-content a[href*="yacht"]:hover,
.message-content a[href*="ship"]:hover {
    background: linear-gradient(135deg, rgba(139, 195, 74, 0.25) 0%, rgba(0, 30, 61, 0.15) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 195, 74, 0.4);
}

/* ======= SCROLL PROFESIONAL - INDICADOR ÚLTIMO MENSAJE ======= */
#scroll-hint {
    position: absolute !important;
    bottom: 75px !important; /* Por encima del área de input */
    right: 15px !important;
    background: linear-gradient(135deg, var(--chatbot-secondary) 0%, #7CB342 100%) !important;
    color: white !important;
    padding: 8px 12px !important;
    border-radius: 20px !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    z-index: 10001 !important;
    cursor: pointer !important;
    box-shadow: 0 4px 15px rgba(139, 195, 74, 0.4) !important;
    animation: scrollHintPulse 2s infinite ease-in-out !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    user-select: none !important;
    border: none !important;
    outline: none !important;
    white-space: nowrap !important;
}

#scroll-hint:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(139, 195, 74, 0.5) !important;
    background: linear-gradient(135deg, #7CB342 0%, var(--chatbot-secondary) 100%) !important;
}

#scroll-hint:active {
    transform: translateY(0px) !important;
    transition: all 0.1s !important;
}

@keyframes scrollHintPulse {
    0%, 100% {
        opacity: 0.9;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

/* Mejorar el área de mensajes para scroll natural y profesional */
.ai-chatbot-messages {
    scroll-behavior: smooth !important;
    overflow-x: hidden !important;
    /* Scroll natural sin interferencias */
}

/* Indicador visual sutil cuando hay scroll disponible */
.ai-chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

.ai-chatbot-messages::-webkit-scrollbar-track {
    background: rgba(0, 30, 61, 0.05);
    border-radius: 2px;
}

.ai-chatbot-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, var(--chatbot-secondary), #7CB342);
    border-radius: 2px;
}

.ai-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #7CB342, var(--chatbot-secondary));
}