/* AI Chatbot Styles */
.chatbot-float {
    position: fixed;
    bottom: 30px; /* Bajado significativamente ya que reCAPTCHA ya no está siempre visible */
    right: 30px;
    z-index: 9999;
}

/* Tooltip llamativo */
.chatbot-tooltip {
    position: absolute;
    bottom: 70px;
    right: -10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    z-index: 10001;
    animation: tooltipFloat 3s ease-in-out infinite;
}

.chatbot-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #667eea;
}

.chatbot-tooltip.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

@keyframes tooltipFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

.chatbot-button {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    color: white;
    animation: pulse 2s infinite;
}

.chatbot-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.6);
}

@keyframes pulse {
    0% {
        box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 8px 30px rgba(102, 126, 234, 1), 0 0 0 10px rgba(102, 126, 234, 0.3);
        transform: scale(1.05);
    }
    100% {
        box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
        transform: scale(1);
    }
}

.chatbot-popup {
    position: fixed; /* Cambiar a fixed para evitar problemas de layout */
    bottom: 100px; /* Ajustado para la nueva posición del botón */
    right: 30px;
    width: 380px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10000; /* Asegurar que esté por encima de todo */
}

.chatbot-popup.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.chatbot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    min-height: 70px;
}

.chatbot-avatar {
    width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.avatar-circle {
    font-weight: bold;
    font-size: 16px;
    color: white;
}

.chatbot-info {
    flex: 1;
    min-width: 0;
}

.chatbot-info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: white;
}

.chatbot-status {
    margin: 2px 0 0 0;
    font-size: 13px;
    opacity: 0.9;
    color: white;
}

.chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: opacity 0.2s;
    flex-shrink: 0;
    margin-left: auto;
}

.chatbot-close:hover {
    opacity: 1;
}

.chatbot-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: white;
}

.chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fa;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #bbb;
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #888;
}

.chat-message {
    display: flex;
    animation: slideIn 0.3s ease;
}

.chat-message.user {
    justify-content: flex-end;
}

.chat-message.bot {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message-bubble ul,
.message-bubble ol {
    margin: 8px 0;
    padding-left: 20px;
}

.message-bubble li {
    margin: 4px 0;
}

.message-bubble strong {
    font-weight: 600;
}

.message-bubble p {
    margin: 8px 0;
}

.message-bubble p:first-child {
    margin-top: 0;
}

.message-bubble p:last-child {
    margin-bottom: 0;
}

.chat-message.user .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.bot .message-bubble {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}

.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0;
}

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.3);
        opacity: 1;
    }
}

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

.chatbot-input-container {
    padding: 16px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    background: white;
    flex-shrink: 0;
}

.chatbot-input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, height 0.2s;
    font-family: inherit;
    resize: none; /* Evitar resize manual */
    overflow-y: auto; /* Scroll cuando sea necesario */
    line-height: 1.4;
    min-height: 40px; /* Altura mínima */
    max-height: 80px; /* Máximo 3 líneas aproximadamente */
    box-sizing: border-box;
    word-wrap: break-word;
}

.chatbot-input:focus {
    border-color: #667eea;
}

.chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.chatbot-send:hover:not(:disabled) {
    transform: scale(1.1);
}

.chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Quick Reply Buttons */
.quick-replies {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    max-width: 70%;
}

.quick-reply-button {
    background: white;
    border: 1px solid #667eea;
    color: #667eea;
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px;
}

.quick-reply-button:hover {
    background: #667eea;
    color: white;
    transform: translateX(2px);
}

.quick-reply-button:active {
    transform: scale(0.98);
}

.quick-reply-button .emoji {
    font-size: 16px;
}

/* Estilo para botones de servicios específicos */
.service-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
    max-width: 70%;
}

.service-button {
    background: linear-gradient(135deg, #667eea20 0%, #764ba220 100%);
    border: 1px solid #667eea40;
    color: #333;
    padding: 8px;
    border-radius: 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: auto !important; /* Anular el min-height desde styles.css */
    height: auto;
}

.service-button:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.service-button .service-emoji {
    font-size: 16px;
}

.service-button .service-text {
    font-weight: 500;
    line-height: 1.2;
}

/* Responsive Design */
@media (max-width: 768px) {
    .chatbot-popup {
        width: calc(100vw - 40px);
        height: calc(100vh - 150px); /* Ajustado para la nueva posición */
        right: 20px;
        bottom: 75px; /* Ajustado para la nueva posición del botón */
        max-width: 400px;
        max-height: 500px; /* Altura máxima reducida */
        position: fixed; /* Asegurar posición fija */
    }
    
    .chatbot-float {
        bottom: 25px; /* Bajado también en tablets */
        right: 20px;
        position: fixed;
    }
    
    /* Ajustar el área de mensajes en mobile */
    .chatbot-messages {
        padding: 15px;
        max-height: calc(100% - 130px); /* Limitar altura del área de mensajes */
    }
    
    .chatbot-header {
        padding: 12px 16px;
        min-height: 60px;
    }
    
    .chatbot-input-container {
        padding: 12px 16px;
    }
}

@media (max-width: 480px) {
    .chatbot-popup {
        width: calc(100vw - 20px);
        height: calc(100vh - 120px); /* Ajustado para nueva posición */
        right: 10px;
        bottom: 70px; /* Ajustado para estar por encima del botón */
        max-height: 450px; /* Altura máxima aún más reducida */
    }
    
    .chatbot-float {
        right: 15px;
        bottom: 20px; /* Bajado para mejor accesibilidad en móviles */
    }
    
    .chatbot-button {
        width: 56px;
        height: 56px;
    }
    
    /* Tooltip más pequeño en móviles */
    .chatbot-tooltip {
        font-size: 12px;
        padding: 6px 12px;
        bottom: 60px;
        right: -5px;
    }
    
    /* Mensajes más compactos en móviles */
    .message-bubble {
        padding: 10px 14px;
        font-size: 13px;
        max-width: 85%;
    }
    
    .chatbot-input {
        padding: 8px 14px;
        font-size: 13px;
        min-height: 36px; /* Altura mínima reducida en móvil */
        max-height: 72px; /* Máximo 3 líneas en móvil */
        line-height: 1.3;
    }
    
    .chatbot-send {
        width: 36px;
        height: 36px;
    }
}