/*
 * MxChat Persian Companion: front-end overrides.
 *
 * Loaded after MxChat's chat-style.css. Every rule is scoped to classes the
 * companion adds to MxChat's wrapper elements:
 *   .mxfa-widget          every companion-touched element
 *   .mxfa-rtl             right-to-left layout (the wrapper also gets dir="rtl")
 *   .mxfa-font-*          Persian font
 *   .mxfa-side-left       floating widget on the left
 *   .mxfa-norag           No-RAG mode (upload buttons hidden)
 * so nothing here can affect the rest of the site.
 */

/* ------------------------------------------------------------------ */
/* Font (Vazirmatn by Saber Rastikerdar, SIL OFL 1.1 — see fonts/OFL.txt) */
/* ------------------------------------------------------------------ */
@font-face {
    font-family: "MXFA Vazirmatn";
    src: url("../fonts/Vazirmatn-Regular.woff2") format("woff2");
    font-weight: 100 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "MXFA Vazirmatn";
    src: url("../fonts/Vazirmatn-Bold.woff2") format("woff2");
    font-weight: 600 900;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "MXFA Vazirmatn FD";
    src: url("../fonts/Vazirmatn-FD-Regular.woff2") format("woff2");
    font-weight: 100 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "MXFA Vazirmatn FD";
    src: url("../fonts/Vazirmatn-FD-Bold.woff2") format("woff2");
    font-weight: 600 900;
    font-style: normal;
    font-display: swap;
}

.mxfa-font-vazirmatn {
    --mxfa-font: "MXFA Vazirmatn", Tahoma, "Segoe UI", sans-serif;
}
.mxfa-font-vazirmatn-fd {
    --mxfa-font: "MXFA Vazirmatn FD", Tahoma, "Segoe UI", sans-serif;
}

/* Explicit on the text elements too, so theme rules like `body p { font-family: … }` don't win. */
.mxfa-font-vazirmatn,
.mxfa-font-vazirmatn-fd,
.mxfa-widget[class*="mxfa-font-"] :is(p, span, div, li, a, strong, b, em, i, label, button, input, textarea, select, h1, h2, h3, h4, h5, h6, td, th, blockquote),
.mxfa-widget[class*="mxfa-font-"] .chatbot-top-bar .chatbot-title {
    font-family: var(--mxfa-font);
}
/* Code stays monospace. */
.mxfa-widget :is(pre, code, .mxchat-code-block, .mxchat-inline-code),
.mxfa-widget :is(pre, code) * {
    font-family: "Monaco", "Menlo", "Ubuntu Mono", "Courier New", monospace !important;
}

/* Persian script needs a little more line height than Latin. */
.mxfa-widget[class*="mxfa-font-"] .bot-message,
.mxfa-widget[class*="mxfa-font-"] .user-message,
.mxfa-widget[class*="mxfa-font-"] .mxchat-popular-question {
    line-height: 1.9;
}

/* ------------------------------------------------------------------ */
/* RTL layout                                                          */
/* ------------------------------------------------------------------ */
.mxchat-chatbot-wrapper.mxfa-rtl {
    direction: rtl;
    text-align: right;
}

/* Header: title on the right, menu + close on the left. */
.mxchat-chatbot-wrapper.mxfa-rtl .mxchat-header-menu-wrap {
    margin-left: 0;
    margin-right: auto;
}
.mxchat-chatbot-wrapper.mxfa-rtl .chatbot-top-bar .exit-chat {
    margin-left: 0;
    margin-right: auto;
}
.mxchat-chatbot-wrapper.mxfa-rtl .chatbot-top-bar .mxchat-header-menu-wrap ~ .exit-chat,
.mxchat-chatbot-wrapper.mxfa-rtl .chatbot-top-bar .mxchat-header-menu-wrap + .exit-chat {
    margin-left: 0;
    margin-right: 4px;
}
.mxchat-chatbot-wrapper.mxfa-rtl .mxchat-header-menu {
    right: auto;
    left: 0;
}
.mxchat-chatbot-wrapper.mxfa-rtl .mxchat-menu-item {
    text-align: right;
}

/* Message bubbles: mirrored — visitor on the left, bot on the right. */
.mxchat-chatbot-wrapper.mxfa-rtl .user-message {
    float: left;
    text-align: right;
    border-radius: 0 18px 18px 18px;
}
.mxchat-chatbot-wrapper.mxfa-rtl .mxchat-chatbot .chat-container .chat-box .bot-message {
    float: right;
    border-radius: 18px 0 18px 18px;
}
.mxchat-chatbot-wrapper.mxfa-rtl .mxchat-chatbot .chat-container .chat-box .agent-message {
    float: right;
    text-align: right;
    border-radius: 18px 0 18px 18px;
    box-shadow: 2px 2px rgba(250, 115, 230, 0.6), 4px 4px rgba(120, 115, 245, 0.6);
}
.mxchat-chatbot-wrapper.mxfa-rtl .mxchat-chatbot .chat-container .chat-box :is(.mxchat-rating-prompt, .mxchat-rating-feedback, .mxchat-rating-saved) {
    float: right;
}
.mxchat-chatbot-wrapper.mxfa-rtl .bot-message :is(ul, ol),
.mxchat-chatbot-wrapper.mxfa-rtl .agent-message :is(ul, ol) {
    padding-left: 0;
    padding-right: 1.5em;
    margin-left: 0;
}
.mxchat-chatbot-wrapper.mxfa-rtl .bot-message blockquote {
    border-left: 0;
    border-right: 3px solid currentColor;
    padding-left: 0;
    padding-right: 0.8em;
    margin-left: 0;
}
.mxchat-chatbot-wrapper.mxfa-rtl .mxchat-table :is(td, th) {
    text-align: right;
}

/* Code, URLs and email addresses stay left-to-right inside RTL text. */
.mxchat-chatbot-wrapper.mxfa-rtl :is(pre, .mxchat-code-block-container, .mxchat-code-block) {
    direction: ltr;
    text-align: left;
}
.mxchat-chatbot-wrapper.mxfa-rtl .mxchat-inline-code {
    direction: ltr;
    unicode-bidi: isolate;
}
.mxchat-chatbot-wrapper.mxfa-rtl input[type="email"] {
    direction: ltr;
    text-align: right;
}
.mxchat-chatbot-wrapper.mxfa-rtl input[type="email"]::placeholder {
    direction: rtl;
}

/* Input row: send button on the left and pointing left. */
.mxchat-chatbot-wrapper.mxfa-rtl .mxchat-chatbot .chat-container .input-container {
    padding-right: 0;
    padding-left: 40px;
}
.mxchat-chatbot-wrapper.mxfa-rtl .mxchat-chatbot .chat-container .input-container .send-button {
    right: auto;
    left: 10px;
    transform: translateY(-50%) scaleX(-1);
}
.mxchat-chatbot-wrapper.mxfa-rtl .chat-input::placeholder {
    direction: rtl;
    text-align: right;
}

/* Toolbar and file chips. */
.mxchat-chatbot-wrapper.mxfa-rtl :is(.remove-pdf-btn, .remove-word-btn, .toolbar-perplexity) {
    margin-left: 0;
    margin-right: 4px;
}
.mxchat-chatbot-wrapper.mxfa-rtl .active-perplexity-container {
    margin-left: 0;
    margin-right: 8px;
}

/* Lead-capture form. */
.mxchat-chatbot-wrapper.mxfa-rtl .email-blocker .mxchat-consent-row {
    text-align: right;
}

/* Header logo. */
.mxchat-chatbot-wrapper .chatbot-title-icon.mxfa-brand-logo {
    height: 28px;
    width: auto;
    max-width: 96px;
    object-fit: contain;
    display: block;
}

/* Pre-chat teaser bubble. */
.pre-chat-message.mxfa-rtl {
    direction: rtl;
    text-align: right;
}
.pre-chat-message.mxfa-rtl .close-pre-chat-message {
    right: auto;
    left: -6px;
}

/* ------------------------------------------------------------------ */
/* Floating launcher                                                   */
/* ------------------------------------------------------------------ */
.floating-chatbot-button .mxfa-launcher-logo {
    width: 60%;
    height: 60%;
    max-width: 60%;
    max-height: 60%;
    object-fit: contain;
    border-radius: 0;
}

.floating-chatbot.mxfa-side-left,
.floating-chatbot-button.mxfa-side-left {
    right: auto;
    left: 25px;
}
.pre-chat-message.mxfa-side-left {
    right: auto;
    left: 30px;
}
@media (max-width: 550px) {
    /* MxChat's full-width mobile panel. */
    .floating-chatbot.mxfa-side-left {
        left: 8px;
        right: 8px;
    }
    .floating-chatbot-button.mxfa-side-left {
        left: 10px;
    }
    .pre-chat-message.mxfa-side-left {
        left: 15px;
    }
}

/* ------------------------------------------------------------------ */
/* No-RAG mode                                                         */
/* ------------------------------------------------------------------ */
/* PDF/Word questions need embeddings; the companion refuses those uploads. */
.mxfa-norag :is(.pdf-upload-btn, .word-upload-btn, .active-pdf-container, .active-word-container) {
    display: none !important;
}
