/* =====================================================================
   FreshAir Climatisation — AI Chat Assistant widget styles
   File: assets/css/ai-chat-widget.css
   ---------------------------------------------------------------------
   Reuses the CSS custom properties already defined in header.php's
   :root block (--color-primary, --color-interactive, etc.) — load this
   AFTER header.php's inline <style>.
   ---------------------------------------------------------------------
   CHANGELOG
   v1.0.0 — 2026-07-11 — Initial build. Replaces the Tawk.to widget with
            an on-brand equivalent: bottom-right launcher bubble, slide-
            up panel, message bubbles in the site's own palette, typing
            indicator, full-screen takeover on phones.
   ===================================================================== */

/* ---------------------------------------------------------------------
   Launcher bubble
   --------------------------------------------------------------------- */
.ai-chat-launcher {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--color-interactive);
    color: var(--color-base);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 26px rgba(10, 17, 40, 0.28);
    z-index: 1060;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.ai-chat-launcher:hover {
    background: var(--color-accent);
    transform: translateY(-2px);
}

.ai-chat-launcher svg {
    width: 26px;
    height: 26px;
}

.ai-chat-launcher .icon-close {
    display: none;
}

.ai-chat-launcher.is-open .icon-chat {
    display: none;
}

.ai-chat-launcher.is-open .icon-close {
    display: block;
}

/* Small unread/greeting dot — shown once before the visitor's first
   open, matches the cart badge's visual language rather than
   introducing a new UI element. */
.ai-chat-launcher .launcher-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #2fae66;
    border: 2px solid var(--color-base);
}

/* ---------------------------------------------------------------------
   Panel
   --------------------------------------------------------------------- */
.ai-chat-panel {
    position: fixed;
    right: 20px;
    bottom: 90px;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: min(560px, calc(100vh - 130px));
    background: var(--color-base);
    border-radius: 10px;
    box-shadow: 0 20px 55px rgba(10, 17, 40, 0.32);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1059;
    opacity: 0;
    transform: translateY(16px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.ai-chat-panel.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.ai-chat-header {
    background: var(--color-primary);
    color: var(--color-base);
    padding: 1rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-shrink: 0;
}

.ai-chat-header .avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--color-interactive);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-chat-header .avatar svg {
    width: 18px;
    height: 18px;
}

.ai-chat-header .title {
    font-size: 0.98rem;
    font-weight: 700;
    line-height: 1.2;
}

.ai-chat-header .subtitle {
    font-size: 0.74rem;
    color: rgba(254, 252, 251, 0.7);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.ai-chat-header .status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #2fae66;
    flex-shrink: 0;
}

/* ---------------------------------------------------------------------
   Messages
   --------------------------------------------------------------------- */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    background: #f4f6f9;
}

.ai-chat-msg {
    max-width: 82%;
    padding: 0.6rem 0.85rem;
    border-radius: 12px;
    font-size: 0.88rem;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.ai-chat-msg.from-assistant {
    align-self: flex-start;
    background: var(--color-base);
    color: var(--color-primary);
    border: 1px solid rgba(10, 17, 40, 0.08);
    border-bottom-left-radius: 3px;
}

.ai-chat-msg.from-user {
    align-self: flex-end;
    background: var(--color-interactive);
    color: var(--color-base);
    border-bottom-right-radius: 3px;
}

.ai-chat-msg.is-error {
    align-self: flex-start;
    background: #fdecea;
    color: #7a2018;
    border: 1px solid #f2c1bc;
}

/* Typing indicator — three dots, shown as a temporary assistant-style
   bubble while waiting on the ai_chat.php response. */
.ai-chat-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 0.7rem 0.9rem;
    background: var(--color-base);
    border: 1px solid rgba(10, 17, 40, 0.08);
    border-radius: 12px;
    border-bottom-left-radius: 3px;
}

.ai-chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(10, 17, 40, 0.35);
    animation: aiChatTypingBounce 1.1s infinite ease-in-out;
}

.ai-chat-typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.ai-chat-typing span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes aiChatTypingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.5;
    }

    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* ---------------------------------------------------------------------
   Suggested quick-reply chips (shown once, above the first assistant
   message, so a visitor doesn't have to type a first question).
   --------------------------------------------------------------------- */
.ai-chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0 1rem 0.75rem;
    background: #f4f6f9;
}

.ai-chat-suggestion-chip {
    border: 1px solid rgba(18, 130, 162, 0.4);
    background: var(--color-base);
    color: var(--color-interactive);
    border-radius: 999px;
    padding: 0.35rem 0.8rem;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.ai-chat-suggestion-chip:hover {
    background: var(--color-interactive);
    color: var(--color-base);
}

/* ---------------------------------------------------------------------
   Input row
   --------------------------------------------------------------------- */
.ai-chat-input-row {
    flex-shrink: 0;
    border-top: 1px solid rgba(10, 17, 40, 0.1);
    background: var(--color-base);
    padding: 0.65rem 0.65rem 0.65rem 1rem;
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

.ai-chat-input-row textarea {
    flex: 1;
    resize: none;
    border: none;
    outline: none;
    font-family: var(--font-stack);
    font-size: 0.92rem;
    /* 16px-equivalent min to avoid iOS zoom-on-focus */
    line-height: 1.4;
    max-height: 90px;
    padding: 0.5rem 0;
    color: var(--color-primary);
}

.ai-chat-input-row textarea::placeholder {
    color: #8a90a0;
}

.ai-chat-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: var(--color-interactive);
    color: var(--color-base);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.15s ease, opacity 0.15s ease;
}

.ai-chat-send:hover:not(:disabled) {
    background: var(--color-accent);
}

.ai-chat-send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.ai-chat-send svg {
    width: 17px;
    height: 17px;
}

.ai-chat-footnote {
    text-align: center;
    font-size: 0.68rem;
    color: #9299a8;
    padding: 0.4rem 0 0.7rem;
    background: var(--color-base);
}

/* ---------------------------------------------------------------------
   Mobile: full-screen takeover instead of a floating panel, same
   pattern the rest of the site uses for its mobile nav/sidebar.
   --------------------------------------------------------------------- */
@media (max-width: 480px) {
    .ai-chat-panel {
        right: 0;
        bottom: 0;
        left: 0;
        top: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .ai-chat-launcher {
        right: 16px;
        bottom: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {

    .ai-chat-panel,
    .ai-chat-launcher {
        transition: none;
    }

    .ai-chat-typing span {
        animation: none;
        opacity: 0.8;
    }
}