/*
 * Kinan AI (was "R8 AI") chat window. Plain CSS syntax. Physical sides (left/right) on purpose:
 * Odoo's rtlcss mirrors them for Arabic, so the launcher sits bottom-left in
 * English and bottom-right in Arabic, opposite the live-chat bubble.
 */
.r8ai-root {
    --r8ai-navy: #1f4e8c;
    --r8ai-navy-dark: #13233f;
    --r8ai-orange: #f08a24;
    --r8ai-text: #13233f;
    --r8ai-muted: #5f6b7e;
    --r8ai-line: #d9e1ec;
    --r8ai-soft: #f3f6fa;
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 1050;
    font-size: 14px;
    line-height: 1.5;
}
html[lang^="ar"] .r8ai-root,
html[lang^="ar"] .r8ai-root * {
    font-family: "Tajawal", "Segoe UI", system-ui, sans-serif;
    letter-spacing: 0;
}
/* Above the sticky buy bar on product pages (role8_shop_ui) */
body.r8ui-has-buybar .r8ai-root {
    bottom: 92px;
}

.r8ai-launcher {
    /* Kinan's picture in a circle, no text (owner) */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    padding: 0;
    border: 3px solid #fff;
    border-radius: 50%;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 10px 26px rgba(19, 35, 63, 0.28);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.r8ai-launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(19, 35, 63, 0.34);
}
.r8ai-launcher img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}
.r8ai-root--open .r8ai-launcher {
    display: none;
}

.r8ai-panel {
    display: flex;
    flex-direction: column;
    width: 380px;
    /* not min(): Odoo's libsass treats it as the Sass function and fails */
    height: 620px;
    max-height: calc(100vh - 40px);
    overflow: hidden;
    border: 1px solid var(--r8ai-line);
    border-radius: 20px;
    background: #fff;
    color: var(--r8ai-text);
    box-shadow: 0 24px 60px rgba(19, 35, 63, 0.25);
}
.r8ai-panel[hidden] {
    display: none;
}
.r8ai-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px 12px 14px;
    background: linear-gradient(135deg, var(--r8ai-navy-dark), var(--r8ai-navy));
    color: #fff;
}
.r8ai-head img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}
.r8ai-head__title {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
}
.r8ai-head__title strong {
    font-size: 1rem;
}
.r8ai-head__title small {
    opacity: 0.8;
    font-size: 0.75rem;
}
.r8ai-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}
.r8ai-icon:hover {
    background: rgba(255, 255, 255, 0.22);
}

.r8ai-log {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding: 14px;
    background: var(--r8ai-soft);
}
.r8ai-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 92%;
}
.r8ai-msg img {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
}
.r8ai-msg--user {
    align-self: flex-end;
}
.r8ai-bubble {
    min-width: 0;
    padding: 9px 12px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid var(--r8ai-line);
    overflow-wrap: anywhere;
}
.r8ai-msg--ai .r8ai-bubble {
    border-bottom-left-radius: 4px;
}
.r8ai-msg--user .r8ai-bubble {
    border: 0;
    border-bottom-right-radius: 4px;
    background: var(--r8ai-navy);
    color: #fff;
}
.r8ai-bubble p {
    margin: 0 0 6px;
}
.r8ai-bubble p:last-child,
.r8ai-bubble ul:last-child,
.r8ai-bubble ol:last-child {
    margin-bottom: 0;
}
.r8ai-bubble ul,
.r8ai-bubble ol {
    margin: 0 0 6px;
    /* logical side, so bullets sit correctly in both Arabic and English bubbles */
    padding: 0;
    padding-inline-start: 18px;
}
.r8ai-bubble a.r8ai-link {
    color: var(--r8ai-navy);
    font-weight: 700;
    text-decoration: underline;
    text-decoration-color: var(--r8ai-orange);
    text-underline-offset: 3px;
}
.r8ai-bubble a.r8ai-link:hover {
    color: var(--r8ai-orange);
}
.r8ai-bubble a.r8ai-link::after {
    content: " \2197";
    font-weight: 400;
    text-decoration: none;
}
/* Arabic message on an English page (or the Arabic site) */
.r8ai-bubble--ar,
.r8ai-bubble--ar * {
    font-family: "Tajawal", "Segoe UI", system-ui, sans-serif;
    letter-spacing: 0;
}
.r8ai-notice {
    align-self: center;
    padding: 6px 12px;
    border-radius: 999px;
    background: #e3f4ea;
    color: #1f7a4c;
    font-size: 0.82rem;
    font-weight: 600;
    text-align: center;
}
.r8ai-typing .r8ai-bubble {
    display: inline-flex;
    gap: 4px;
    padding: 12px 14px;
}
.r8ai-typing .r8ai-bubble span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--r8ai-muted);
    animation: r8ai-dot 1.2s infinite ease-in-out;
}
.r8ai-typing .r8ai-bubble span:nth-child(2) {
    animation-delay: 0.15s;
}
.r8ai-typing .r8ai-bubble span:nth-child(3) {
    animation-delay: 0.3s;
}
@keyframes r8ai-dot {
    0%,
    80%,
    100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

.r8ai-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 14px;
    background: var(--r8ai-soft);
}
.r8ai-chips:not(:empty) {
    padding-bottom: 10px;
}
.r8ai-chip {
    padding: 6px 12px;
    border: 1px solid var(--r8ai-line);
    border-radius: 999px;
    background: #fff;
    color: var(--r8ai-navy);
    font-size: 0.82rem;
    font-weight: 600;
}
.r8ai-chip:hover {
    border-color: var(--r8ai-orange);
}

.r8ai-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--r8ai-line);
    background: #fff;
}
.r8ai-form textarea {
    flex: 1 1 auto;
    min-height: 40px;
    max-height: 120px;
    padding: 9px 12px;
    border: 1px solid var(--r8ai-line);
    border-radius: 12px;
    resize: none;
    font-family: inherit;
    font-size: 16px; /* no zoom on iPhone */
    line-height: 1.4;
}
.r8ai-form textarea:focus {
    outline: none;
    border-color: var(--r8ai-navy);
}
.r8ai-send {
    flex: 0 0 40px;
    height: 40px;
    border: 0;
    border-radius: 12px;
    background: var(--r8ai-orange);
    color: #fff;
}
.r8ai-send:disabled {
    opacity: 0.5;
}
.r8ai-note {
    margin: 0;
    padding: 0 12px 10px;
    background: #fff;
    color: var(--r8ai-muted);
    font-size: 0.72rem;
    text-align: center;
}

@media (max-width: 575.98px) {
    .r8ai-root {
        left: 12px;
        bottom: 12px;
    }
    .r8ai-launcher {
        width: 56px;
        height: 56px;
    }
    .r8ai-root--open {
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
    }
    .r8ai-root--open .r8ai-panel {
        width: 100%;
        height: 100%;
        max-height: none;
        border: 0;
        border-radius: 0;
    }
    body.r8ai-chat-open .o-livechat-root {
        display: none !important;
    }
}
@media print {
    .r8ai-root {
        display: none !important;
    }
}
@media (prefers-reduced-motion: reduce) {
    .r8ai-typing .r8ai-bubble span {
        animation: none;
    }
}

/* owner 2026-10-27: colleagues in the same window - Asia (Subra) and Sanad (Najeed) */
.r8ai-root--asia .r8ai-head {
    background: linear-gradient(135deg, #2e3b47, #4f6b66);
}
.r8ai-root--sanad .r8ai-head {
    background: linear-gradient(135deg, #0a2b2c, #0f3d3e);
}
.r8ai-join {
    align-self: center;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--r8ai-soft);
    color: var(--r8ai-muted-text, #5b6675);
    font-size: 0.78rem;
    font-weight: 600;
    text-align: center;
}
