/* ============================================================
   CHAT IA WIDGET — Desarrollos Inmobiliarios
   ============================================================ */

.chat-bubble {
    position: fixed;
    bottom: 100px;
    right: 28px;
    z-index: 200;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1b6fb5, #29bced);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(41,188,237,.45);
    transition: transform .25s ease, box-shadow .25s ease;
}
.chat-bubble:hover { transform: scale(1.09); box-shadow: 0 6px 28px rgba(41,188,237,.55); }
.chat-bubble svg { width: 26px; height: 26px; color: #fff; transition: transform .3s ease; }
.chat-bubble.open svg { transform: rotate(180deg); }
.chat-unread {
    position: absolute;
    top: -3px; right: -3px;
    width: 18px; height: 18px;
    background: #e24b4a;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--bg, #07080f);
    display: none;
}
.chat-unread.show { display: flex; }

.chat-panel {
    position: fixed;
    bottom: 170px;
    right: 28px;
    z-index: 199;
    width: 360px;
    max-height: 520px;
    background: #0d1221;
    border: 1px solid rgba(41,188,237,.2);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 12px 48px rgba(0,0,0,.6);
    transform: translateY(20px) scale(.95);
    opacity: 0;
    pointer-events: none;
    transition: transform .3s ease, opacity .3s ease;
}
.chat-panel.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}

.chat-header {
    background: linear-gradient(135deg, #1b6fb5, #29bced);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.chat-avatar {
    width: 38px; height: 38px;
    background: rgba(255,255,255,.2);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.chat-avatar svg { width: 20px; height: 20px; color: #fff; }
.chat-header-info { flex: 1; }
.chat-header-name  { font-size: 14px; font-weight: 600; color: #fff; line-height: 1.2; }
.chat-header-status { font-size: 11px; color: rgba(255,255,255,.75); display: flex; align-items: center; gap: 5px; }
.chat-header-status::before { content: ''; width: 6px; height: 6px; background: #4dff9f; border-radius: 50%; }
.chat-close { background: none; border: none; cursor: pointer; color: rgba(255,255,255,.8); padding: 4px; line-height: 0; }
.chat-close:hover { color: #fff; }
.chat-close svg { width: 18px; height: 18px; }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(41,188,237,.25); border-radius: 4px; }

.chat-msg {
    display: flex;
    gap: 8px;
    animation: msgIn .25s ease both;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.chat-msg.user { flex-direction: row-reverse; }
.chat-msg-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; font-size: 12px; font-weight: 600;
    margin-top: 2px;
}
.chat-msg.assistant .chat-msg-avatar { background: linear-gradient(135deg,#1b6fb5,#29bced); color: #fff; }
.chat-msg.user      .chat-msg-avatar { background: rgba(41,188,237,.15); color: #29bced; }
.chat-msg-bubble {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.55;
    word-wrap: break-word;
}
.chat-msg.assistant .chat-msg-bubble {
    background: #10152a;
    color: #eef2f8;
    border-bottom-left-radius: 4px;
}
.chat-msg.user .chat-msg-bubble {
    background: linear-gradient(135deg,#1b6fb5,#29bced);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg-time { font-size: 10px; opacity: .5; margin-top: 4px; }

.chat-typing {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 0 0 4px;
}
.chat-typing.show { display: flex; }
.chat-typing-dots { display: flex; gap: 4px; padding: 10px 14px; background: #10152a; border-radius: 14px 14px 14px 4px; }
.chat-typing-dots span {
    width: 6px; height: 6px;
    background: #29bced;
    border-radius: 50%;
    animation: dot .8s ease infinite;
}
.chat-typing-dots span:nth-child(2) { animation-delay: .16s; }
.chat-typing-dots span:nth-child(3) { animation-delay: .32s; }
@keyframes dot { 0%,80%,100% { transform: scale(.8); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }

.chat-footer {
    border-top: 1px solid rgba(238,242,248,.07);
    padding: 12px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}
.chat-input {
    flex: 1;
    background: #10152a;
    border: 1px solid rgba(238,242,248,.1);
    border-radius: 10px;
    color: #eef2f8;
    padding: 10px 14px;
    font-size: 13px;
    font-family: 'DM Sans', sans-serif;
    resize: none;
    outline: none;
    max-height: 100px;
    line-height: 1.5;
    transition: border-color .2s;
}
.chat-input:focus { border-color: #29bced; }
.chat-input::placeholder { color: #4d5a7a; }
.chat-send {
    width: 40px; height: 40px;
    background: linear-gradient(135deg,#1b6fb5,#29bced);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: transform .2s, opacity .2s;
}
.chat-send:hover { transform: scale(1.05); }
.chat-send:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.chat-send svg { width: 18px; height: 18px; color: #fff; }

.chat-powered {
    text-align: center;
    font-size: 10px;
    color: #4d5a7a;
    padding: 0 12px 8px;
    flex-shrink: 0;
}

@media (max-width: 480px) {
    .chat-panel { width: calc(100vw - 20px); right: 10px; bottom: 90px; }
    .chat-bubble { right: 16px; bottom: 22px; }
}
