/* WP AI Chatbot Styles */
:root {
    --wpaic-primary: #6C63FF;
    --wpaic-primary-dark: #5a52e0;
    --wpaic-bg: #ffffff;
    --wpaic-text: #1a1a2e;
    --wpaic-text-muted: #666680;
    --wpaic-border: #e8e8f0;
    --wpaic-radius: 16px;
    --wpaic-shadow: 0 8px 40px rgba(108, 99, 255, 0.18);
}

.wpaic-widget *,
.wpaic-widget *::before,
.wpaic-widget *::after {
    box-sizing: border-box;
}

#wpaic-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Positioning */
.wpaic-bottom-right {
    bottom: 20px;
    right: 20px;
}

.wpaic-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Launcher */
.wpaic-launcher {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--wpaic-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: absolute;
    bottom: 0;
    right: 0;
}

.wpaic-bottom-left .wpaic-launcher {
    right: auto;
    left: 0;
}

.wpaic-launcher:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.wpaic-launcher-icon {
    display: flex;
}

.wpaic-unread-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ff3b30;
    color: white;
    font-size: 11px;
    font-weight: bold;
    height: 20px;
    min-width: 20px;
    padding: 0 6px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

/* Chat Window */
.wpaic-window {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 380px;
    height: 560px;
    background: var(--wpaic-bg);
    border-radius: var(--wpaic-radius);
    box-shadow: var(--wpaic-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.wpaic-bottom-left .wpaic-window {
    right: auto;
    left: 0;
}

.wpaic-window.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Header */
.wpaic-header {
    background: linear-gradient(135deg, var(--wpaic-primary) 0%, var(--wpaic-primary-dark) 100%);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.wpaic-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wpaic-avatar {
    font-size: 24px;
}

.wpaic-bot-name {
    display: block;
    font-size: 16px;
    margin-bottom: 2px;
}

.wpaic-status {
    font-size: 12px;
    opacity: 0.8;
}

.wpaic-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    padding: 4px;
}

.wpaic-close:hover {
    opacity: 1;
}

/* Lead Form */
.wpaic-lead-form {
    padding: 30px 20px;
    flex-grow: 1;
    overflow-y: auto;
    text-align: center;
}

.wpaic-lead-form p {
    color: var(--wpaic-text);
    margin-bottom: 20px;
}

.wpaic-lead-form input {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 12px;
    border: 1px solid var(--wpaic-border);
    border-radius: 8px;
    font-size: 14px;
}

.wpaic-lead-form button {
    width: 100%;
    padding: 12px;
    background: var(--wpaic-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
}

/* Messages Area */
.wpaic-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.wpaic-msg {
    max-width: 85%;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: wpaic-fade-in 0.3s ease;
}

.wpaic-msg-user {
    align-self: flex-end;
    background: var(--wpaic-user-bubble);
    color: #fff;
    border-radius: 18px 18px 4px 18px;
}

.wpaic-msg-bot {
    align-self: flex-start;
    background: var(--wpaic-bot-bubble);
    color: var(--wpaic-text);
    border-radius: 18px 18px 18px 4px;
}

.wpaic-msg-error {
    align-self: center;
    background: #ffebee;
    color: #c62828;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
}

/* Typing Indicator */
.wpaic-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    align-self: flex-start;
    background: #f0efff;
    border-radius: 18px 18px 18px 4px;
    animation: wpaic-fade-in 0.3s ease;
}

.wpaic-typing span {
    width: 6px;
    height: 6px;
    background: var(--wpaic-text-muted);
    border-radius: 50%;
    animation: wpaic-bounce 1s infinite;
}

.wpaic-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.wpaic-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

/* History Bar */
#wpaic-history-bar {
    background: #fffbe6;
    border-bottom: 1px solid #ffe58f;
    padding: 8px 14px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

#wpaic-history-bar button {
    border: none;
    background: none;
    color: var(--wpaic-primary);
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    font-size: 13px;
}

/* API Key Bar */
.wpaic-apikey-bar {
    background: #fff8e1;
    padding: 8px 12px;
    border-top: 1px solid #ffe082;
    display: flex;
    gap: 8px;
}

.wpaic-apikey-bar input {
    flex-grow: 1;
    border: 1px solid #ffe082;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 12px;
}

.wpaic-apikey-bar button {
    background: #ffca28;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    font-weight: 600;
}

/* Input Area */
.wpaic-input-area {
    border-top: 1px solid var(--wpaic-border);
    padding: 12px 16px;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--wpaic-bg);
}

#wpaic-input {
    flex-grow: 1;
    border: none;
    background: transparent;
    resize: none;
    max-height: 120px;
    padding: 8px 0;
    font-family: inherit;
    font-size: 14px;
    color: var(--wpaic-text);
    line-height: 1.4;
}

#wpaic-input:focus {
    outline: none;
}

#wpaic-send {
    background: var(--wpaic-primary);
    color: #fff;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    margin-bottom: 2px;
    transition: background 0.2s;
}

#wpaic-send:hover {
    background: var(--wpaic-primary-dark);
}

/* Footer */
.wpaic-footer {
    text-align: center;
    font-size: 11px;
    color: #aaaacc;
    padding: 6px 0 4px;
    background: #f9f9fb;
    border-top: 1px solid var(--wpaic-border);
}

.wpaic-brand-link {
    color: #6C63FF;
    text-decoration: none;
    font-weight: 600;
}

.wpaic-brand-link:hover {
    text-decoration: underline;
}

/* GDPR Notice (Feature 16) */
.wpaic-gdpr-notice {
    background: #1a1a2e;
    color: #fff;
    font-size: 11px;
    padding: 10px 14px;
    display: none;
    /* JS will toggle */
    align-items: center;
    gap: 10px;
    justify-content: space-between;
}

.wpaic-gdpr-notice a {
    color: var(--wpaic-primary);
    text-decoration: underline;
}

.wpaic-gdpr-btn {
    background: var(--wpaic-primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
    font-weight: 600;
}

/* Demo Banner (Feature 17) */
.wpaic-demo-banner {
    background: #ff9800;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    text-align: center;
    padding: 6px;
    width: 100%;
}

/* Feature 1 Customizer Classes */
.wpaic-font-sm .wpaic-msg {
    font-size: 13px;
}

.wpaic-font-md .wpaic-msg {
    font-size: 15px;
}

.wpaic-font-lg .wpaic-msg {
    font-size: 17px;
}

.wpaic-radius-sharp,
.wpaic-radius-sharp .wpaic-window {
    border-radius: 4px;
}

.wpaic-radius-pill .wpaic-launcher {
    border-radius: 50%;
}

.wpaic-radius-rounded .wpaic-window {
    border-radius: var(--wpaic-radius);
}

/* Feature 6: Inline Shortcode Styles */
.wpaic-inline {
    position: relative !important;
    max-width: 400px;
    margin: 20px auto;
    bottom: auto !important;
    right: auto !important;
    left: auto !important;
    display: block !important;
    z-index: 1 !important;
}

.wpaic-inline .wpaic-launcher {
    display: none !important;
}

.wpaic-inline .wpaic-window {
    position: relative !important;
    bottom: auto !important;
    right: auto !important;
    left: auto !important;
    display: flex !important;
    opacity: 1 !important;
    transform: none !important;
    pointer-events: auto !important;
    width: 100% !important;
    height: 600px !important;
    max-height: 80vh !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

.wpaic-inline .wpaic-close {
    display: none !important;
}

/* Animations */
@keyframes wpaic-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes wpaic-bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-4px);
    }
}

/* Responsive */
@media (max-width: 480px) {
    #wpaic-widget {
        position: fixed;
        z-index: 999999;
    }
    
    /* Launcher stays in corner */
    .wpaic-bottom-right #wpaic-launcher {
        bottom: 20px !important;
        right: 16px !important;
    }
    .wpaic-bottom-left #wpaic-launcher {
        bottom: 20px !important;
        left: 16px !important;
    }

    /* Window takes full screen on mobile */
    #wpaic-window {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        z-index: 999999 !important;
        display: flex;
        flex-direction: column;
    }

    /* Messages area fills available space */
    #wpaic-messages {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Larger tap targets */
    #wpaic-send {
        min-width: 44px;
        min-height: 44px;
    }

    #wpaic-launcher {
        width: 56px !important;
        height: 56px !important;
        min-width: 56px;
        min-height: 56px;
    }

    /* Input stays above keyboard */
    .wpaic-input-area {
        position: sticky;
        bottom: 0;
        background: white;
        padding-bottom: env(safe-area-inset-bottom, 8px);
    }

    /* Close button bigger on mobile */
    .wpaic-close {
        min-width: 44px;
        min-height: 44px;
        font-size: 20px;
    }

    /* Prevent body scroll when chat open */
    html.wpaic-open, body.wpaic-open {
        overflow: hidden !important;
    }
}