/* ── SparkBot — SparkLab Chatbot Widget ── */

#sparklab-chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Toggle button */
#sparklab-chat-toggle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(245, 100, 20, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    outline: none;
    padding: 0;
    overflow: visible;
    position: relative;
}

#sparklab-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 22px rgba(245, 100, 20, 0.55);
}

#sparklab-chat-toggle img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    display: block;
}

.notif-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 13px;
    height: 13px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #fff;
}

/* Chat window — altura fija, layout estricto */
#sparklab-chat-window {
    position: absolute;
    bottom: 74px;
    right: 0;
    width: 340px;
    height: 480px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: sparklabSlideIn 0.25s ease;
}

@keyframes sparklabSlideIn {
    from { opacity: 0; transform: scale(0.85) translateY(16px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

#sparklab-chat-window.hidden { display: none; }

/* Header — altura fija */
#sparklab-chat-header {
    background: linear-gradient(135deg, #F97316, #F59E0B);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    height: 58px;
    box-sizing: border-box;
}

#sparklab-chat-header .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

#sparklab-chat-header .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#sparklab-chat-header .info h4 {
    margin: 0;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
}

#sparklab-chat-header .info p {
    margin: 0;
    color: rgba(255,255,255,0.88);
    font-size: 11px;
}

#sparklab-chat-close {
    margin-left: auto;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    padding: 0 4px;
    opacity: 0.85;
    flex-shrink: 0;
}
#sparklab-chat-close:hover { opacity: 1; }

/* Input area — altura fija en el fondo */
#sparklab-chat-input-area {
    flex: 0 0 auto;
    height: 68px;
    padding: 12px 14px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    box-sizing: border-box;
}

/* Messages area — ocupa TODO el espacio restante */
#sparklab-chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f9fafb;
    min-height: 0;
}

/* Messages */
.sparklab-msg {
    max-width: 82%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.5;
    word-break: break-word;
}

.sparklab-msg.bot {
    background: #fff;
    color: #1f2937;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    align-self: flex-start;
}

.sparklab-msg.user {
    background: linear-gradient(135deg, #F97316, #F59E0B);
    color: #fff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

.sparklab-msg.typing {
    background: #fff;
    color: #9ca3af;
    font-style: italic;
    align-self: flex-start;
    font-size: 13px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* Input */
#sparklab-chat-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 22px;
    padding: 10px 16px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    resize: none;
    font-family: inherit;
    line-height: 1.4;
    height: 44px;
    max-height: 44px;
    overflow-y: hidden;
    box-sizing: border-box;
    white-space: nowrap;
    overflow-x: hidden;
    text-overflow: ellipsis;
}

#sparklab-chat-input:focus { border-color: #F97316; }

#sparklab-chat-send {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #F97316, #F59E0B);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s, opacity 0.15s;
}

#sparklab-chat-send:hover { transform: scale(1.08); }
#sparklab-chat-send:disabled { opacity: 0.5; cursor: not-allowed; }

#sparklab-chat-send svg { width: 16px; height: 16px; fill: #fff; }

/* Scrollbar */
#sparklab-chat-messages::-webkit-scrollbar { width: 4px; }
#sparklab-chat-messages::-webkit-scrollbar-track { background: transparent; }
#sparklab-chat-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

/* Mobile */
@media (max-width: 480px) {
    #sparklab-chat-window {
        width: calc(100vw - 32px);
        right: -8px;
        bottom: 70px;
        height: 420px;
    }
}
