/* WP AI Chatbot Widget Styling */
:root {
    --wp-ai-primary: #702FFF;
    --wp-ai-primary-hover: #591ed6;
    --wp-ai-bg: #ffffff;
    --wp-ai-text: #1f2937;
    --wp-ai-text-muted: #6b7280;
    --wp-ai-bubble-bot: #f3f4f6;
    --wp-ai-bubble-user: #702FFF;
    --wp-ai-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

#wp-ai-chatbot-root {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999999;
}

/* Floating Trigger Button */
.wp-ai-trigger-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--wp-ai-primary);
    color: #ffffff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(112, 47, 255, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
    outline: none;
    position: relative;
}

.wp-ai-trigger-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(112, 47, 255, 0.45);
}

.wp-ai-trigger-btn svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
    transition: transform 0.2s ease;
}

.wp-ai-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background: #10b981;
    border: 2px solid #ffffff;
    border-radius: 50%;
}

/* Main Chat Container */
.wp-ai-chat-window {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 380px;
    height: 580px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 110px);
    background: var(--wp-ai-bg);
    border-radius: 16px;
    box-shadow: var(--wp-ai-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: scale(0.95) translateY(10px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.wp-ai-chat-window.wp-ai-open {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}

/* Header */
.wp-ai-header {
    background: var(--wp-ai-primary);
    color: #ffffff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.wp-ai-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wp-ai-avatar {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.wp-ai-title-wrap h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
}

.wp-ai-title-wrap span {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    gap: 5px;
}

.wp-ai-status-dot {
    width: 7px;
    height: 7px;
    background: #10b981;
    border-radius: 50%;
    display: inline-block;
}

.wp-ai-header-actions button {
    background: transparent;
    border: none;
    color: #ffffff;
    cursor: pointer;
    opacity: 0.8;
    padding: 6px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s, background 0.15s;
}

.wp-ai-header-actions button:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

/* Chat Messages Stream */
.wp-ai-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #fafafa;
}

.wp-ai-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    font-size: 13.5px;
    line-height: 1.45;
    animation: wpAiFadeIn 0.2s ease forwards;
}

.wp-ai-msg-bot {
    align-self: flex-start;
}

.wp-ai-msg-bot .wp-ai-bubble {
    background: #ffffff;
    color: var(--wp-ai-text);
    border-radius: 14px 14px 14px 2px;
    padding: 11px 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
}

.wp-ai-msg-user {
    align-self: flex-end;
}

.wp-ai-msg-user .wp-ai-bubble {
    background: var(--wp-ai-primary);
    color: #ffffff;
    border-radius: 14px 14px 2px 14px;
    padding: 11px 14px;
    box-shadow: 0 1px 3px rgba(112, 47, 255, 0.2);
}

.wp-ai-msg-time {
    font-size: 10px;
    color: var(--wp-ai-text-muted);
    margin-top: 3px;
    padding: 0 4px;
}

.wp-ai-msg-user .wp-ai-msg-time {
    align-self: flex-end;
}

/* Quick Prompt Suggestions */
.wp-ai-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 14px;
    background: #ffffff;
    border-top: 1px solid #f3f4f6;
}

.wp-ai-chip {
    background: #f3f4f6;
    color: var(--wp-ai-text);
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 11.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.wp-ai-chip:hover {
    background: var(--wp-ai-primary);
    color: #ffffff;
    border-color: var(--wp-ai-primary);
}

/* Typing Indicator */
.wp-ai-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #ffffff;
    border-radius: 14px 14px 14px 2px;
    border: 1px solid #e5e7eb;
    align-self: flex-start;
    width: fit-content;
}

.wp-ai-dot {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: wpAiBounce 1.3s infinite ease-in-out;
}

.wp-ai-dot:nth-child(2) { animation-delay: 0.15s; }
.wp-ai-dot:nth-child(3) { animation-delay: 0.3s; }

/* Input Bar */
.wp-ai-input-area {
    padding: 10px 14px;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 8px;
}

#wp-ai-chatbot-root input[type="text"].wp-ai-input,
.wp-ai-input {
    flex: 1;
    border: 1px solid #d1d5db !important;
    border-radius: 22px !important;
    padding: 8px 14px !important;
    font-size: 13px !important;
    line-height: 1.4 !important;
    height: auto !important;
    min-height: unset !important;
    outline: none !important;
    font-family: inherit !important;
    transition: border-color 0.15s;
    background: #f9fafb !important;
    box-shadow: none !important;
}

#wp-ai-chatbot-root input[type="text"].wp-ai-input:focus,
.wp-ai-input:focus {
    border-color: var(--wp-ai-primary) !important;
    background: #ffffff !important;
}

.wp-ai-send-btn {
    width: 36px;
    height: 36px;
    background: var(--wp-ai-primary);
    border: none;
    border-radius: 50%;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
    outline: none;
}

.wp-ai-send-btn:hover {
    background: var(--wp-ai-primary-hover);
    transform: scale(1.05);
}

.wp-ai-send-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
    margin-left: 2px;
}

/* Success Consultation Notice Card */
.wp-ai-lead-alert {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 12px;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

@keyframes wpAiBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Responsive on Mobile Screens & Small Displays */
@media (max-width: 600px) {
    #wp-ai-chatbot-root {
        bottom: 16px;
        right: 16px;
    }

    .wp-ai-trigger-btn {
        width: 52px;
        height: 52px;
    }

    .wp-ai-trigger-btn svg {
        width: 24px;
        height: 24px;
    }

    /* Floating Chat Window on Mobile:
       - Placed comfortably above the floating WhatsApp icon (bottom-left) and trigger controls (bottom: 80px)
       - Compact card height: never covers full screen (max 440px / 55-60% viewport), leaving website content freely visible above and WhatsApp icon freely accessible below
    */
    .wp-ai-chat-window {
        position: fixed;
        bottom: calc(80px + env(safe-area-inset-bottom, 0px));
        right: 12px;
        left: 12px;
        width: auto;
        max-width: 380px;
        margin: 0 auto;
        height: min(440px, calc(100dvh - 170px));
        max-height: min(440px, calc(100dvh - 170px));
        border-radius: 16px;
        box-shadow: 0 12px 36px rgba(0, 0, 0, 0.22);
        z-index: 99999999;
    }

    .wp-ai-header {
        padding: 12px 14px;
    }

    .wp-ai-avatar {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .wp-ai-title-wrap h4 {
        font-size: 14px;
    }

    .wp-ai-title-wrap span {
        font-size: 10.5px;
    }

    .wp-ai-messages {
        padding: 12px;
        gap: 10px;
    }

    .wp-ai-message {
        font-size: 12.5px;
        max-width: 90%;
    }

    .wp-ai-chips {
        padding: 6px 10px;
        gap: 5px;
    }

    .wp-ai-chip {
        padding: 4px 9px;
        font-size: 11px;
    }

    .wp-ai-input-area {
        padding: 8px 10px;
        gap: 6px;
    }

    #wp-ai-chatbot-root input[type="text"].wp-ai-input,
    .wp-ai-input {
        padding: 7px 12px !important;
        font-size: 12.5px !important;
        height: auto !important;
    }

    #wp-ai-chatbot-root input[type="text"].wp-ai-input::placeholder,
    .wp-ai-input::placeholder {
        font-size: 11.5px !important;
        color: #9ca3af !important;
    }

    .wp-ai-send-btn {
        width: 34px;
        height: 34px;
        min-width: 34px;
    }

    .wp-ai-send-btn svg {
        width: 14px;
        height: 14px;
    }
}

