/* Mix Media AI Chat — fixed right, all pages */
.mm-ai-chat {
    --mm-ai-panel: #14102a;
    --mm-ai-border: rgba(139, 92, 246, 0.28);
    --mm-ai-violet: #8b5cf6;
    --mm-ai-cyan: #22d3ee;
    --mm-ai-text: #e8eaf6;
    --mm-ai-muted: #9ca3af;
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 99999;
    font-family: 'Noto Sans Armenian', 'Plus Jakarta Sans', system-ui, sans-serif;
}

body:has(.mm-ai-chat) .back-to-top {
    bottom: 7.5rem;
}

/* ── Launcher (icon + label) ── */
.mm-ai-chat__launcher {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.mm-ai-chat__label {
    font-size: 0.72rem;
    font-weight: 700;
    color: #c4b5fd;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 8px rgba(139, 92, 246, 0.5);
    pointer-events: none;
    user-select: none;
    transition: opacity 0.2s ease;
}

.mm-ai-chat__toggle {
    position: relative;
    width: 4.75rem;
    height: 4.75rem;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(135deg, #7c3aed 0%, #6366f1 45%, #22d3ee 100%);
    box-shadow: 0 10px 40px rgba(124, 58, 237, 0.55), 0 0 0 0 rgba(139, 92, 246, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    transition: box-shadow 0.25s ease;
}

.mm-ai-chat__toggle:not(.is-open) {
    animation: mm-ai-breathe 2.6s ease-in-out infinite;
}

.mm-ai-chat__pulse {
    position: absolute;
    inset: -4px;
    border-radius: 999px;
    border: 2px solid rgba(167, 139, 250, 0.55);
    pointer-events: none;
    animation: mm-ai-pulse-ring 2.6s ease-out infinite;
}

.mm-ai-chat__toggle.is-open .mm-ai-chat__pulse {
    display: none;
}

.mm-ai-chat__toggle.is-open {
    animation: none;
    transform: none;
    background: #1e293b;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
    width: 3.5rem;
    height: 3.5rem;
    font-size: 1.25rem;
}

.mm-ai-chat__toggle:hover:not(.is-open) {
    box-shadow: 0 14px 48px rgba(34, 211, 238, 0.4);
}

@keyframes mm-ai-breathe {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.1); }
}

@keyframes mm-ai-pulse-ring {
    0%   { transform: scale(1);   opacity: 0.65; }
    70%  { transform: scale(1.45); opacity: 0; }
    100% { transform: scale(1.45); opacity: 0; }
}

/* ── Panel ── */
.mm-ai-chat__panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 0.65rem);
    width: min(23.5rem, calc(100vw - 2rem));
    max-height: min(44rem, calc(100vh - 5rem));
    background: var(--mm-ai-panel);
    border: 1px solid var(--mm-ai-border);
    border-radius: 1.35rem;
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(139, 92, 246, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(14px) scale(0.95);
    transition: opacity 0.24s ease, transform 0.24s ease, visibility 0.24s;
    pointer-events: none;
}

.mm-ai-chat__panel.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.mm-ai-chat__header {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: linear-gradient(180deg, rgba(124, 58, 237, 0.14), transparent);
}

.mm-ai-chat__avatar {
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--mm-ai-violet), var(--mm-ai-cyan));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: #fff;
    flex-shrink: 0;
}

.mm-ai-chat__title {
    font-size: 0.92rem;
    font-weight: 800;
    color: #fff;
    line-height: 1.2;
}

.mm-ai-chat__subtitle {
    font-size: 0.67rem;
    color: var(--mm-ai-muted);
}

.mm-ai-chat__close {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--mm-ai-muted);
    cursor: pointer;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mm-ai-chat__close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

/* ── Quick chips (top) ── */
.mm-ai-chat__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.75rem 0.85rem 0.25rem;
}

.mm-ai-chat__chips.is-hidden {
    display: none;
}

.mm-ai-chat__chip {
    border: 1px solid rgba(139, 92, 246, 0.4);
    background: rgba(139, 92, 246, 0.08);
    color: #ddd6fe;
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.38rem 0.65rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    line-height: 1.3;
    text-align: left;
}

.mm-ai-chat__chip:hover {
    background: rgba(139, 92, 246, 0.22);
    border-color: rgba(167, 139, 250, 0.65);
}

/* ── Messages + bottom (static lead + chat) ── */
.mm-ai-chat__body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mm-ai-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0.85rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    scroll-behavior: smooth;
}

.mm-ai-chat__messages::-webkit-scrollbar {
    width: 4px;
}

.mm-ai-chat__messages::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.35);
    border-radius: 4px;
}

.mm-ai-chat__bubble {
    max-width: 94%;
    padding: 0.75rem 0.9rem;
    border-radius: 1rem;
    font-size: 0.83rem;
    line-height: 1.5;
    word-break: break-word;
}

.mm-ai-chat__bubble--bot {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.055);
    color: var(--mm-ai-text);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom-left-radius: 0.3rem;
}

.mm-ai-chat__bubble--user {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.9), rgba(99, 102, 241, 0.88));
    color: #fff;
    border-bottom-right-radius: 0.3rem;
    white-space: pre-wrap;
}

.mm-ai-chat__bubble--typing {
    color: var(--mm-ai-muted);
    font-style: italic;
}

.mm-ai-chat__welcome-title {
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.55rem;
}

.mm-ai-chat__welcome-lead {
    margin-bottom: 0.35rem;
    color: var(--mm-ai-text);
}

.mm-ai-chat__welcome-list {
    margin: 0 0 0.55rem 1.1rem;
    padding: 0;
    color: #c4b5fd;
}

.mm-ai-chat__welcome-list li {
    margin-bottom: 0.2rem;
}

.mm-ai-chat__welcome-end {
    color: var(--mm-ai-muted);
    font-size: 0.8rem;
}

/* ── Bottom: lead button + collapsible form + chat ── */
.mm-ai-chat__bottom {
    flex-shrink: 0;
    position: relative;
    z-index: 8;
    background: rgba(0, 0, 0, 0.4);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.mm-ai-chat__lead-bar {
    padding: 0.55rem 0.75rem 0;
}

.mm-ai-chat__lead-btn {
    width: 100%;
    border: 1px solid rgba(139, 92, 246, 0.45);
    background: rgba(139, 92, 246, 0.12);
    color: #e9d5ff;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 0.55rem 0.75rem;
    border-radius: 0.75rem;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s;
}

.mm-ai-chat__lead-btn:hover,
.mm-ai-chat__panel.is-lead-open .mm-ai-chat__lead-btn {
    background: rgba(139, 92, 246, 0.22);
    border-color: rgba(167, 139, 250, 0.7);
}

.mm-ai-chat__lead-static {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.55rem 0.75rem 0.5rem;
    background: linear-gradient(180deg, rgba(124, 58, 237, 0.12), rgba(124, 58, 237, 0.04));
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
}

.mm-ai-chat__lead-static[hidden] {
    display: none !important;
}

.mm-ai-chat__lead-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
}

.mm-ai-chat__chat-bar {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    padding: 0.55rem 0.75rem 0.7rem;
}

.mm-ai-chat__lead-title {
    font-size: 0.88rem;
    font-weight: 800;
    color: #fff;
    margin: 0 0 0.15rem;
    flex-shrink: 0;
}

.mm-ai-chat__lead-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    flex-shrink: 0;
}

.mm-ai-chat__lead-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: #c4b5fd;
    line-height: 1.3;
}

.mm-ai-chat .mm-ai-chat__lead-input {
    display: block;
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    border-radius: 0.65rem;
    padding: 0.6rem 0.75rem;
    font-size: 0.82rem;
    font-family: inherit;
    box-sizing: border-box;
    margin: 0;
    line-height: 1.4;
    -webkit-appearance: none;
    appearance: none;
}

.mm-ai-chat .mm-ai-chat__lead-input::placeholder {
    color: #6b7280;
}

.mm-ai-chat .mm-ai-chat__lead-input:focus {
    outline: none;
    border-color: rgba(139, 92, 246, 0.6);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.15);
}

.mm-ai-chat__lead-textarea {
    resize: vertical;
    min-height: 2.6rem;
    max-height: 5rem;
}

.mm-ai-chat__lead-actions {
    display: flex;
    gap: 0.45rem;
    margin-top: 0.1rem;
}

.mm-ai-chat__lead-cancel,
.mm-ai-chat__lead-submit {
    flex: 1;
    border: none;
    border-radius: 0.65rem;
    padding: 0.55rem 0.5rem;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.3;
}

.mm-ai-chat__lead-cancel {
    background: rgba(255, 255, 255, 0.08);
    color: #9ca3af;
}

.mm-ai-chat__lead-submit {
    background: linear-gradient(135deg, var(--mm-ai-violet), #6366f1);
    color: #fff;
    transition: opacity 0.15s;
}

.mm-ai-chat__lead-submit:hover {
    opacity: 0.92;
}

.mm-ai-chat__bubble--bot strong {
    color: #e9d5ff;
    font-weight: 700;
}

.mm-ai-chat__bubble--bot a {
    color: #67e8f9;
    text-decoration: underline;
    word-break: break-all;
}

.mm-ai-chat__bubble--bot a:hover {
    color: #a5f3fc;
}

/* ── Input ── */
.mm-ai-chat__input {
    flex: 1;
    border: 1px solid rgba(255, 255, 255, 0.09);
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    border-radius: 0.85rem;
    padding: 0.7rem 0.85rem;
    font-size: 0.86rem;
    font-family: inherit;
    resize: none;
    min-height: 3.35rem;
    max-height: 7rem;
    line-height: 1.45;
    width: 100%;
    box-sizing: border-box;
}

.mm-ai-chat__chat-bar .mm-ai-chat__input {
    min-width: 0;
    min-height: 2.75rem;
    max-height: 5.5rem;
}

.mm-ai-chat__input::placeholder {
    color: #6b7280;
}

.mm-ai-chat__input:focus {
    outline: none;
    border-color: rgba(139, 92, 246, 0.55);
}

.mm-ai-chat__send {
    width: 2.75rem;
    height: 2.75rem;
    border: none;
    border-radius: 0.85rem;
    background: linear-gradient(135deg, var(--mm-ai-violet), #6366f1);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.mm-ai-chat__send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.mm-ai-chat__icon-wa {
    display: none;
}

/* WhatsApp launcher — all viewports */
.mm-ai-chat.is-wa-launcher .mm-ai-chat__icon-chat {
    display: none;
}

.mm-ai-chat.is-wa-launcher .mm-ai-chat__icon-wa {
    display: block;
}

.mm-ai-chat.is-wa-launcher .mm-ai-chat__label {
    display: none;
}

.mm-ai-chat.is-wa-launcher .mm-ai-chat__toggle:not(.is-open) {
    width: 3.5rem;
    height: 3.5rem;
    font-size: 2.15rem;
    background: #25d366;
    box-shadow: 0 8px 28px rgba(37, 211, 102, 0.45), 0 0 0 0 rgba(37, 211, 102, 0.35);
}

.mm-ai-chat.is-wa-launcher .mm-ai-chat__toggle:not(.is-open):hover {
    box-shadow: 0 12px 36px rgba(37, 211, 102, 0.55);
}

.mm-ai-chat.is-wa-launcher .mm-ai-chat__pulse {
    border-color: rgba(37, 211, 102, 0.55);
    inset: -3px;
}

.mm-ai-chat.is-wa-launcher .mm-ai-chat__panel {
    display: none !important;
}

/* Desktop/web — right side, vertically centered */
@media (min-width: 769px) {
    .mm-ai-chat.is-desktop-wa {
        top: 50%;
        bottom: auto;
        right: 1.25rem;
        left: auto;
        transform: translateY(-50%);
    }

    body:has(.mm-ai-chat) .back-to-top {
        bottom: 1.25rem;
    }
}

/* Mobile — bottom left */
@media (max-width: 768px) {
    .mm-ai-chat.is-mobile-wa {
        left: 0.65rem;
        right: auto;
        bottom: 0.65rem;
        top: auto;
        transform: none;
    }

    .mm-ai-chat.is-mobile-wa .mm-ai-chat__toggle:not(.is-open) {
        width: 3.25rem;
        height: 3.25rem;
        font-size: 2rem;
    }

    body:has(.mm-ai-chat) .back-to-top {
        bottom: 6.75rem;
        right: 0.65rem;
    }
}

@media (max-width: 480px) {
    .mm-ai-chat__panel {
        width: calc(100vw - 1.3rem);
        max-height: min(85dvh, calc(100dvh - 5rem));
    }

    .mm-ai-chat__lead-grid {
        grid-template-columns: 1fr;
    }
}
