/**
 * ============================================
 * ESTILOS DEL CHATBOT Y WHATSAPP
 * ============================================
 */

/* ============================================
   CHATBOT
   ============================================ */

/* Botón flotante */
.chatbot-toggle {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(252, 184, 7, 0.4);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(252, 184, 7, 0.5);
}

.chatbot-toggle-icon {
    font-size: 2rem;
    display: block;
}

.chatbot-close-icon {
    font-size: 1.5rem;
    display: none;
}

.chatbot-toggle.active .chatbot-toggle-icon {
    display: none;
}

.chatbot-toggle.active .chatbot-close-icon {
    display: block;
}

/* Badge de notificación */
.chatbot-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--color-secondary);
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

/* Ventana del chat */
.chatbot-window {
    position: fixed;
    bottom: 170px;
    right: 20px;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: 500px;
    max-height: calc(100vh - 200px);
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(74, 63, 53, 0.2);
    z-index: 999;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s ease;
}

.chatbot-window.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

@media (max-width: 480px) {
    .chatbot-window {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
    
    .chatbot-toggle {
        bottom: 20px;
    }
}

/* Header del chat */
.chatbot-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    border-radius: 20px 20px 0 0;
}

.chatbot-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: white;
    padding: 3px;
    margin-right: 12px;
}

.chatbot-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.chatbot-info h4 {
    font-family: var(--font-h4);
    font-size: 1.1rem;
    color: var(--color-text);
    margin: 0;
}

.chatbot-status {
    font-size: 0.8rem;
    color: var(--color-text-light);
    display: flex;
    align-items: center;
    gap: 5px;
}

.chatbot-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4CAF50;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.chatbot-minimize {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.3);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.chatbot-minimize:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Área de mensajes */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--color-bg);
}

.chat-message {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    animation: fadeInUp 0.3s ease;
}

.message-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.user-message .message-avatar {
    background: var(--color-accent);
    order: 2;
}

.user-message {
    flex-direction: row-reverse;
}

.message-content {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--color-text);
    max-width: 75%;
}

.user-message .message-content {
    background: var(--color-primary);
    color: var(--color-text);
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 4px;
}

.message-content p {
    margin: 0 0 8px 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul {
    margin: 8px 0;
    padding-left: 20px;
}

.message-content li {
    margin: 4px 0;
}

.message-content .chat-link {
    color: var(--color-primary-dark);
    text-decoration: underline;
    font-weight: 600;
}

/* Indicador de escribiendo */
.typing-indicator {
    opacity: 0.7;
}

.typing-indicator .message-content {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 16px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--color-text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Respuestas rápidas */
.chatbot-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    background: var(--color-bg);
    border-top: 1px solid var(--color-border);
}

.quick-reply {
    background: white;
    border: 1px solid var(--color-border);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.quick-reply:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    transform: translateY(-2px);
}

/* Input area */
.chatbot-input-area {
    display: flex;
    gap: 10px;
    padding: 12px 20px;
    background: white;
    border-top: 1px solid var(--color-border);
}

.chatbot-input {
    flex: 1;
    border: 2px solid var(--color-border);
    border-radius: 25px;
    padding: 10px 16px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s ease;
}

.chatbot-input:focus {
    border-color: var(--color-primary);
}

.chatbot-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--color-primary);
    border: none;
    color: var(--color-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chatbot-send:hover {
    background: var(--color-primary-dark);
    transform: scale(1.05);
}

/* Footer del chat */
.chatbot-footer {
    padding: 10px 20px;
    background: var(--color-bg);
    text-align: center;
    border-top: 1px solid var(--color-border);
}

.chatbot-whatsapp-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #25D366;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
}

.chatbot-whatsapp-link:hover {
    text-decoration: underline;
}


/* ============================================
   BOTÓN WHATSAPP FLOTANTE
   ============================================ */

#whatsapp-button-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 998;
}

.whatsapp-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: #25D366;
    color: white;
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(37, 211, 102, 0.4);
    text-decoration: none;
    position: relative;
    transition: all 0.3s ease;
}

.whatsapp-button:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 6px 25px rgba(37, 211, 102, 0.5);
}

.whatsapp-icon {
    width: 32px;
    height: 32px;
}

/* Tooltip */
.whatsapp-tooltip {
    position: absolute;
    right: 70px;
    background: var(--color-text);
    color: white;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-family: var(--font-body);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transform: translateX(10px);
    transition: all 0.3s ease;
}

.whatsapp-button:hover .whatsapp-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

/* Popup de invitación */
.whatsapp-popup {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 260px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.whatsapp-popup.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.whatsapp-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-family: var(--font-h4);
    color: var(--color-text);
}

.whatsapp-popup-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--color-text-light);
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.whatsapp-popup-close:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.whatsapp-popup-body {
    font-size: 0.9rem;
    color: var(--color-text-light);
    line-height: 1.5;
}

.whatsapp-popup-body p {
    margin: 0;
}


/* ============================================
   ANIMACIONES
   ============================================ */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive: Ajustar posición en mobile */
@media (max-width: 480px) {
    #whatsapp-button-container {
        bottom: 90px;
    }
    
    .chatbot-toggle {
        bottom: 20px;
    }
    
    #whatsapp-button-container {
        right: 10px;
    }
    
    .chatbot-toggle {
        right: 10px;
    }
}

/* Si hay poco espacio vertical, ajustar */
@media (max-height: 600px) {
    .chatbot-window {
        height: calc(100vh - 100px);
        max-height: 400px;
    }
}
