/* ── WDG Chatbot Widget ──────────────────────────────────────────────────── */

/* Scoped reset - only inside our wrapper */
#wdg-chat-wrapper,
#wdg-chat-wrapper *,
#wdg-chat-btn,
#wdg-chat-window,
#wdg-chat-window * {
    box-sizing: border-box !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

/* ── Float Button ────────────────────────────────────────────────────────── */
#wdg-chat-btn {
    position: fixed !important;
    bottom: 28px !important;
    right: 28px !important;
    z-index: 2147483647 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    background: var(--wdg-color, #1a73e8) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 50px !important;
    padding: 13px 20px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25) !important;
    transition: transform 0.2s, box-shadow 0.2s !important;
    text-decoration: none !important;
    outline: none !important;
    line-height: 1 !important;
    margin: 0 !important;
    width: auto !important;
    height: auto !important;
}
#wdg-chat-btn:hover { transform: translateY(-2px) !important; box-shadow: 0 8px 28px rgba(0,0,0,0.3) !important; }
#wdg-chat-btn:active { transform: scale(0.97) !important; }

#wdg-chat-btn .wdg-pulse {
    position: absolute !important;
    top: -3px !important; right: -3px !important;
    width: 12px !important; height: 12px !important;
    background: #34c759 !important;
    border-radius: 50% !important;
    border: 2px solid white !important;
    margin: 0 !important; padding: 0 !important;
}

/* ── Chat Window ─────────────────────────────────────────────────────────── */
#wdg-chat-window {
    position: fixed !important;
    bottom: 90px !important;
    right: 28px !important;
    z-index: 2147483646 !important;
    width: 360px !important;
    height: 520px !important;
    max-height: 80vh !important;
    background: #ffffff !important;
    border-radius: 20px !important;
    box-shadow: 0 12px 48px rgba(0,0,0,0.2) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    transform: scale(0.85) translateY(20px) !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s ease !important;
    transform-origin: bottom right !important;
    margin: 0 !important;
    padding: 0 !important;
}
#wdg-chat-window.wdg-open {
    transform: scale(1) translateY(0) !important;
    opacity: 1 !important;
    pointer-events: all !important;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
#wdg-chat-window .wdg-header {
    background: var(--wdg-color, #1a73e8) !important;
    padding: 14px 16px !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    color: white !important;
    flex-shrink: 0 !important;
    min-height: 64px !important;
    width: 100% !important;
}

#wdg-chat-window .wdg-header-avatar {
    width: 36px !important; height: 36px !important;
    background: rgba(255,255,255,0.2) !important;
    border-radius: 50% !important;
    display: flex !important; align-items: center !important; justify-content: center !important;
    font-size: 17px !important; flex-shrink: 0 !important;
    margin: 0 !important; padding: 0 !important;
}

#wdg-chat-window .wdg-header-info { flex: 1 !important; min-width: 0 !important; }
#wdg-chat-window .wdg-header-info h3 {
    font-size: 15px !important; font-weight: 600 !important;
    line-height: 1.2 !important; color: white !important;
    margin: 0 !important; padding: 0 !important;
    white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important;
}
#wdg-chat-window .wdg-header-info p {
    font-size: 11.5px !important; opacity: 0.85 !important;
    margin: 2px 0 0 0 !important; padding: 0 !important;
    color: white !important;
}

#wdg-chat-window .wdg-header-close {
    margin-left: auto !important;
    background: rgba(255,255,255,0.15) !important;
    border: none !important; color: white !important;
    width: 28px !important; height: 28px !important;
    border-radius: 50% !important; cursor: pointer !important;
    font-size: 14px !important; line-height: 1 !important;
    display: flex !important; align-items: center !important; justify-content: center !important;
    transition: background 0.2s !important; flex-shrink: 0 !important;
    padding: 0 !important;
}
#wdg-chat-window .wdg-header-close:hover { background: rgba(255,255,255,0.3) !important; }

/* ── Messages Area ───────────────────────────────────────────────────────── */
#wdg-chat-window .wdg-messages {
    flex: 1 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 14px 12px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    background: #f4f6f8 !important;
    scroll-behavior: smooth !important;
    width: 100% !important;
    min-height: 0 !important;
}
#wdg-chat-window .wdg-messages::-webkit-scrollbar { width: 4px !important; }
#wdg-chat-window .wdg-messages::-webkit-scrollbar-thumb { background: #ccc !important; border-radius: 2px !important; }

/* ── Message Row ─────────────────────────────────────────────────────────── */
#wdg-chat-window .wdg-msg {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-end !important;
    gap: 7px !important;
    width: 100% !important;
    animation: wdgFadeUp 0.3s ease both !important;
    margin: 0 !important; padding: 0 !important;
}

/* User messages: align right */
#wdg-chat-window .wdg-msg.wdg-user {
    flex-direction: row-reverse !important;
    justify-content: flex-start !important;
}

/* Bot messages: align left */
#wdg-chat-window .wdg-msg.wdg-bot {
    justify-content: flex-start !important;
}

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

/* ── Avatar ──────────────────────────────────────────────────────────────── */
#wdg-chat-window .wdg-avatar {
    width: 28px !important; height: 28px !important;
    min-width: 28px !important;
    border-radius: 50% !important;
    background: var(--wdg-color, #1a73e8) !important;
    color: white !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}
#wdg-chat-window .wdg-msg.wdg-user .wdg-avatar {
    background: #d0d0d0 !important;
    color: #555 !important;
}

/* ── Bubble ──────────────────────────────────────────────────────────────── */
#wdg-chat-window .wdg-bubble {
    max-width: 75% !important;
    min-width: 0 !important;
    padding: 9px 13px !important;
    border-radius: 16px !important;
    font-size: 13.5px !important;
    line-height: 1.55 !important;
    word-wrap: break-word !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    white-space: pre-wrap !important;
    margin: 0 !important;
}

/* Bot bubble */
#wdg-chat-window .wdg-msg.wdg-bot .wdg-bubble {
    background: #ffffff !important;
    color: #1a1a1a !important;
    border: 1px solid #e4e4e4 !important;
    border-bottom-left-radius: 4px !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.07) !important;
    text-align: left !important;
}

/* User bubble */
#wdg-chat-window .wdg-msg.wdg-user .wdg-bubble {
    background: var(--wdg-color, #1a73e8) !important;
    color: #ffffff !important;
    border: none !important;
    border-bottom-right-radius: 4px !important;
    text-align: left !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15) !important;
}

/* ── Typing Indicator ────────────────────────────────────────────────────── */
#wdg-chat-window .wdg-typing {
    display: flex !important;
    gap: 4px !important;
    align-items: center !important;
    padding: 2px 0 !important;
}
#wdg-chat-window .wdg-typing span {
    display: block !important;
    width: 7px !important; height: 7px !important;
    background: var(--wdg-color, #1a73e8) !important;
    border-radius: 50% !important;
    animation: wdgBounce 1.2s infinite !important;
    opacity: 0.5 !important;
    margin: 0 !important; padding: 0 !important;
}
#wdg-chat-window .wdg-typing span:nth-child(2) { animation-delay: 0.2s !important; }
#wdg-chat-window .wdg-typing span:nth-child(3) { animation-delay: 0.4s !important; }
@keyframes wdgBounce {
    0%,60%,100% { transform: translateY(0); opacity: 0.4; }
    30%          { transform: translateY(-5px); opacity: 1; }
}

/* ── Quick Chips ─────────────────────────────────────────────────────────── */
#wdg-chat-window .wdg-chips {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    padding: 8px 12px 10px !important;
    background: #f4f6f8 !important;
    flex-shrink: 0 !important;
    border-top: 1px solid #eee !important;
}
#wdg-chat-window .wdg-chip {
    padding: 5px 12px !important;
    background: white !important;
    border: 1px solid #ddd !important;
    border-radius: 100px !important;
    font-size: 12px !important;
    cursor: pointer !important;
    color: var(--wdg-color, #1a73e8) !important;
    transition: all 0.18s !important;
    white-space: nowrap !important;
    line-height: 1.4 !important;
    margin: 0 !important;
}
#wdg-chat-window .wdg-chip:hover {
    background: var(--wdg-color, #1a73e8) !important;
    color: white !important;
    border-color: var(--wdg-color, #1a73e8) !important;
}

/* ── Input Area ──────────────────────────────────────────────────────────── */
#wdg-chat-window .wdg-input-area {
    padding: 10px 12px !important;
    border-top: 1px solid #ebebeb !important;
    background: #ffffff !important;
    display: flex !important;
    gap: 8px !important;
    align-items: flex-end !important;
    flex-shrink: 0 !important;
    width: 100% !important;
}

#wdg-input {
    flex: 1 !important;
    min-width: 0 !important;
    border: 1.5px solid #e0e0e0 !important;
    border-radius: 12px !important;
    padding: 9px 12px !important;
    font-size: 13.5px !important;
    outline: none !important;
    resize: none !important;
    line-height: 1.4 !important;
    max-height: 80px !important;
    overflow-y: auto !important;
    color: #1a1a1a !important;
    background: #f9f9f9 !important;
    transition: border-color 0.2s, background 0.2s !important;
    font-family: inherit !important;
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
}
#wdg-input:focus {
    border-color: var(--wdg-color, #1a73e8) !important;
    background: #fff !important;
    outline: none !important;
}
#wdg-input::placeholder { color: #b0b0b0 !important; }

#wdg-send {
    width: 38px !important; height: 38px !important;
    min-width: 38px !important;
    border-radius: 12px !important;
    background: var(--wdg-color, #1a73e8) !important;
    border: none !important;
    color: white !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}
#wdg-send:hover  { filter: brightness(1.1) !important; transform: scale(1.05) !important; }
#wdg-send:active { transform: scale(0.95) !important; }
#wdg-send:disabled { opacity: 0.4 !important; cursor: not-allowed !important; transform: none !important; }
#wdg-send svg { width: 15px !important; height: 15px !important; display: block !important; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
#wdg-chat-window .wdg-footer {
    text-align: center !important;
    font-size: 10.5px !important;
    color: #c0c0c0 !important;
    padding: 5px 8px !important;
    background: white !important;
    border-top: 1px solid #f2f2f2 !important;
    flex-shrink: 0 !important;
    line-height: 1.4 !important;
    margin: 0 !important;
}

/* ── Mobile ──────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    #wdg-chat-window {
        width: calc(100vw - 16px) !important;
        right: 8px !important;
        bottom: 76px !important;
        height: 70vh !important;
    }
    #wdg-chat-btn {
        right: 14px !important;
        bottom: 14px !important;
        padding: 11px 16px !important;
        font-size: 14px !important;
    }
}
