<style>
/* Estilos base existentes */
:root {
    --primary-color: #2563eb;
    --secondary-color: #06b6d4;
    --accent-color: #10b981;
    --dark-color: #1e293b;
    --light-color: #f8fafc;
    --gray-color: #64748b;
    --white: #ffffff;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gradient: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    --shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.15);
}

/* Chat Support Widget - Estilos mejorados */
.chat-support {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.chat-button {
    width: 60px;
    height: 60px;
    background: var(--gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    border: none;
    position: relative;
    animation: chatButtonPulse 3s infinite;
}

.chat-button:hover {
    transform: scale(1.1);
    animation: none;
}

.chat-button:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.chat-widget {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    max-width: 90vw;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    display: none;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
}

.chat-widget.active {
    display: block;
    animation: slideUpChat 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.chat-header {
    background: var(--gradient);
    color: white;
    padding: 1rem;
}

.chat-header h4 {
    margin: 0;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header p {
    margin: 0.2rem 0 0 0;
    font-size: 0.8rem;
    opacity: 0.9;
}

.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    margin-right: 5px;
    animation: pulse 2s infinite;
}

.chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.8;
    transition: all 0.3s ease;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-close:hover {
    opacity: 1;
    transform: scale(1.1);
}

.chat-content {
    max-height: 300px;
    overflow-y: auto;
    padding: 1rem;
    scroll-behavior: smooth;
}

.chat-content::-webkit-scrollbar {
    width: 4px;
}

.chat-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.chat-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

.chat-input-container {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
}

.chat-input-flex {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

#chat-input {
    flex: 1;
    padding: 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    resize: none;
    font-size: 0.9rem;
    line-height: 1.4;
    min-height: 40px;
    max-height: 100px;
    outline: none;
    transition: all 0.3s ease;
    font-family: inherit;
}

#chat-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

#chat-input:focus {
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.15);
}

.chat-send-btn {
    background: var(--gradient);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(37, 99, 235, 0.4);
}

.chat-send-btn:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.chat-status {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 0.5rem;
    text-align: center;
}

/* Mensajes del chat */
.chat-message {
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    word-wrap: break-word;
    max-width: 85%;
    font-size: 0.9rem;
    line-height: 1.4;
    animation: fadeInUp 0.3s ease;
    display: block;
}

.chat-message-user {
    background: var(--gradient);
    color: white;
    margin-left: 2rem;
    border-radius: 15px 15px 5px 15px;
    align-self: flex-end;
}

.chat-message-assistant {
    background: #f8fafc;
    color: #1e293b;
    margin-right: 2rem;
    border-radius: 15px 15px 15px 5px;
}

.chat-message-suggestion {
    background: var(--accent-color);
    color: white;
    margin-right: 2rem;
    border-radius: 15px 15px 15px 5px;
    font-size: 0.85rem;
}

.chat-message-error {
    background: var(--danger);
    color: white;
    margin: 0 1rem;
    border-radius: 8px;
}

/* Formulario de información del usuario */
.user-info-form {
    background: rgba(37, 99, 235, 0.1);
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    font-size: 0.85rem;
}

.user-info-form p {
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: white;
}

.user-info-form input {
    width: 100%;
    margin-bottom: 0.5rem;
    padding: 0.4rem;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 0.8rem;
    color: #1e293b;
}

.user-info-form input:last-child {
    margin-bottom: 0;
}

/* Indicador de escritura */
.typing-indicator {
    display: flex;
    align-items: center;
    margin-bottom: 0.75rem;
    margin-right: 2rem;
}

.typing-bubble {
    background: #f8fafc;
    padding: 0.75rem 1rem;
    border-radius: 15px 15px 15px 5px;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: #64748b;
}

.typing-dots {
    display: flex;
    gap: 0.2rem;
}

.typing-dot {
    width: 4px;
    height: 4px;
    background: #64748b;
    border-radius: 50%;
    animation: typingDot 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* Notificaciones */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    animation: slideIn 0.3s ease;
    max-width: 400px;
    word-wrap: break-word;
    font-size: 0.9rem;
    line-height: 1.5;
    cursor: pointer;
    border-left: 4px solid rgba(255, 255, 255, 0.3);
}

.notification.success {
    background: var(--success);
    color: white;
}

.notification.error {
    background: var(--danger);
    color: white;
}

.notification-content {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.notification-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* Animaciones */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes typingDot {
    0%, 20% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
    80%, 100% { opacity: 0.4; transform: scale(1); }
}

@keyframes slideUpChat {
    from { transform: translateY(30px) scale(0.8); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes slideDownChat {
    from { transform: translateY(0) scale(1); opacity: 1; }
    to { transform: translateY(30px) scale(0.8); opacity: 0; }
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

@keyframes chatButtonPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* Loading spinner */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 480px) {
    .chat-widget {
        width: 320px;
        bottom: 70px;
        right: 10px;
    }
    
    .chat-support {
        bottom: 10px;
        right: 10px;
    }
    
    .chat-button {
        width: 50px;
        height: 50px;
        font-size: 1.3rem;
    }
    
    .notification {
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

/* Accesibilidad mejorada */
@media (prefers-reduced-motion: reduce) {
    .chat-button,
    .chat-widget,
    .chat-message,
    .notification {
        animation: none;
        transition: none;
    }
}

/* Tema oscuro automático */
@media (prefers-color-scheme: dark) {
    .chat-message-assistant {
        background: #374151;
        color: #f9fafb;
    }
    
    .user-info-form input {
        background: #374151;
        color: #f9fafb;
        border-color: #6b7280;
    }
}
</style>