/* CHAT - SOLUCIÓN EXTREMA PERO LIMPIA */
html, body {
    position: relative;
    z-index: 1;
}

/* FORZAR CHAT SOBRE TODO - SIN !important MASIVOS */
#chatgpt-bot-button-belen,
#chatgpt-bot-button-joaquin,
#chatgpt-bot-belen,
#chatgpt-bot-joaquin {
    position: fixed !important;
    z-index: 2147483647 !important;
    transform: translate3d(0, 0, 1000px) !important;
}

/* Botones flotantes */
.chatgpt-bot-button {
    bottom: 20px;
    right: 20px;
    background: #007bff;
    color: white;
    font-size: 14px;
    width: auto;
    height: auto;
    border-radius: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    padding: 8px 16px 8px 8px;
    gap: 8px;
}

#chatgpt-bot-button-belen { background: #007bff; }
#chatgpt-bot-button-joaquin { background: #28a745; }

.chatgpt-bot-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(0,0,0,0.4);
}

.button-avatar-container { position: relative; display: flex; align-items: center; }
.button-avatar { width: 40px; height: 40px; border-radius: 50%; border: 2px solid white; }

.button-online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #4CAF50;
    border-radius: 50%;
    border: 2px solid #007bff;
    animation: pulse 2s infinite;
}

#chatgpt-bot-button-joaquin .button-online-dot {
    border-color: #28a745;
    background: #4CAF50;
    border: 2px solid white;
}

.button-text { font-weight: 600; white-space: nowrap; }

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

/* Ventanas de chat */
.chatgpt-bot-window {
    bottom: 90px;
    right: 20px;
    width: 350px;
    height: 450px;
    background: #111;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 2px solid #333;
}

#chatgpt-bot-belen { border-color: #007bff; }
#chatgpt-bot-joaquin { border-color: #28a745; }

.hidden { display: none !important; }

.chat-header {
    background: #222;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #333;
    position: relative;
}

#chatgpt-bot-belen .chat-header { border-bottom: 2px solid #007bff; }
#chatgpt-bot-joaquin .chat-header { border-bottom: 2px solid #28a745; }

.chat-info { display: flex; align-items: center; gap: 10px; flex: 1; }
.chat-avatar { width: 40px; height: 40px; border-radius: 50%; border: 2px solid #007bff; }
#chatgpt-bot-joaquin .chat-avatar { border-color: #28a745; }
.chat-user-info { display: flex; flex-direction: column; }
.chat-name { font-weight: bold; font-size: 14px; }
.chat-status { font-size: 12px; color: #aaa; display: flex; align-items: center; gap: 4px; }

.online-dot {
    width: 8px;
    height: 8px;
    background: #4CAF50;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

.chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
}

.chat-close:hover { background: rgba(255,255,255,0.1); }
.chat-body { flex: 1; padding: 16px; background: #181818; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }

.msg {
    margin: 0;
    padding: 10px 12px;
    border-radius: 12px;
    max-width: 85%;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 14px;
}

.msg.user { background: #007bff; margin-left: auto; text-align: right; color: white; border-bottom-right-radius: 4px; }
.msg.bot { background: #333; margin-right: auto; text-align: left; color: white; border-bottom-left-radius: 4px; }
#chatgpt-bot-joaquin .msg.user { background: #28a745; }
.typing-indicator { color: #aaa; font-style: italic; }
.error { background: #d32f2f !important; color: white !important; }

.chat-footer { display: flex; border-top: 1px solid #333; padding: 12px; background: #111; gap: 8px; }
.chat-input { flex: 1; padding: 12px; border: 1px solid #333; outline: none; border-radius: 8px; background: #222; color: white; font-size: 16px; }
.chat-input:focus { border-color: #007bff; }
#chatgpt-bot-joaquin .chat-input:focus { border-color: #28a745; }
.chat-input::placeholder { color: #888; }

.chat-send {
    background: #007bff;
    border: none;
    color: white;
    padding: 12px 16px;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.chat-send:hover { background: #0056b3; }
#chatgpt-bot-joaquin .chat-send { background: #28a745; }
#chatgpt-bot-joaquin .chat-send:hover { background: #218838; }

/* Scrollbar */
.chat-body::-webkit-scrollbar { width: 6px; }
.chat-body::-webkit-scrollbar-track { background: #222; }
.chat-body::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }
.chat-body::-webkit-scrollbar-thumb:hover { background: #555; }

/* Responsive */
@media (max-width: 768px) {
    .chatgpt-bot-window {
        top: 50px; left: 10px; right: 10px; bottom: 80px;
        width: auto; height: auto; max-width: none; margin: 0; transform: none;
    }
    .chatgpt-bot-button { bottom: 20px; right: 20px; }
    .chat-body { padding: 12px; }
    .msg { max-width: 90%; font-size: 14px; }
    .chat-input { font-size: 16px; padding: 12px; }
    .chat-send { padding: 12px 14px; }
}

@media (max-width: 480px) {
    .chatgpt-bot-window { top: 40px; left: 5px; right: 5px; bottom: 70px; border-radius: 12px; }
    .chatgpt-bot-button { bottom: 15px; right: 15px; padding: 6px 12px 6px 6px; }
    .button-avatar { width: 35px; height: 35px; }
    .button-text { font-size: 13px; }
    .chat-header { padding: 10px 12px; }
    .chat-body { padding: 10px; }
    .msg { padding: 8px 10px; max-width: 92%; }
}

/* Control visibilidad */
.chatgpt-bot-button { display: none; }
#chatgpt-bot-button-belen.logged-in { display: flex; }
#chatgpt-bot-button-joaquin.visitor { display: flex; }
.chatgpt-bot-window.hidden + .chatgpt-bot-button { display: flex; }

/* Streaming */
.streaming-message { position: relative; }
.streaming-cursor { animation: blink 1s infinite; color: #007bff; font-weight: bold; }
@keyframes blink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0; } }
.msg.bot.streaming-message { background: #2a2a2a; border-left: 3px solid #007bff; }
#chatgpt-bot-joaquin .msg.bot.streaming-message { border-left-color: #28a745; }