/* ══════════════════════════════════════
   AI Chat Widget — QuePedazoWeb
   ══════════════════════════════════════ */
.qpw-chat-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--gradient-brand, linear-gradient(135deg, #1e5799, #6ab04c));
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(30, 87, 153, 0.35);
    z-index: 998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    font-family: inherit;
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.qpw-chat-btn svg {
    width: 28px;
    height: 28px;
}

.qpw-chat-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(30, 87, 153, 0.45);
}

/* Chat window */
.qpw-chat-window {
    position: fixed;
    bottom: 160px;
    right: 24px;
    width: 370px;
    max-height: 500px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
    z-index: 999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.qpw-chat-window.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Header */
.qpw-chat-header {
    padding: 14px 16px;
    background: linear-gradient(135deg, #1e5799 0%, #2989d8 50%, #6ab04c 100%);
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.qpw-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.qpw-chat-header-info h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.2;
}

.qpw-chat-header-info p {
    font-size: 0.75rem;
    margin: 0;
    opacity: 0.85;
}

.qpw-chat-close {
    margin-left: auto;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
    line-height: 1;
}

.qpw-chat-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* Messages area */
.qpw-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 250px;
    max-height: 320px;
    background: #f8fafc;
}

.qpw-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.875rem;
    line-height: 1.45;
    word-wrap: break-word;
}

.qpw-msg.bot {
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.qpw-msg.user {
    background: #1e5799;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.qpw-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}

.qpw-typing span {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: qpwBounce 1.2s infinite;
}

.qpw-typing span:nth-child(2) { animation-delay: 0.15s; }
.qpw-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes qpwBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Input area */
.qpw-chat-input {
    display: flex;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}

.qpw-chat-input input {
    flex: 1;
    border: none;
    padding: 12px 16px;
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    background: transparent;
}

.qpw-chat-input input::placeholder {
    color: #94a3b8;
}

.qpw-chat-input button {
    padding: 12px 16px;
    background: none;
    border: none;
    cursor: pointer;
    color: #1e5799;
    font-size: 1.125rem;
    transition: color 0.2s;
}

.qpw-chat-input button:hover {
    color: #174a80;
}

.qpw-chat-input button:disabled {
    color: #cbd5e1;
    cursor: not-allowed;
}

/* Lock body scroll when chat is open */
body.qpw-chat-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .qpw-chat-window {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        height: 100dvh;
        height: 100vh;
        max-height: none;
        border-radius: 0;
    }

    .qpw-chat-messages {
        max-height: none;
        min-height: 0;
        flex: 1;
    }

    .qpw-chat-btn {
        bottom: 16px;
        right: 16px;
    }
}
