/* =========================================================
   MAXBLO AI Assistant + floating buttons
   Loads after maxblo-theme.css. Right-hand column, bottom to top:
   WhatsApp (24px) -> AI assistant (92px) -> back to top (160px).
========================================================= */

:root {
    --mx-ai-navy: #232F84;
    --mx-ai-navy-deep: #10164A;
    --mx-ai-royal: #3D5AFE;
    --mx-ai-cyan: #3CCBFF;
    --mx-ai-light: #F3F5FF;
    --mx-ai-ink: #161B3D;
    --mx-ai-muted: #5A6086;
    --mx-ai-size: 56px;
    --mx-ai-edge: 24px;
}


/* ---------- floating column ---------- */

.mx-whatsapp {
    left: auto;
    right: var(--mx-ai-edge);
    bottom: var(--mx-ai-edge);
    width: var(--mx-ai-size);
    height: var(--mx-ai-size);
}

.back-to-top-wrapper {
    right: calc(var(--mx-ai-edge) + (var(--mx-ai-size) - 44px) / 2);
    bottom: 120px;
}

.back-to-top-wrapper.back-to-top-btn-show {
    bottom: calc(var(--mx-ai-edge) + var(--mx-ai-size) * 2 + 24px);
}

/* while the chat is open, the floating buttons step aside */
body.mx-ai-open .mx-whatsapp,
body.mx-ai-open .back-to-top-wrapper,
body.mx-ai-open #mx-ai-launcher {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}


/* ---------- launcher ---------- */

#mx-ai-root {
    font-family: inherit;
}

#mx-ai-root *,
#mx-ai-root *::before,
#mx-ai-root *::after {
    box-sizing: border-box;
}

#mx-ai-launcher {
    position: fixed;
    right: var(--mx-ai-edge);
    bottom: calc(var(--mx-ai-edge) + var(--mx-ai-size) + 12px);
    z-index: 999;
    width: var(--mx-ai-size);
    height: var(--mx-ai-size);
    padding: 0;
    border: 0;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    color: #fff;
    cursor: pointer;
    background: linear-gradient(135deg, var(--mx-ai-royal), var(--mx-ai-navy) 70%);
    box-shadow: 0 10px 25px rgba(35, 47, 132, 0.4);
    transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
    animation: mx-ai-glow 3s ease-in-out infinite;
}

#mx-ai-launcher:hover {
    transform: scale(1.08);
}

.mx-ai-launcher-icon {
    display: flex;
    color: var(--mx-ai-cyan);
}

.mx-ai-launcher-icon svg {
    width: 20px;
    height: 20px;
}

.mx-ai-launcher-label {
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 1px;
}

.mx-ai-launcher-tip {
    position: absolute;
    right: calc(100% + 12px);
    top: 50%;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    color: #fff;
    background: var(--mx-ai-navy-deep);
    box-shadow: 0 8px 20px rgba(16, 22, 74, 0.25);
    opacity: 0;
    visibility: hidden;
    transform: translate(6px, -50%);
    transition: all 0.25s ease;
    pointer-events: none;
}

#mx-ai-launcher:hover .mx-ai-launcher-tip,
#mx-ai-launcher:focus-visible .mx-ai-launcher-tip {
    opacity: 1;
    visibility: visible;
    transform: translate(0, -50%);
}

@keyframes mx-ai-glow {
    0%, 100% { box-shadow: 0 10px 25px rgba(35, 47, 132, 0.4), 0 0 0 0 rgba(60, 203, 255, 0.35); }
    50% { box-shadow: 0 10px 25px rgba(35, 47, 132, 0.4), 0 0 0 8px rgba(60, 203, 255, 0); }
}


/* ---------- chat window ---------- */

#mx-ai-window {
    position: fixed;
    right: var(--mx-ai-edge);
    bottom: var(--mx-ai-edge);
    z-index: 1000;
    width: 380px;
    height: min(620px, calc(100dvh - 48px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 22px;
    background: #fff;
    border: 1px solid rgba(35, 47, 132, 0.1);
    box-shadow: 0 30px 80px rgba(16, 22, 74, 0.28);
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px) scale(0.98);
    transform-origin: bottom right;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
}

#mx-ai-window.is-open {
    opacity: 1;
    visibility: visible;
    transform: none;
}

/* header */
.mx-ai-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    color: #fff;
    background:
        radial-gradient(circle at 90% 0%, rgba(60, 203, 255, 0.35), transparent 55%),
        linear-gradient(135deg, var(--mx-ai-navy-deep), var(--mx-ai-navy));
}

.mx-ai-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mx-ai-brand-icon {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 50%;
    background: #fff;
    padding: 2px;
}

.mx-ai-brand-icon img {
    width: 100%;
    height: 100%;
    display: block;
}

.mx-ai-brand strong {
    display: block;
    font-size: 15px;
    line-height: 1.2;
    color: #fff;
}

.mx-ai-brand small {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.75);
}

.mx-ai-brand small i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #2EE59D;
    box-shadow: 0 0 0 3px rgba(46, 229, 157, 0.25);
}

#mx-ai-close {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: grid;
    place-content: center;
    padding: 0;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
    transition: background 0.25s ease;
}

#mx-ai-close:hover {
    background: rgba(255, 255, 255, 0.22);
}

/* messages */
#mx-ai-messages {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--mx-ai-light);
}

#mx-ai-messages::-webkit-scrollbar { width: 5px; }
#mx-ai-messages::-webkit-scrollbar-thumb { background: rgba(35, 47, 132, 0.25); border-radius: 5px; }

.mx-ai-message {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.mx-ai-user {
    justify-content: flex-end;
}

.mx-ai-avatar {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    display: grid;
    place-content: center;
    border-radius: 50%;
    color: var(--mx-ai-cyan);
    background: var(--mx-ai-navy);
}

.mx-ai-avatar svg {
    width: 15px;
    height: 15px;
}

.mx-ai-bubble {
    max-width: 85%;
    padding: 12px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.mx-ai-bot .mx-ai-bubble {
    color: var(--mx-ai-ink);
    background: #fff;
    border: 1px solid rgba(35, 47, 132, 0.08);
    border-top-left-radius: 4px;
}

.mx-ai-user .mx-ai-bubble {
    color: #fff;
    background: linear-gradient(135deg, var(--mx-ai-royal), var(--mx-ai-navy));
    border-top-right-radius: 4px;
}

.mx-ai-bubble strong {
    color: inherit;
    font-weight: 700;
}

.mx-ai-link {
    color: var(--mx-ai-royal);
    font-weight: 600;
    text-decoration: none;
}

.mx-ai-link:hover {
    text-decoration: underline;
}

.mx-ai-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.mx-ai-action {
    display: inline-flex;
    align-items: center;
    padding: 7px 14px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    color: #fff;
    background: var(--mx-ai-navy);
    transition: background 0.25s ease;
}

.mx-ai-action:hover {
    color: #fff;
    background: var(--mx-ai-royal);
}

/* typing dots */
.mx-ai-dots {
    display: inline-flex;
    gap: 5px;
    padding: 4px 0;
}

.mx-ai-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--mx-ai-royal);
    animation: mx-ai-typing 1.2s ease-in-out infinite;
}

.mx-ai-dots span:nth-child(2) { animation-delay: 0.15s; }
.mx-ai-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes mx-ai-typing {
    0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

/* quick questions */
.mx-ai-quick {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    overflow-x: auto;
    scrollbar-width: none;
    background: #fff;
    border-top: 1px solid rgba(35, 47, 132, 0.06);
}

.mx-ai-quick::-webkit-scrollbar { display: none; }

.mx-ai-quick button {
    flex-shrink: 0;
    padding: 7px 14px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    color: var(--mx-ai-navy);
    background: var(--mx-ai-light);
    border: 1px solid rgba(35, 47, 132, 0.12);
    transition: all 0.25s ease;
}

.mx-ai-quick button:hover {
    color: #fff;
    background: var(--mx-ai-navy);
    border-color: var(--mx-ai-navy);
}

/* input */
.mx-ai-input {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 16px;
    padding: 5px 5px 5px 18px;
    border-radius: 30px;
    background: var(--mx-ai-light);
    border: 1px solid rgba(35, 47, 132, 0.12);
    transition: border-color 0.25s ease;
}

.mx-ai-input:focus-within {
    border-color: var(--mx-ai-royal);
}

#mx-ai-input {
    flex: 1;
    min-width: 0;
    height: 40px;
    padding: 0;
    border: 0;
    outline: none;
    font-size: 14px;
    color: var(--mx-ai-ink);
    background: transparent;
}

#mx-ai-input::placeholder {
    color: #8A90B0;
}

#mx-ai-send {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: grid;
    place-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    color: #fff;
    background: var(--mx-ai-navy);
    transition: background 0.25s ease;
}

#mx-ai-send:hover {
    background: var(--mx-ai-royal);
}

#mx-ai-send:disabled {
    opacity: 0.55;
    cursor: default;
}

.mx-ai-footer {
    flex-shrink: 0;
    padding: 10px 16px 12px;
    text-align: center;
    font-size: 11px;
    letter-spacing: 0.4px;
    color: var(--mx-ai-muted);
    background: #fff;
}

/* focus */
#mx-ai-root button:focus-visible,
#mx-ai-root a:focus-visible {
    outline: 2px solid var(--mx-ai-cyan);
    outline-offset: 3px;
}


/* ---------- mobile ---------- */

@media (max-width: 767px) {
    :root {
        --mx-ai-size: 52px;
        --mx-ai-edge: 16px;
    }

    #mx-ai-launcher .mx-ai-launcher-tip {
        display: none;
    }

    #mx-ai-window {
        right: 10px;
        left: 10px;
        bottom: 10px;
        width: auto;
        height: calc(100dvh - 20px);
        border-radius: 18px;
    }
}


/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    #mx-ai-launcher,
    #mx-ai-window,
    .mx-ai-dots span {
        animation: none !important;
        transition: none !important;
    }
}
