/* Estilos comunes para la burbuja y la interfaz */
#mcfl-chat-bubble,
#mcfl-chat-interface {
    position: fixed;
    z-index: 10000; /* Muy alto para estar sobre otros elementos */
    box-sizing: border-box;
}

/* Posiciones de la burbuja y la interfaz */
#mcfl-chat-bubble.bottom-left,
#mcfl-chat-interface.bottom-left {
    bottom: 20px;
    left: 20px;
}
#mcfl-chat-bubble.bottom-right,
#mcfl-chat-interface.bottom-right {
    bottom: 20px;
    right: 20px;
    left: auto;
}
#mcfl-chat-bubble.top-left,
#mcfl-chat-interface.top-left {
    top: 20px;
    left: 20px;
    bottom: auto;
}
#mcfl-chat-bubble.top-right,
#mcfl-chat-interface.top-right {
    top: 20px;
    right: 20px;
    left: auto;
    bottom: auto;
}

/* Ajustes de posición para la interfaz, para que aparezca "encima" de la burbuja */
#mcfl-chat-interface.bottom-left {
    bottom: calc(20px + var(--bubble-size, 60px) + 10px); /* 10px de margen */
}
#mcfl-chat-interface.bottom-right {
    bottom: calc(20px + var(--bubble-size, 60px) + 10px);
}
#mcfl-chat-interface.top-left {
    top: calc(20px + var(--bubble-size, 60px) + 10px);
}
#mcfl-chat-interface.top-right {
    top: calc(20px + var(--bubble-size, 60px) + 10px);
}


/* Estilos para la burbuja de chat */
#mcfl-chat-bubble {
    width: var(--bubble-size, 60px); /* Usar variable CSS */
    height: var(--bubble-size, 60px);
    background-color: var(--bubble-bg-color, #0073aa); /* Variable CSS */
    color: var(--bubble-text-color, white); /* Variable CSS */
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s ease, transform 0.2s ease;
    -webkit-user-select: none;  /* Evitar selección de texto en la burbuja */
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

#mcfl-chat-bubble:hover {
    filter: brightness(0.9);
    transform: scale(1.05);
}

.mcfl-chat-icon {
    font-size: calc(var(--bubble-size, 60px) * 0.45); /* Tamaño del icono basado en la burbuja */
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mcfl-chat-icon svg { /* Si usas SVG para el icono */
    width: 60%;
    height: 60%;
    fill: currentColor; /* Usa el color del texto de la burbuja */
}


/* Estilos para la interfaz de chat */
#mcfl-chat-interface {
    width: 340px; 
    height: 480px; 
    background-color: #fff;
    border-radius: 10px; 
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2); 
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e0e0e0; 
    font-family: 'Roboto', 'Segoe UI', Arial, sans-serif; 
    font-size: 14px;
}

.mcfl-chat-header {
    background-color: var(--bubble-bg-color, #0073aa); 
    color: var(--bubble-text-color, white);
    padding: 15px; 
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 9px; 
    border-top-right-radius: 9px;
    cursor: grab; 
}

.mcfl-chat-header h3 {
    margin: 0;
    font-size: 16px; 
    font-weight: 500;
}

.mcfl-close-chat {
    font-size: 24px; 
    font-weight: bold;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.mcfl-close-chat:hover {
    opacity: 1;
}

.mcfl-chat-messages {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    background-color: #f9f9f9; 
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
}

.mcfl-chat-messages::-webkit-scrollbar { width: 6px; }
.mcfl-chat-messages::-webkit-scrollbar-thumb { background-color: #ccc; border-radius: 3px; }
.mcfl-chat-messages::-webkit-scrollbar-track { background-color: #f0f0f0; }


.mcfl-message {
    padding: 10px 15px;
    border-radius: 20px; 
    margin-bottom: 10px; 
    max-width: 80%; 
    word-wrap: break-word;
    line-height: 1.45;
    font-size: 14px;
    position: relative; 
}

.mcfl-message.user {
    background-color: var(--bubble-bg-color, #0073aa); 
    color: var(--bubble-text-color, white);
    align-self: flex-end;
    border-bottom-right-radius: 5px; 
}

.mcfl-message.bot {
    background-color: #e5e5ea; 
    color: #000;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}

.mcfl-message.bot.typing span {
    display: inline-block; width: 8px; height: 8px;
    border-radius: 50%; background-color: #aaa; margin: 0 2px;
    animation: mcfl_typing_blink 1.4s infinite both;
}
.mcfl-message.bot.typing span:nth-child(2) { animation-delay: 0.2s; }
.mcfl-message.bot.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes mcfl_typing_blink {
    0% { opacity: 0.2; } 20% { opacity: 1; } 100% { opacity: 0.2; }
}


.mcfl-chat-input-area {
    display: flex; padding: 12px 15px;
    border-top: 1px solid #e0e0e0; background-color: #fdfdfd;
    align-items: center;
}

#mcfl-chat-input {
    flex-grow: 1; padding: 10px 15px;
    border: 1px solid #d0d0d0; border-radius: 20px;
    margin-right: 10px; font-size: 14px; line-height: 1.4;
    resize: none; 
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#mcfl-chat-input:focus {
    outline: none; border-color: var(--bubble-bg-color, #0073aa);
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.15); 
}

#mcfl-send-button {
    background-color: var(--bubble-bg-color, #0073aa);
    color: var(--bubble-text-color, white);
    border: none; width: 40px; height: 40px;
    border-radius: 50%; cursor: pointer; font-size: 18px;
    display: flex; align-items: center; justify-content: center;
    transition: background-color 0.2s ease, transform 0.1s ease;
    padding: 0; 
}
#mcfl-send-button svg {
    width: 20px; height: 20px;
    fill: var(--bubble-text-color, white); /* Color del SVG del botón de enviar */
}


#mcfl-send-button:hover { filter: brightness(0.9); }
#mcfl-send-button:active { transform: scale(0.95); }
#mcfl-send-button:disabled { background-color: #cccccc; cursor: not-allowed; opacity: 0.7;}

@media (max-width: 480px) {
    #mcfl-chat-bubble.bottom-left, #mcfl-chat-bubble.bottom-right,
    #mcfl-chat-bubble.top-left, #mcfl-chat-bubble.top-right {
        bottom: 15px !important; left: auto; right: 15px !important; top: auto !important;
    }
    #mcfl-chat-interface {
        width: calc(100% - 20px) !important; height: calc(100% - 90px) !important;
        max-height: 85vh; border-radius: 10px 10px 0 0 !important;
        bottom: 0 !important; left: 10px !important; right: 10px !important; top: auto !important;
    }
     #mcfl-chat-interface.bottom-right, #mcfl-chat-interface.bottom-left { bottom: 0 !important; }
    .mcfl-chat-header h3 { font-size: 15px; }
    .mcfl-chat-input-area { padding: 10px 12px; }
    #mcfl-chat-input { padding: 8px 12px; font-size: 13px; }
    #mcfl-send-button { width: 36px; height: 36px; font-size: 16px; }
    #mcfl-send-button svg { width: 18px; height: 18px; }
}