/* ===== Paulo AI Chatbot Widget ===== */

/*
 * POINTER-EVENTS STRATEGY:
 * 1. Wrapper has pointer-events: none — invisible to touches/clicks at all times
 * 2. Only the toggle button gets pointer-events: auto — always clickable
 * 3. Chat window gets pointer-events: none by default (closed state)
 * 4. Chat window gets pointer-events: auto only when .open class is added
 * This ensures NOTHING inside the widget blocks page content when chat is closed
 */

#paulo-chatbot-wrapper {
    position: fixed;
    bottom: 24px;
    right: 16px;
    z-index: 999999;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: flex-end;

    /* CRITICAL: wrapper never blocks clicks */
    pointer-events: none;

    /* Constrain wrapper to only what it needs */
    width: fit-content;
    height: fit-content;
}

/* ---- Toggle Button (always clickable) ---- */
#paulo-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0073aa, #005f8d);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 115, 170, 0.45);
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex-shrink: 0;
    -webkit-appearance: none;
    appearance: none;

    /* Toggle button is ALWAYS clickable */
    pointer-events: auto;
}

#paulo-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0, 115, 170, 0.55);
}

/* ---- Chat Window ---- */
#paulo-chat-window {
    width: 340px;
    max-height: 480px;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    margin-bottom: 14px;
    overflow: hidden;

    /* Closed state — hidden and NOT blocking clicks */
    opacity: 0;
    transform: translateY(20px) scale(0.96);
    pointer-events: none;
    visibility: hidden;

    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
}

/* Open state — visible AND clickable */
#paulo-chat-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    visibility: visible;
}

/* ---- Header ---- */
#paulo-chat-header {
    background: linear-gradient(135deg, #0073aa, #005f8d);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

#paulo-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

#paulo-chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

#paulo-chat-name {
    font-weight: 600;
    font-size: 14px;
}

#paulo-chat-status {
    font-size: 11px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

#paulo-status-dot {
    width: 7px;
    height: 7px;
    background: #4cff91;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 6px #4cff91;
}

#paulo-chat-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#paulo-chat-close:hover {
    background: rgba(255,255,255,0.3);
}

/* ---- Messages Area ---- */
#paulo-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

#paulo-chat-messages::-webkit-scrollbar { width: 4px; }
#paulo-chat-messages::-webkit-scrollbar-track { background: transparent; }
#paulo-chat-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

/* ---- Message Bubbles ---- */
.chat-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    animation: msgFadeIn 0.2s ease;
}

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

.bot-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0073aa, #005f8d);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.bubble {
    max-width: 78%;
    padding: 9px 13px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.5;
    word-wrap: break-word;
}

.user-msg {
    flex-direction: row-reverse;
}

.user-msg .bubble {
    background: linear-gradient(135deg, #0073aa, #005f8d);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.bot-msg .bubble {
    background: #f3f4f6;
    color: #1a1a2e;
    border-bottom-left-radius: 4px;
}

/* ---- Typing Indicator ---- */
.typing-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
}

.typing-bubble span {
    width: 7px;
    height: 7px;
    background: #aaa;
    border-radius: 50%;
    animation: typingBounce 1.2s infinite ease-in-out;
}

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

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

/* ---- Suggestion Chips ---- */
.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 2px 0 4px 36px;
    animation: msgFadeIn 0.3s ease;
}

.suggestion-chip {
    background: #fff;
    border: 1.5px solid #0073aa;
    color: #0073aa;
    border-radius: 20px;
    padding: 5px 11px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
}

.suggestion-chip:hover {
    background: #0073aa;
    color: #fff;
}

/* ---- Input Area ---- */
#paulo-chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
    background: #fff;
}

#paulo-chat-input {
    flex: 1;
    border: 1.5px solid #e5e7eb;
    border-radius: 22px;
    padding: 8px 14px;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.2s;
    background: #f9fafb;
    color: #1a1a2e;
}

#paulo-chat-input:focus {
    border-color: #0073aa;
    background: #fff;
}

#paulo-chat-send {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #0073aa, #005f8d);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s ease, opacity 0.15s;
}

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

/* ---- Mobile: small phones (up to 480px) ---- */
@media (max-width: 480px) {
    #paulo-chatbot-wrapper {
        bottom: 16px;
        right: 12px;
    }

    #paulo-chat-window {
        /* Fit within screen with padding, never full width */
        width: calc(100vw - 24px);
        max-height: 70vh;
        margin-bottom: 10px;

        /* Anchor to right edge of wrapper, not full screen */
        position: absolute;
        bottom: 70px;
        right: 0;

        /* Still hidden and non-blocking when closed */
        pointer-events: none;
        visibility: hidden;
    }

    #paulo-chat-window.open {
        pointer-events: auto;
        visibility: visible;
    }
}

/* ---- Tablet: 481px to 768px ---- */
@media (min-width: 481px) and (max-width: 768px) {
    #paulo-chatbot-wrapper {
        bottom: 20px;
        right: 16px;
    }

    #paulo-chat-window {
        width: 320px;
        max-height: 460px;
    }
}

/* ---- Clickable links inside chat bubbles ---- */
.bot-msg .bubble a {
    color: #0073aa;
    text-decoration: underline;
    word-break: break-all;
}

.bot-msg .bubble a:hover {
    color: #005f8d;
}

/* ---- Reduced motion preference ---- */
@media (prefers-reduced-motion: reduce) {
    #paulo-chat-window,
    #paulo-chat-toggle,
    .chat-msg,
    .typing-bubble span {
        animation: none;
        transition: none;
    }
}