/* Botón flotante del chat */
.chat-button {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 1000;
    overflow: hidden;
}

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

.chat-button.active {
    background: #ff4757;
}

/* Iconos del botón */
.chat-icon,
.close-icon {
    width: 28px;
    height: 28px;
    fill: white;
    transition: all 0.3s ease;
    position: absolute;
}

.close-icon {
    opacity: 0;
    transform: rotate(180deg) scale(0.8);
}

.chat-button.active .chat-icon {
    opacity: 0;
    transform: rotate(-180deg) scale(0.8);
}

.chat-button.active .close-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Contador de mensajes sin leer */
.chat-badge {
    position: absolute;
    top: -15px;
    right: -15px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    transform: scale(0);
    transition: transform 0.3s ease;
}

.chat-badge.show {
    transform: scale(1);
}

/* Contenedor del chat */
.chat-container {
    position: fixed;
    bottom: 150px;
    right: 30px;
    width: 380px;
    height: 500px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 999;
    overflow: hidden;
}

.chat-container.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

/* Header del chat */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
    position: relative;
}

.chat-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.chat-header p {
    margin: 5px 0 0 0;
    font-size: 14px;
    opacity: 0.9;
}

/* Indicador de estado */
.status-indicator {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 10px;
    height: 10px;
    background: #2ed573;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(46, 213, 115, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(46, 213, 115, 0); }
    100% { box-shadow: 0 0 0 0 rgba(46, 213, 115, 0); }
}

/* Área de mensajes */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    scroll-behavior: smooth;
}

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

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

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

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Mensajes */
.message {
    margin-bottom: 15px;
    animation: slideUp 0.4s ease;
}

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

.message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

/* Mensaje del bot */
.message.bot .message-content {
    background: white;
    color: #333;
    border: 1px solid #e9ecef;
    margin-right: auto;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Mensaje del usuario */
.message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 6px;
}

/* Avatar del mensaje */
.message {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
}

.message.bot .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message.user .message-avatar {
    background: #2ed573;
    color: white;
}

/* Indicador de escritura */
.typing-indicator {
    display: none; /* Inicialmente oculto */
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    max-width: 80%;
    margin-right: auto;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    min-height: 44px;
    align-items: center;
}

.typing-indicator.show {
    display: flex;
}

.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    font-size: 14px;
    color: #667eea;
    line-height: 1.4;
    text-align: left; /* Justificado a la izquierda */
    width: 100%;
    transition: opacity 0.3s ease, transform 0.3s ease; /* Transición suave */
}

/* Animaciones de transición para cambio de frases */
.typing-dots.fade-out {
    opacity: 0;
    transform: translateY(-5px);
}

.typing-dots.fade-in {
    opacity: 1;
    transform: translateY(0);
    animation: fadeInSlide 0.3s ease forwards;
}

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

/* Mantener animación de puntos cuando sean puntos */
.typing-dot {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Área de input */
.chat-input {
    padding: 20px;
    background: white;
    border-top: 1px solid #e9ecef;
}

.cb-input-group {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input textarea {
    flex: 1;
    border: 2px solid #e9ecef;
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 80px;
    min-height: 44px;
    transition: border-color 0.3s ease;
    font-size: 16px;     /* sin este valor, iOS forzará zoom */
    line-height: 1.4;
}

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

.chat-input textarea::placeholder {
    color: #adb5bd;
}

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

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

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

.send-icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Responsive */
@media (max-width: 480px) {
    .chat-container {
        bottom: 150px;
        right: 15px;
        left: 15px;
        width: auto;
        height: 70vh;
        max-height: 500px;
    }
    
    .chat-button {
        bottom: 80px;
        right: 20px;
        width: 56px;
        height: 56px;
    }
    
    .chat-icon,
    .close-icon {
        width: 24px;
        height: 24px;
    }
    
    .message-content {
        max-width: 85%;
    }
}

/* Sugerencias rápidas */
.quick-suggestions {
    padding: 15px 20px 0;
    background: #f8f9fa;
}

.suggestions-title {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 10px;
    font-weight: 600;
}

.suggestions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.suggestion-chip {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 12px;
    color: #495057;
    cursor: pointer;
    transition: all 0.3s ease;
}

.suggestion-chip:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Estilos para contenido HTML en mensajes */
.message-content h1, 
.message-content h2, 
.message-content h3 {
    margin: 8px 0 4px 0;
    color: inherit;
    font-size: 1.1em;
    font-weight: bold;
}

.message-content p {
    margin: 4px 0;
    line-height: 1.4;
}

.message-content strong, 
.message-content b {
    font-weight: bold;
}

.message-content em, 
.message-content i {
    font-style: italic;
}

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

.message-content li {
    margin: 2px 0;
}

.message-content br {
    line-height: 1.6;
}

.message-content code {
    background: rgba(0,0,0,0.1);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.9em;
}

.message-content blockquote {
    border-left: 3px solid #667eea;
    margin: 8px 0;
    padding-left: 12px;
    font-style: italic;
    opacity: 0.8;
}

/* Estilos específicos para mensajes del bot con HTML */
.message.bot .message-content {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Animación suave durante la escritura */
.message-content.typing {
    position: relative;
}

.message-content.typing::after {
    content: '▋';
    animation: blink 1s infinite;
    color: #667eea;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Estilos mejorados para contenido HTML en mensajes */
.message-content {
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.5;
    text-align: left !important;
}

.message-content p {
    margin: 6px 0;
    line-height: 1.4;
}

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

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

.message-content strong {
    font-weight: 600;
    color: inherit;
}

.message-content em {
    font-style: italic;
    color: inherit;
}

.message-content ul {
    margin: 8px 0;
    padding-left: 0;
    list-style: none;
}

.message-content li {
    margin: 8px 0;
    padding: 8px 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    
}

.message-content li:last-child {
    border-bottom: none;
}

.message-content br {
    line-height: 1.8;
}

.message-content span[style*="color: #e74c3c"] {
    font-size: 0.9em;
    font-weight: 500;
}

/* Mejorar legibilidad en mensajes del bot */
.message.bot .message-content {
    color: #2c3e50;
}

.message.bot .message-content strong {
    color: #2c3e50;
}

.message.user .message-content {
    color: white;
}

.message.user .message-content strong {
    color: white;
}

