/* WP Site Chat AI — frontend */

.wpsc-ai-chat,
.wpsc-ai-launcher {
    /* Theme-friendly tokens: fall back to sensible defaults but use the theme's vars where present. */
    --wpsc-ai-bg: var(--wp--preset--color--base, #ffffff);
    --wpsc-ai-fg: var(--wp--preset--color--contrast, #1a1a1a);
    --wpsc-ai-muted: rgba(0, 0, 0, 0.55);
    --wpsc-ai-border: rgba(0, 0, 0, 0.12);
    --wpsc-ai-accent: var(--wp--preset--color--primary, var(--wp--preset--color--vivid-cyan-blue, #2563eb));
    --wpsc-ai-accent-fg: #ffffff;
    --wpsc-ai-bubble-bot: var(--wp--preset--color--tertiary, #f3f4f6);
    --wpsc-ai-radius: 14px;
    --wpsc-ai-font: var(--wp--preset--font-family--body, inherit);
}

/* Launcher button (floating) */
.wpsc-ai-launcher {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 99998;
    font-family: var(--wpsc-ai-font);
}
.wpsc-ai-launcher__btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    background: var(--wpsc-ai-accent);
    color: var(--wpsc-ai-accent-fg);
    border: none;
    border-radius: 999px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease;
}
.wpsc-ai-launcher__btn:hover { transform: translateY(-1px); }
.wpsc-ai-launcher__icon { font-size: 18px; line-height: 1; }

/* Chat container — floating */
.wpsc-ai-chat--floating {
    position: fixed;
    right: 20px;
    bottom: 90px;
    width: min(380px, calc(100vw - 40px));
    height: min(560px, calc(100vh - 120px));
    z-index: 99999;
}
.wpsc-ai-chat--floating .wpsc-ai-chat__panel {
    height: 100%;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    border-radius: var(--wpsc-ai-radius);
    overflow: hidden;
}

/* Embedded variant via shortcode */
.wpsc-ai-chat--embed {
    width: 100%;
    max-width: 720px;
    height: 560px;
    margin: 20px auto;
}
.wpsc-ai-chat--embed .wpsc-ai-chat__panel {
    height: 100%;
    border-radius: var(--wpsc-ai-radius);
    border: 1px solid var(--wpsc-ai-border);
}

/* Panel */
.wpsc-ai-chat__panel {
    display: flex;
    flex-direction: column;
    background: var(--wpsc-ai-bg);
    color: var(--wpsc-ai-fg);
    font-family: var(--wpsc-ai-font);
    font-size: 15px;
    line-height: 1.45;
}

.wpsc-ai-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--wpsc-ai-accent);
    color: var(--wpsc-ai-accent-fg);
    font-weight: 600;
}
.wpsc-ai-chat__title { font-size: 15px; }
.wpsc-ai-chat__close {
    background: transparent;
    border: none;
    color: var(--wpsc-ai-accent-fg);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

/* Messages list */
.wpsc-ai-chat__messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--wpsc-ai-bg);
}

.wpsc-ai-msg {
    max-width: 85%;
    padding: 10px 12px;
    border-radius: 12px;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.wpsc-ai-msg--bot {
    align-self: flex-start;
    background: var(--wpsc-ai-bubble-bot);
    color: var(--wpsc-ai-fg);
    border-bottom-left-radius: 4px;
}
.wpsc-ai-msg--user {
    align-self: flex-end;
    background: var(--wpsc-ai-accent);
    color: var(--wpsc-ai-accent-fg);
    border-bottom-right-radius: 4px;
}
.wpsc-ai-msg--system {
    align-self: center;
    background: transparent;
    color: var(--wpsc-ai-muted);
    font-size: 13px;
    font-style: italic;
}
.wpsc-ai-msg a {
    color: inherit;
    text-decoration: underline;
}

/* Action chip (e.g. Book a meeting) */
.wpsc-ai-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 14px 8px;
}
.wpsc-ai-actions__btn {
    background: var(--wpsc-ai-accent);
    color: var(--wpsc-ai-accent-fg);
    border: none;
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

/* Input form */
.wpsc-ai-chat__form {
    display: flex;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid var(--wpsc-ai-border);
    background: var(--wpsc-ai-bg);
}
.wpsc-ai-chat__input {
    flex: 1 1 auto;
    padding: 10px 12px;
    border: 1px solid var(--wpsc-ai-border);
    border-radius: 999px;
    font: inherit;
    color: var(--wpsc-ai-fg);
    background: var(--wpsc-ai-bg);
}
.wpsc-ai-chat__input:focus {
    outline: 2px solid var(--wpsc-ai-accent);
    outline-offset: 1px;
}
.wpsc-ai-chat__send {
    padding: 10px 16px;
    background: var(--wpsc-ai-accent);
    color: var(--wpsc-ai-accent-fg);
    border: none;
    border-radius: 999px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.wpsc-ai-chat__send:disabled { opacity: 0.5; cursor: not-allowed; }

/* Typing indicator */
.wpsc-ai-typing {
    display: inline-flex;
    gap: 4px;
    padding: 4px 0;
}
.wpsc-ai-typing span {
    width: 6px;
    height: 6px;
    background: var(--wpsc-ai-muted);
    border-radius: 50%;
    animation: wpsc-ai-bounce 1.2s infinite ease-in-out;
}
.wpsc-ai-typing span:nth-child(2) { animation-delay: 0.15s; }
.wpsc-ai-typing span:nth-child(3) { animation-delay: 0.30s; }
@keyframes wpsc-ai-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40%           { transform: scale(1);   opacity: 1; }
}

@media (max-width: 480px) {
    .wpsc-ai-chat--floating {
        right: 10px;
        left: 10px;
        bottom: 80px;
        width: auto;
        height: min(70vh, 560px);
    }
}
