/* ==========================================================================
   ECOIMAGEN SALUD - WIDGET ASISTENTE VIRTUAL (CHATBOT.CSS)
   ========================================================================== */

/* Contenedor Flotante Principal */
.eco-chatbot-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
    box-sizing: border-box;
}

.eco-chatbot-container * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Botón Flotante (FAB) */
.eco-chatbot-fab {
    position: relative;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0f4c81 0%, #0066ff 100%);
    color: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 8px 25px rgba(15, 76, 129, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.eco-chatbot-fab:hover {
    transform: scale(1.08) rotate(5deg);
    box-shadow: 0 12px 30px rgba(0, 102, 255, 0.5);
}

.eco-chatbot-fab-icon {
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
    width: 100%;
    height: 100%;
}

.eco-fab-avatar-img {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
}

.eco-fab-chat-svg {
    width: 28px;
    height: 28px;
    stroke: #ffffff;
    transition: transform 0.3s ease;
}

.eco-fab-close-icon {
    font-size: 26px;
    font-weight: bold;
    color: #ffffff;
}

.eco-chatbot-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 14px;
    height: 14px;
    background: #00e676;
    border: 2px solid #ffffff;
    border-radius: 50%;
    animation: ecoPulseGreen 2s infinite;
}

@keyframes ecoPulseGreen {
    0% { box-shadow: 0 0 0 0 rgba(0, 230, 118, 0.7); }
    70% { box-shadow: 0 0 0 8px rgba(0, 230, 118, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 230, 118, 0); }
}

/* Tooltip Promocional junto al FAB */
.eco-chatbot-tooltip {
    position: absolute;
    right: 74px;
    top: 50%;
    transform: translateY(-50%);
    background: #ffffff;
    color: #0b3b68;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
    border: 1px solid rgba(15, 76, 129, 0.15);
    pointer-events: none;
    animation: ecoFloatTooltip 3s ease-in-out infinite;
}

.eco-chatbot-tooltip::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 6px 0 6px 6px;
    border-style: solid;
    border-color: transparent transparent transparent #ffffff;
}

@keyframes ecoFloatTooltip {
    0%, 100% { transform: translateY(-50%); }
    50% { transform: translateY(-58%); }
}

/* Ventana de Chat */
.eco-chat-window {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 380px;
    height: 560px;
    max-height: 80vh;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 15px 40px rgba(10, 45, 90, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(15, 76, 129, 0.12);
    transform-origin: bottom right;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 1;
    transform: scale(1) translateY(0);
}

.eco-chat-window.hidden {
    opacity: 0;
    transform: scale(0.85) translateY(20px);
    pointer-events: none;
    visibility: hidden;
}

/* Cabecera del Chat */
.eco-chat-header {
    background: linear-gradient(135deg, #0b3b68 0%, #0f4c81 60%, #0066ff 100%);
    color: #ffffff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.eco-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.eco-chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #ffffff;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.eco-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

.eco-chat-header-text h4 {
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
}

.eco-chat-status {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.eco-chat-status-dot {
    width: 8px;
    height: 8px;
    background: #00e676;
    border-radius: 50%;
    display: inline-block;
}

.eco-chat-header-actions {
    display: flex;
    gap: 8px;
}

.eco-chat-btn-action {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.2s ease;
}

.eco-chat-btn-action:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Cuerpo de Mensajes */
.eco-chat-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f8fbfe;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.eco-chat-body::-webkit-scrollbar {
    width: 5px;
}

.eco-chat-body::-webkit-scrollbar-thumb {
    background: rgba(15, 76, 129, 0.2);
    border-radius: 10px;
}

/* Mensajes (Burbujas) */
.eco-msg {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: ecoFadeMsg 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.eco-msg-bot {
    align-self: flex-start;
    max-width: 90%;
}

.eco-msg-bot-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.eco-msg-bot-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: contain;
    background: #ffffff;
    padding: 2px;
    border: 1.5px solid #0066ff;
    box-shadow: 0 2px 6px rgba(0, 102, 255, 0.2);
    flex-shrink: 0;
    margin-top: 2px;
}

.eco-msg-content-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.eco-msg-user {
    align-self: flex-end;
}

.eco-msg-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.9rem;
    line-height: 1.45;
    word-break: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.eco-msg-bot .eco-msg-bubble {
    background: #ffffff;
    color: #1c2d42;
    border: 1px solid rgba(15, 76, 129, 0.12);
    border-bottom-left-radius: 4px;
}

.eco-msg-user .eco-msg-bubble {
    background: linear-gradient(135deg, #0f4c81 0%, #0066ff 100%);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.eco-msg-time {
    font-size: 0.68rem;
    color: #8c9ba5;
    margin-top: 4px;
    align-self: flex-start;
}

.eco-msg-user .eco-msg-time {
    align-self: flex-end;
}

/* Botones y Enlaces dentro del Chat */
.eco-chat-btn-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #0f4c81;
    color: #ffffff !important;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 700;
    margin-top: 10px;
    transition: all 0.2s ease;
    box-shadow: 0 3px 10px rgba(15, 76, 129, 0.2);
}

.eco-chat-btn-link:hover {
    background: #0066ff;
    transform: translateY(-1px);
}

.eco-chat-btn-wa {
    background: #25d366;
    color: #ffffff !important;
}

.eco-chat-btn-wa:hover {
    background: #1eb956;
}

/* Píldoras de Sugerencias Rápidas */
.eco-chat-chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.eco-chat-chip {
    background: rgba(15, 76, 129, 0.08);
    color: #0b3b68;
    border: 1px solid rgba(15, 76, 129, 0.2);
    padding: 7px 13px;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.eco-chat-chip:hover {
    background: #0f4c81;
    color: #ffffff;
    border-color: #0f4c81;
    transform: translateY(-1px);
}

/* Indicador de Escritura ("Typing...") */
.eco-typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 16px;
    background: #ffffff;
    border: 1px solid rgba(15, 76, 129, 0.12);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.eco-typing-dot {
    width: 7px;
    height: 7px;
    background: #0f4c81;
    border-radius: 50%;
    animation: ecoTyping 1.4s infinite ease-in-out both;
}

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

@keyframes ecoTyping {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1.1); opacity: 1; }
}

/* Área de Entrada / Footer */
.eco-chat-footer {
    padding: 12px 14px;
    background: #ffffff;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 10px;
}

.eco-chat-input {
    flex: 1;
    border: 1.5px solid rgba(15, 76, 129, 0.2);
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    color: #1c2d42;
}

.eco-chat-input:focus {
    border-color: #0066ff;
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.12);
}

.eco-chat-btn-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #0f4c81;
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.eco-chat-btn-send:hover {
    background: #0066ff;
    transform: scale(1.05);
}

/* Responsividad para Móviles */
@media (max-width: 480px) {
    .eco-chatbot-container {
        bottom: 16px;
        right: 16px;
    }

    .eco-chat-window {
        right: -16px;
        bottom: 70px;
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
        max-height: 580px;
        border-radius: 16px;
    }

    .eco-chatbot-tooltip {
        display: none;
    }
}
