/* ============================================================
   CHATBOT WIDGET — Megaflotas
   Paleta: negro #0D0D0D | verde menta #00C8A0 | blanco #FFF
   ============================================================ */

/* --- BOTÓN FLOTANTE ---------------------------------------- */
#chatbot-toggle {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 56px;
    height: 56px;
    background: #00C8A0;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 200, 160, 0.45);
    z-index: 1000;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(0, 200, 160, 0.6);
}

#chatbot-toggle svg {
    width: 26px;
    height: 26px;
    fill: #000;
    transition: transform 0.3s ease, opacity 0.2s ease;
}

#chatbot-toggle .icon-close {
    display: none;
}

#chatbot-toggle.open .icon-chat {
    display: none;
}

#chatbot-toggle.open .icon-close {
    display: block;
}

/* --- VENTANA CHAT ------------------------------------------ */
#chatbot-window {
    position: fixed;
    bottom: 96px;
    right: 28px;
    width: 360px;
    height: 520px;
    background: #111111;
    border: 1px solid #2A2A2A;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
    z-index: 999;
    /* Estado inicial: oculto */
    opacity: 0;
    transform: translateY(16px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

#chatbot-window.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* --- CABECERA ----------------------------------------------- */
#chatbot-header {
    background: #0D0D0D;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #1E1E1E;
    flex-shrink: 0;
}

.chatbot-avatar {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #00C8A0, #007A64);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chatbot-avatar svg {
    width: 20px;
    height: 20px;
    fill: #000;
}

.chatbot-header-info {
    flex: 1;
}

.chatbot-header-info .bot-name {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #FFFFFF;
    line-height: 1.2;
}

.chatbot-header-info .bot-status {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    color: #00C8A0;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.chatbot-header-info .bot-status::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #00C8A0;
    border-radius: 50%;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

.chatbot-ai-badge {
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #000;
    background: #00C8A0;
    padding: 3px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    flex-shrink: 0;
}

/* --- ÁREA DE MENSAJES --------------------------------------- */
#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

#chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

#chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

#chatbot-messages::-webkit-scrollbar-thumb {
    background: #2A2A2A;
    border-radius: 4px;
}

/* --- BURBUJAS DE MENSAJE ------------------------------------ */
.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: msg-in 0.2s ease;
}

@keyframes msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

.chat-msg.bot {
    align-self: flex-start;
    align-items: flex-start;
}

.chat-msg .bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-family: 'Inter', sans-serif;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
}

.chat-msg.user .bubble {
    background: #00C8A0;
    color: #000000;
    border-bottom-right-radius: 4px;
}

.chat-msg.bot .bubble {
    background: #1E1E1E;
    color: #FFFFFF;
    border-bottom-left-radius: 4px;
    border: 1px solid #2A2A2A;
}

/* Cursor parpadeante mientras llega el stream */
.chat-msg.bot .bubble.streaming::after {
    content: '▋';
    display: inline-block;
    color: #00C8A0;
    font-size: 12px;
    margin-left: 2px;
    vertical-align: middle;
    animation: cursor-blink 0.6s infinite;
}

@keyframes cursor-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

.chat-msg .msg-time {
    font-size: 10px;
    color: #555555;
    margin-top: 4px;
    padding: 0 2px;
}

/* --- INDICADOR ESCRIBIENDO --------------------------------- */
.typing-indicator {
    align-self: flex-start;
    background: #1E1E1E;
    border: 1px solid #2A2A2A;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    padding: 12px 16px;
    display: flex;
    gap: 5px;
    align-items: center;
}

.typing-indicator span {
    display: inline-block;
    width: 7px;
    height: 7px;
    background: #555555;
    border-radius: 50%;
    animation: typing-bounce 1.2s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0);    background: #555555; }
    30%           { transform: translateY(-5px); background: #00C8A0; }
}

/* --- FOOTER: INPUT ----------------------------------------- */
#chatbot-footer {
    border-top: 1px solid #1E1E1E;
    padding: 12px 14px;
    background: #0D0D0D;
    flex-shrink: 0;
}

#chatbot-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

#chatbot-input {
    flex: 1;
    background: #1E1E1E;
    border: 1px solid #2A2A2A;
    border-radius: 12px;
    color: #FFFFFF;
    font-family: 'Inter', sans-serif;
    font-size: 13.5px;
    padding: 10px 14px;
    resize: none;
    max-height: 100px;
    outline: none;
    transition: border-color 0.2s ease;
    line-height: 1.4;
}

#chatbot-input::placeholder {
    color: #444444;
}

#chatbot-input:focus {
    border-color: #00C8A0;
}

#chatbot-send {
    width: 40px;
    height: 40px;
    background: #00C8A0;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease, transform 0.15s ease;
}

#chatbot-send:hover {
    background: #00A884;
    transform: scale(1.05);
}

#chatbot-send:disabled {
    background: #1E1E1E;
    cursor: not-allowed;
    transform: none;
}

#chatbot-send svg {
    width: 18px;
    height: 18px;
    fill: #000;
}

#chatbot-send:disabled svg {
    fill: #444444;
}

.chatbot-disclaimer {
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    color: #444444;
    text-align: center;
    margin-top: 8px;
}

/* --- RESPONSIVE -------------------------------------------- */
@media (max-width: 480px) {
    #chatbot-window {
        right: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        height: 70vh;
        border-radius: 20px 20px 0 0;
    }

    #chatbot-toggle {
        bottom: 20px;
        right: 20px;
    }
}
