/* Chat Widget Styles - Colores Empresariales Naranja y Morado */
.chatbot-widget {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.chatbot-widget.bottom-right {
    bottom: 20px;
    right: 20px;
}

.chatbot-widget.bottom-left {
    bottom: 100px;
    left: 20px;
}

.chatbot-widget.top-right {
    top: 20px;
    right: 20px;
}

.chatbot-widget.top-left {
    top: 20px;
    left: 20px;
}

/* Botón flotante - Gradiente Naranja a Morado */
.chatbot-button {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #ff6b35, #7b2cbf);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(255, 107, 53, 0.4);
    transition: all 0.3s ease;
    color: white;
    position: relative;
    overflow: hidden;
}

.chatbot-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 107, 53, 0.5);
    background: linear-gradient(135deg, #ff8c61, #9d4edd);
}

.chatbot-button.active {
    background: linear-gradient(135deg, #dc3545, #c82333);
}

.chatbot-button svg {
    transition: transform 0.3s ease;
}

.chatbot-button.active svg {
    transform: rotate(45deg);
}

/* Badge de notificación */
.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff6b35;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Panel de chat */
.chatbot-panel {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header del chat - Gradiente Empresarial */
.chatbot-header {
    background: linear-gradient(135deg, #ff6b35, #7b2cbf);
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.bot-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bot-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.bot-details {
    display: flex;
    flex-direction: column;
}

.bot-name {
    font-weight: 600;
    font-size: 16px;
}

.bot-status {
    font-size: 12px;
    opacity: 0.9;
}

.close-button {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.close-button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Área de mensajes - Fondo Blanco */
.chatbot-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #ffffff; /* FONDO BLANCO PURO */
}

.chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #ff6b35, #7b2cbf);
    border-radius: 2px;
}

/* Mensajes */
.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.bot-message {
    align-self: flex-start;
}

.user-message {
    align-self: flex-end;
}

.message-content {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

/* Mensajes del BOT - Fondo claro con texto oscuro */
.bot-message .message-content {
    background: #f8f9fa;
    color: #2d3436; /* TEXTO OSCURO LEGIBLE */
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    border-left: 3px solid #ff6b35;
}

/* Mensajes del USUARIO - Gradiente empresarial */
.user-message .message-content {
    background: linear-gradient(135deg, #ff6b35, #7b2cbf);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: #6c757d;
    margin-top: 4px;
    padding: 0 4px;
}

.user-message .message-time {
    text-align: right;
    color: #adb5bd;
}

/* ESTILOS PARA CONTENIDO HTML EN MENSAJES */
.bot-message .message-content h3,
.bot-message .message-content h4 {
    color: #7b2cbf !important; /* MORADO PARA TÍTULOS */
    margin: 8px 0 6px 0 !important;
    font-weight: bold !important;
}

.bot-message .message-content h3 {
    font-size: 16px !important;
}

.bot-message .message-content h4 {
    font-size: 14px !important;
}

.bot-message .message-content strong {
    color: #2d3436 !important; /* TEXTO OSCURO PARA NEGRITAS */
    font-weight: 600 !important;
}

.bot-message .message-content ul,
.bot-message .message-content ol {
    margin: 8px 0 !important;
    padding-left: 20px !important;
}

.bot-message .message-content li {
    margin: 4px 0 !important;
    color: #2d3436 !important;
}

.bot-message .message-content div {
    color: #2d3436 !important;
}

/* Botón de WhatsApp */
.whatsapp-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #25d366;
    color: white;
    text-decoration: none;
    padding: 12px 16px;
    border-radius: 25px;
    font-weight: 500;
    transition: all 0.3s ease;
    font-size: 14px;
    margin-top: 8px;
}

.whatsapp-button:hover {
    background: #1eb654;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
    color: white;
    text-decoration: none;
}

/* Sugerencias */
.chatbot-suggestions {
    padding: 16px;
    background: white;
    border-top: 1px solid #eee;
}

.suggestions-label {
    font-size: 12px;
    color: #7b2cbf;
    margin-bottom: 8px;
    font-weight: 600;
}

.suggestion-button {
    display: block;
    width: 100%;
    background: #fff5f3;
    border: 1px solid #ff6b35;
    border-radius: 20px;
    padding: 8px 12px;
    margin-bottom: 6px;
    font-size: 13px;
    color: #7b2cbf;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.suggestion-button:hover {
    background: linear-gradient(135deg, #ff6b35, #7b2cbf);
    color: white;
    transform: translateX(4px);
}

.suggestion-button:last-child {
    margin-bottom: 0;
}

/* Área de input */
.chatbot-input-area {
    background: white;
    border-top: 1px solid #eee;
    padding: 16px;
}

.input-container {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chatbot-input-area input {
    flex: 1;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    padding: 12px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
    color: #2d3436;
}

.chatbot-input-area input:focus {
    border-color: #ff6b35;
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.chatbot-input-area input::placeholder {
    color: #6c757d;
}

.send-button {
    width: 40px !important;
    height: 40px !important;
    background: linear-gradient(135deg, #ff6b35, #7b2cbf) !important;
    border: none !important;
    border-radius: 50% !important;
    color: white !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease !important;
    flex-shrink: 0 !important;
}


.send-button:hover {
    background: linear-gradient(135deg, #ff8c61, #9d4edd);
    transform: scale(1.05);
}

.send-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.input-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 11px;
    color: #6c757d;
}

/* Loading indicator */
.chatbot-loading {
    padding: 16px;
    display: flex;
    justify-content: flex-start;
}

.typing-indicator {
    background: #f8f9fa;
    border-radius: 18px;
    padding: 12px 16px;
    display: flex;
    gap: 4px;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    border-left: 3px solid #ff6b35;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: #ff6b35;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
    background: #9d4edd;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
    background: #7b2cbf;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 480px) {
    .chatbot-panel {
        width: calc(100vw - 40px);
        height: calc(100vh - 140px);
        left: 20px;
        right: auto;
        bottom: 80px;
    }
    
    .chatbot-widget.bottom-left .chatbot-panel,
    .chatbot-widget.bottom-right .chatbot-panel {
        left: 20px;
        right: auto;
    }
    
    .message {
        max-width: 90%;
    }
}

@media (max-width: 360px) {
    .chatbot-button {
        width: 50px;
        height: 50px;
    }
    
    .chatbot-panel {
        width: calc(100vw - 20px);
        left: 10px;
        right: auto;
    }
}

/* Estados de conexión */
.connection-status {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #28a745;
}

.connection-status.disconnected {
    background: #dc3545;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

/* Efectos adicionales */
.chatbot-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.1));
    pointer-events: none;
}

/* Animación de entrada del panel */
.chatbot-panel.entering {
    animation: panelEnter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes panelEnter {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* MODO OSCURO REMOVIDO - Solo modo claro con colores empresariales */

/* Estilos adicionales para emojis y formato */
.bot-message .message-content .emoji {
    font-size: 16px;
    margin-right: 4px;
}

/* Ajustes finales para legibilidad */
.bot-message .message-content * {
    color: #2d3436 !important;
}

.bot-message .message-content h3 *,
.bot-message .message-content h4 * {
    color: #7b2cbf !important;
}

.bot-message .message-content strong * {
    color: #2d3436 !important;
    font-weight: 600 !important;
}

/* AGREGAR AL FINAL DEL CSS - RESPONSIVE MEJORADO */

/* Responsive REAL para todos los móviles y tablets */
@media (max-width: 768px) {
    .chatbot-panel {
        width: calc(100vw - 20px) !important;
        height: calc(100vh - 120px) !important;
        left: 10px !important;
        right: auto !important;
        bottom: 10px !important;
        max-width: none !important;
    }
    
    .chatbot-widget.bottom-right .chatbot-panel,
    .chatbot-widget.bottom-left .chatbot-panel {
        left: 10px !important;
        right: auto !important;
    }
    
    .chatbot-button {
        width: 50px !important;
        height: 50px !important;
        bottom: 20px !important;
        right: 20px !important;
    }
    
    .message {
        max-width: 90% !important;
    }
    
    .chatbot-messages {
        padding: 12px !important;
    }
    
    .chatbot-input-area {
        padding: 12px !important;
    }
}

/* Para pantallas MUY pequeñas */
@media (max-width: 390px) {
    .chatbot-panel {
        width: calc(100vw - 10px) !important;
        left: 5px !important;
        height: calc(100vh - 100px) !important;
    }
    
    .chatbot-button {
        width: 45px !important;
        height: 45px !important;
        bottom: 15px !important;
        right: 15px !important;
    }
}

/* Para landscape en móviles */
@media (max-width: 768px) and (orientation: landscape) {
    .chatbot-panel {
        height: calc(100vh - 80px) !important;
        width: calc(100vw - 20px) !important;
    }
}

/* OVERRIDE específico para móviles - FORZAR posición */
@media (max-width: 768px) {
    .chatbot-widget {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
    }
    
    .chatbot-widget .chatbot-panel {
        position: fixed !important;
        bottom: 70px !important;
        left: 10px !important;
        right: 10px !important;
        width: auto !important;
        max-width: none !important;
        height: calc(100vh - 140px) !important;
    }
    
    .chatbot-widget .chatbot-button {
        position: fixed !important;
        bottom: 20px !important;
        right: 20px !important;
        left: auto !important;
        top: auto !important;
    }
}

/* Fix para el test HTML específicamente */
@media (max-width: 768px) {
    /* Ajustar el FAB del test para no chocar con el chatbot */
    .fab-chat {
        bottom: 90px !important;
        z-index: 9997 !important;
    }
    
    /* Ajustar el status bar */
    .chatbot-status {
        top: 5px !important;
        left: 5px !important;
        right: 5px !important;
        font-size: 0.8rem !important;
    }
}