/**
 * Estilos Premium para Chatbot de Salud Curicó
 * Integrado con la paleta de verdes elegantes del diseño principal
 * 
 * @version 1.0
 */

:root {
    /* Paleta de colores específica para chatbot, matching con los verdes principales */
    --chatbot-primary: #2E8B57;
    /* Verde mar primario */
    --chatbot-secondary: #3CB371;
    /* Verde medio mar secundario */
    --chatbot-accent: #1D6E43;
    /* Verde oscuro para acentos */
    --chatbot-light: #E8F5E9;
    /* Verde ultra claro para fondos */
    --chatbot-gray: #F5F7FA;
    /* Gris claro */
    --chatbot-text: #2C3E50;
    /* Color texto principal */
    --chatbot-text-light: #FFFFFF;
    /* Texto claro */
    --chatbot-shadow: 0 5px 25px rgba(0, 0, 0, 0.15);
    /* Sombra principal */
    --chatbot-shadow-hover: 0 8px 35px rgba(0, 0, 0, 0.2);
    /* Sombra hover */
    --chatbot-radius: 16px;
    /* Radio de borde principal */
    --chatbot-transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    /* Transición fluida */
}

/* Contenedor principal del chatbot */
.chatbot-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    font-family: 'Montserrat', 'Segoe UI', sans-serif;
}

/* Botón flotante para abrir/cerrar el chatbot */
.chatbot-button {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chatbot-secondary), var(--chatbot-primary));
    box-shadow: var(--chatbot-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--chatbot-text-light);
    font-size: 24px;
    cursor: pointer;
    transition: var(--chatbot-transition);
    position: relative;
    z-index: 1;
}

.chatbot-button:hover {
    transform: translateY(-5px);
    box-shadow: var(--chatbot-shadow-hover);
}

.chatbot-button:before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-accent));
    border-radius: 50%;
    opacity: 0;
    z-index: -1;
    transition: var(--chatbot-transition);
}

.chatbot-button:hover:before {
    opacity: 1;
}

.chatbot-button-active {
    transform: scale(0.85);
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.1);
}

.chatbot-button-active i {
    transform: scale(0.9);
}

/* Animación de notificación (pulsante) */
.chatbot-button:after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: var(--chatbot-primary);
    z-index: -2;
    opacity: 0.8;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }

    70% {
        transform: scale(1.3);
        opacity: 0;
    }

    100% {
        transform: scale(1.3);
        opacity: 0;
    }
}

/* Ventana de chat */
.chatbot-window {
    position: absolute;
    bottom: 90px;
    right: 0;
    width: 380px;
    height: 500px;
    background-color: #FFFFFF;
    border-radius: var(--chatbot-radius);
    box-shadow: var(--chatbot-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px);
    opacity: 0;
    visibility: hidden;
    transition: var(--chatbot-transition);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.chatbot-window-active {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

/* Encabezado del chatbot */
.chatbot-header {
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-accent));
    color: var(--chatbot-text-light);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: var(--chatbot-radius) var(--chatbot-radius) 0 0;
    position: relative;
    z-index: 2;
}

.chatbot-header:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none"><path d="M0,0 L100,0 L100,5 C75,30 25,30 0,5 L0,0 Z" fill="rgba(255,255,255,0.1)"/></svg>');
    background-size: 100% 100%;
    opacity: 0.3;
    z-index: -1;
}

.chatbot-title {
    font-weight: 600;
    margin: 0;
    font-size: 18px;
    letter-spacing: 0.5px;
}

.chatbot-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--chatbot-transition);
}

.chatbot-close:hover {
    background-color: rgba(255, 255, 255, 0.25);
    transform: rotate(90deg);
}

/* Cuerpo del chatbot (donde aparecen los mensajes) */
.chatbot-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: var(--chatbot-gray);
    position: relative;

    /* Estilo de scrollbar personalizado */
    scrollbar-width: thin;
    scrollbar-color: rgba(46, 139, 87, 0.3) transparent;
}

.chatbot-body::-webkit-scrollbar {
    width: 6px;
}

.chatbot-body::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-body::-webkit-scrollbar-thumb {
    background-color: rgba(46, 139, 87, 0.3);
    border-radius: 20px;
}

.chatbot-body::-webkit-scrollbar-thumb:hover {
    background-color: rgba(46, 139, 87, 0.5);
}

/* Mensajes de chat */
.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    margin-bottom: 15px;
    animation: fadeInMessage 0.3s ease forwards;
}

.chat-bot {
    align-items: flex-start;
    align-self: flex-start;
}

.chat-user {
    align-items: flex-end;
    align-self: flex-end;
}

@keyframes fadeInMessage {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Burbujas de chat */
.chat-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.5;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    overflow-wrap: break-word;
    hyphens: auto;
}

.chat-bot .chat-bubble {
    background-color: #FFFFFF;
    color: var(--chatbot-text);
    border-bottom-left-radius: 4px;
    margin-right: 40px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.chat-user .chat-bubble {
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-secondary));
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 5px rgba(46, 139, 87, 0.2);
}

/* Avatar para mensajes del bot */
.chat-bot:before {
    content: '';
    display: block;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-secondary));
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4z"/></svg>');
    background-size: 18px 18px;
    background-repeat: no-repeat;
    background-position: center;
    margin-bottom: 5px;
    box-shadow: 0 2px 5px rgba(46, 139, 87, 0.2);
}

/* Indicador de escritura del bot */
.typing-dots {
    display: flex;
    align-items: center;
    column-gap: 4px;
    height: 20px;
    padding: 0 5px;
}

.typing-dots span {
    display: block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--chatbot-primary);
    opacity: 0.6;
}

.typing-dots span:nth-child(1) {
    animation: typingDot 1.4s infinite;
    animation-delay: 0s;
}

.typing-dots span:nth-child(2) {
    animation: typingDot 1.4s infinite;
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation: typingDot 1.4s infinite;
    animation-delay: 0.4s;
}

@keyframes typingDot {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-5px);
    }
}

/* Campo de entrada de mensajes */
.chatbot-input {
    padding: 15px;
    background-color: white;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
}

.chatbot-input form {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chatbot-input .form-control {
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 30px;
    padding: 12px 20px;
    font-size: 14px;
    transition: all 0.3s ease;
    background-color: var(--chatbot-gray);
    flex: 1;
}

.chatbot-input .form-control:focus {
    outline: none;
    border-color: var(--chatbot-primary);
    box-shadow: 0 0 0 3px rgba(46, 139, 87, 0.1);
    background-color: white;
}

.chatbot-input .btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chatbot-secondary), var(--chatbot-primary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
    font-size: 16px;
}

.chatbot-input .btn:hover {
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-accent));
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(46, 139, 87, 0.2);
}

.chatbot-input .btn:active {
    transform: scale(0.95);
}

/* Sugerencias de chatbot */
.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    margin-bottom: 15px;
    animation: fadeIn 0.5s ease forwards;
}

.suggestion-button {
    background-color: white;
    border: 1px solid var(--chatbot-primary);
    color: var(--chatbot-primary);
    border-radius: 18px;
    padding: 8px 15px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    max-width: 180px;
}

.suggestion-button:hover {
    background-color: var(--chatbot-light);
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(46, 139, 87, 0.15);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Links en los mensajes del chatbot */
.chat-bubble a {
    color: var(--chatbot-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.chat-bubble a:hover {
    color: var(--chatbot-primary);
}

.chat-user .chat-bubble a {
    color: white;
    text-decoration: underline;
}

/* Elementos destacados en los mensajes */
.chat-bubble strong {
    font-weight: 600;
}

/* Responsive design */
@media (max-width: 480px) {
    .chatbot-window {
        width: calc(100vw - 30px);
        bottom: 80px;
        right: 15px;
        height: 60vh;
    }

    .chatbot-button {
        width: 55px;
        height: 55px;
        bottom: 15px;
        right: 15px;
    }

    .chat-message {
        max-width: 90%;
    }

    .suggestion-button {
        max-width: 150px;
    }

    .chatbot-input .form-control {
        font-size: 13px;
        padding: 10px 15px;
    }

    .chatbot-input .btn {
        width: 38px;
        height: 38px;
    }
}