/* Envasify Chatbot Widget — v1.0.0 */

#envasify-chat-btn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 56px;
    height: 56px;
    background: #0047AB;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,71,171,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99998;
    transition: background 0.2s, transform 0.2s;
}
#envasify-chat-btn:hover { background: #003380; transform: scale(1.06); }
#envasify-chat-btn svg  { width: 26px; height: 26px; fill: #fff; }

/* Badge de notificación */
#envasify-chat-btn::after {
    content: '';
    position: absolute;
    top: 4px; right: 4px;
    width: 12px; height: 12px;
    background: #05B77A;
    border-radius: 50%;
    border: 2px solid #fff;
}

/* Panel principal */
#envasify-chat-panel {
    position: fixed;
    bottom: 96px;
    right: 28px;
    width: 360px;
    max-height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    z-index: 99999;
    font-family: -apple-system, 'Segoe UI', sans-serif;
    overflow: hidden;
    transform: scale(0.92) translateY(16px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s cubic-bezier(.4,0,.2,1), opacity 0.22s ease;
}
#envasify-chat-panel.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* Header */
#envasify-chat-header {
    background: #0047AB;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
#envasify-chat-header .ec-avatar {
    width: 36px; height: 36px;
    background: #05B77A;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 700; color: #fff;
    flex-shrink: 0;
}
#envasify-chat-header .ec-info { flex: 1; }
#envasify-chat-header .ec-name  { color: #fff; font-weight: 600; font-size: 14px; line-height: 1.2; }
#envasify-chat-header .ec-status { color: rgba(255,255,255,0.75); font-size: 12px; }
#envasify-chat-close {
    background: none; border: none; cursor: pointer;
    color: rgba(255,255,255,0.8); font-size: 20px; line-height: 1;
    padding: 0; transition: color 0.15s;
}
#envasify-chat-close:hover { color: #fff; }

/* Mensajes */
#envasify-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8fafc;
}
#envasify-chat-messages::-webkit-scrollbar { width: 4px; }
#envasify-chat-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.ec-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.5;
    word-wrap: break-word;
}
.ec-msg.bot {
    background: #fff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}
.ec-msg.user {
    background: #0047AB;
    color: #fff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

/* Typing indicator */
.ec-typing {
    display: flex; gap: 4px;
    align-items: center;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}
.ec-typing span {
    width: 7px; height: 7px;
    background: #0047AB;
    border-radius: 50%;
    animation: ec-bounce 1.2s infinite;
}
.ec-typing span:nth-child(2) { animation-delay: 0.2s; }
.ec-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ec-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-6px); }
}

/* Sugerencias rápidas */
#envasify-chat-suggestions {
    padding: 0 16px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: #f8fafc;
}
.ec-suggestion {
    background: #fff;
    border: 1px solid #0047AB;
    color: #0047AB;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.ec-suggestion:hover { background: #0047AB; color: #fff; }

/* Input */
#envasify-chat-footer {
    padding: 12px 14px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
    background: #fff;
    flex-shrink: 0;
}
#envasify-chat-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.15s;
    font-family: inherit;
    resize: none;
    height: 38px;
    line-height: 1.4;
}
#envasify-chat-input:focus { border-color: #0047AB; }
#envasify-chat-send {
    background: #0047AB;
    border: none;
    border-radius: 10px;
    width: 38px; height: 38px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}
#envasify-chat-send:hover   { background: #003380; }
#envasify-chat-send:disabled { background: #93c5fd; cursor: not-allowed; }
#envasify-chat-send svg { width: 17px; height: 17px; fill: #fff; }

/* Powered by */
#envasify-chat-powered {
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    padding: 4px 0 8px;
    background: #fff;
}

/* Mobile */
@media (max-width: 420px) {
    #envasify-chat-panel {
        width: calc(100vw - 24px);
        right: 12px;
        bottom: 88px;
    }
    #envasify-chat-btn { bottom: 20px; right: 16px; }
}
