/* OneStaff v5 "Flow" - the assistant bubble + the team-chat widget.
   Printed by head.php right after onestaff-flow-widgets.css, so it wins over app.all.css and the
   chat rules in onestaff-flow.css. Reads the Flow tokens (works in light + dark); the bubble's own
   blue (--bot-*) also tints the chat accents.

   1. .os-bot / .init-chat-icon : a glowing blue speech bubble with two pill eyes.
        ::before = the bubble (SVG, --bot-img)   -> shifts a little toward the pointer
        ::after  = the eyes (one pill + a copy via box-shadow) -> shift more, and blink
      assets/js/onestaff-orb.js writes --ex / --ey (-1..1 = direction to the cursor).
      Sizes are in em = the bubble's own width: set `font-size` to the same value as width/height.
      Markup: <span class="os-bot"></span>
   2. The chat box opened by the launcher (messages/chat/*.php): header + tabs, conversation list,
      bubbles, composer. */

:root {
    --bot-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-12 -12 524 515'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0.1' y1='0' x2='0.9' y2='1'%3E%3Cstop offset='0' stop-color='%232680ff'/%3E%3Cstop offset='.55' stop-color='%233a98ff'/%3E%3Cstop offset='1' stop-color='%2362b8ff'/%3E%3C/linearGradient%3E%3CclipPath id='c'%3E%3Cpath d='M175 0H325C435 0 499 75 499 200V235C499 310 468 372 420 405V491L282 438H205C70 438 0 360 0 235V200C0 75 65 0 175 0Z'/%3E%3C/clipPath%3E%3Cfilter id='b' x='-20%25' y='-20%25' width='140%25' height='140%25'%3E%3CfeGaussianBlur stdDeviation='9'/%3E%3C/filter%3E%3C/defs%3E%3Cpath d='M175 0H325C435 0 499 75 499 200V235C499 310 468 372 420 405V491L282 438H205C70 438 0 360 0 235V200C0 75 65 0 175 0Z' fill='url(%23g)'/%3E%3Cg clip-path='url(%23c)'%3E%3Cpath d='M175 0H325C435 0 499 75 499 200V235C499 310 468 372 420 405V491L282 438H205C70 438 0 360 0 235V200C0 75 65 0 175 0Z' fill='none' stroke='%23cfe6ff' stroke-opacity='.75' stroke-width='26' filter='url(%23b)'/%3E%3C/g%3E%3C/svg%3E");
    --bot-blue: #2b86ff;
    --bot-sky: #5ab4ff;
    --bot-glow: rgba(43, 134, 255, 0.55);
    --bot-grad-soft: linear-gradient(135deg, #2680ff 0%, #4aa8ff 100%);   /* bubbles + send buttons */
}

/* ================= 1. the bubble ================= */

.os-bot,
.init-chat-icon {
    filter: drop-shadow(0 0.03em 0.05em rgba(10, 40, 100, 0.35)) drop-shadow(0 0 0.1em var(--bot-glow));
}
/* (.init-chat-icon is already position: fixed, which also anchors its pseudo-elements) */
.os-bot { position: relative; display: block; width: 100%; height: 100%; }

/* the bubble itself */
.os-bot::before,
.init-chat-icon::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--bot-img) center / contain no-repeat;
    transform: translate(calc(var(--ex, 0) * 0.015em), calc(var(--ey, 0) * 0.012em));
    transition: transform 140ms ease-out;
    pointer-events: none;
}
/* eyes: one pill + a copy shifted right through box-shadow (so a single element blinks both) */
.os-bot::after,
.init-chat-icon::after {
    content: "";
    position: absolute;
    left: 24.2%;
    top: 27.7%;
    width: 15.6%;
    height: 36.2%;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0.358em 0 0 0 #fff;
    transform: translate(calc(var(--ex, 0) * 0.05em), calc(var(--ey, 0) * 0.04em));
    transition: transform 110ms ease-out;
    animation: os-bot-blink 5.5s infinite;
    pointer-events: none;
}
@keyframes os-bot-blink { 0%, 92%, 100% { scale: 1 1; } 95% { scale: 1 0.08; } }

/* the team-chat launcher: the same bubble drawn on the existing element */
.init-chat-icon {
    width: 52px !important;
    height: 52px !important;
    font-size: 52px;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: none !important;      /* beats onestaff-ui.css's gradient */
    box-shadow: none !important;
    color: var(--os-text, #151515) !important;
    cursor: pointer;
    z-index: 1042;
    transition: transform 180ms ease, opacity 160ms ease;
    animation: os-bot-float 4.5s ease-in-out infinite;
}
@keyframes os-bot-float { 0%, 100% { translate: 0 0; } 50% { translate: 0 -4px; } }
.init-chat-icon:hover { transform: scale(1.07); }
.init-chat-icon:active { transform: scale(0.95); }
.init-chat-icon.has-message { background: none !important; color: var(--os-text, #151515) !important; }
.init-chat-icon svg, .init-chat-icon .icon { stroke: currentColor !important; }

/* what the launcher's inner span holds: nothing (closed) / a close badge (open) / the unread count */
.init-chat-icon .chat-min-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}
.init-chat-icon .chat-min-icon[data-type="open"] { display: none; }
.init-chat-icon .chat-min-icon[data-type="close"],
.init-chat-icon .chat-min-icon[data-type="unread"] {
    inset: auto;
    right: -4px;
    border-radius: 999px;
    box-shadow: 0 0 0 2px var(--os-base, #eee);
}
.init-chat-icon .chat-min-icon[data-type="close"] {
    top: -4px;
    width: 24px;
    height: 24px;
    background: var(--os-ink, #161616);
    color: var(--os-on-ink, #fff);
}
.init-chat-icon .chat-min-icon[data-type="close"] .chat-close { font-size: 19px; line-height: 1; font-weight: 400; }
.init-chat-icon .chat-min-icon[data-type="unread"] {
    top: -4px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    background: var(--os-coral, #e8673f);
    color: #fff;
    font: 700 11px/1 var(--os-font, inherit);
}

@media (prefers-reduced-motion: reduce) {
    .init-chat-icon, .os-bot::after, .init-chat-icon::after { animation: none; }
    .os-bot::before, .init-chat-icon::before, .os-bot::after, .init-chat-icon::after { transition: none; }
}

/* ================= 2. the chat box ================= */

.rise-chat-wrapper {
    display: flex;
    flex-direction: column;
    background: var(--os-surface-3, #fff) !important;
    border: 1px solid var(--os-line-2, rgba(0, 0, 0, 0.11)) !important;
    border-radius: 18px !important;
    box-shadow: var(--os-shadow-lg) !important;
    overflow: hidden;
    z-index: 1041;
    font-family: var(--os-font, inherit);
    color: var(--os-text-2, #3a3a3a);
    transform-origin: bottom right;
    animation: os-chat-pop 200ms ease both;
}
@keyframes os-chat-pop { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: none; } }
@media (min-width: 768px) {
    .rise-chat-wrapper {
        width: 372px;
        height: min(580px, calc(100vh - 40px));
        right: 84px;
        bottom: 20px;
    }
}
/* the black bottom bar (<=990px, see onestaff-flow.css) already lifts the box by 84px */
@media (min-width: 768px) and (max-width: 990px) {
    .rise-chat-wrapper { height: min(580px, calc(100vh - 124px)); }
}
@media (prefers-reduced-motion: reduce) { .rise-chat-wrapper { animation: none; } }

/* header (conversation list: title row + tabs; open conversation: back + name) */
.rise-chat-header {
    display: block !important;
    flex: 0 0 auto;
    padding: 12px 12px 10px 14px;
    background: linear-gradient(180deg, rgba(43, 134, 255, 0.09), rgba(43, 134, 255, 0) 100%);
    border-bottom: 1px solid var(--os-line, rgba(0, 0, 0, 0.07));
    box-shadow: none !important;
}
.rise-chat-header .box-content { display: block; padding: 0; }
.chat-head-row { display: flex; align-items: center; gap: 11px; }
.chat-head-orb { flex: 0 0 auto; width: 40px; height: 40px; font-size: 40px; display: block; }
.chat-head-text { flex: 1 1 auto; min-width: 0; }
.chat-head-name { font: 600 14px/1.25 var(--os-font-display, inherit); letter-spacing: -0.01em; color: var(--os-text, #151515); }
.chat-head-sub { margin-top: 2px; font-size: 11.5px; line-height: 1.2; color: var(--os-muted, #727272); }
.chat-head-btn {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--os-muted, #727272);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease;
}
.chat-head-btn:hover { background: var(--os-wash-2); color: var(--os-text, #151515); }

/* tabs = segmented switch */
.chat-tab.nav-tabs {
    display: flex !important;
    gap: 4px;
    margin: 12px 0 0 !important;
    padding: 3px !important;
    background: var(--os-wash, rgba(17, 17, 17, 0.035)) !important;
    border: 0 !important;
    border-radius: 12px;
}
.chat-tab.nav-tabs > li { display: block !important; flex: 1 1 0; width: auto !important; float: none; margin: 0; padding: 0; }
.chat-tab.nav-tabs > li > a {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 8px !important;
    border: 0 !important;
    border-radius: 9px !important;
    background: transparent !important;
    color: var(--os-muted, #727272) !important;
    font: 600 12px/1 var(--os-font, inherit);
    transition: background 140ms ease, color 140ms ease;
}
.chat-tab.nav-tabs > li > a:hover { color: var(--os-text, #151515) !important; }
.chat-tab.nav-tabs > li > a.active { background: var(--os-ink, #161616) !important; color: var(--os-on-ink, #fff) !important; }
.chat-tab.nav-tabs > li > a.active svg { stroke: var(--os-on-ink, #fff); }
.chat-tab .icon-16, .chat-tab .icon-18 { width: 14px; height: 14px; }

/* open conversation header */
.rise-chat-header:has(.chat-back) { display: flex !important; align-items: center; gap: 8px; padding: 10px 14px 10px 8px; cursor: grab; }
.chat-back {
    flex: 0 0 auto;
    width: 32px !important;
    height: 32px;
    padding: 0 !important;
    opacity: 1 !important;
    border-radius: 9px;
    color: var(--os-muted, #727272);
    display: flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.chat-back:hover { background: var(--os-wash-2); color: var(--os-text, #151515); }
.chat-title { flex: 1 1 auto; min-width: 0; text-indent: 0 !important; text-align: left !important; padding: 0 !important; font: 600 14px/1.3 var(--os-font-display, inherit) !important; color: var(--os-text, #151515); }
.chat-title .online { position: static; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--os-green, #1db57a); vertical-align: 1px; }

/* body */
.rise-chat-body {
    flex: 1 1 auto;
    height: auto !important;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    user-select: text;
}
.rise-chat-body:not(.long) { background: var(--os-surface-2, #f2f2f2); padding: 10px 0; }
.rise-chat-body::-webkit-scrollbar { width: 8px; }
.rise-chat-body::-webkit-scrollbar-thumb { background: var(--os-line-2); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }

/* conversation list */
.rise-chat-wrapper .message-row {
    padding: 12px 14px;
    border-bottom: 1px solid var(--os-line, rgba(0, 0, 0, 0.07)) !important;
    border-radius: 0 !important;
    cursor: pointer;
    transition: background 120ms ease;
}
.rise-chat-wrapper .message-row:hover { background: var(--os-wash, rgba(17, 17, 17, 0.035)) !important; }
.rise-chat-wrapper .message-row strong { color: var(--os-text, #151515); font-weight: 600; font-size: 13px; }
.rise-chat-wrapper .message-row .time { font-size: 11px; width: auto; color: var(--os-faint, #a2a2a2) !important; }
.rise-chat-wrapper .message-row.unread { box-shadow: inset 3px 0 0 var(--bot-blue, #2b86ff); }
.rise-chat-wrapper .message-row.unread strong { font-weight: 700; }
.rise-chat-wrapper .message-row .avatar { width: 34px; height: 34px; }
.rise-chat-wrapper .message-row .avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.rise-chat-wrapper .message-row small { font-size: 12px; color: var(--os-muted, #727272); }
.chat-no-messages { padding: 64px 28px; color: var(--os-muted, #727272) !important; font-size: 13px; line-height: 1.5; }
.chat-no-messages svg { color: var(--os-faint, #a2a2a2); margin-bottom: 10px; }

/* bubbles */
.chat-me, .chat-other { padding: 3px 14px !important; background: transparent !important; border-radius: 0 !important; margin: 0 !important; }
.chat-msg { max-width: 78%; padding: 8px 12px !important; font-size: 13px; line-height: 1.5; }
.chat-me { text-align: right; }
.chat-me .chat-msg {
    background: var(--bot-grad-soft, #3a6bff) !important;
    color: #fff !important;
    border-radius: 16px 16px 4px 16px !important;
}
.chat-me .chat-msg a { color: inherit !important; text-decoration: underline; }
.chat-other .avatar { float: left; margin-right: 8px; width: 28px; height: 28px; }
.chat-other .avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.chat-other .chat-msg {
    max-width: calc(100% - 44px);
    background: var(--os-surface-3, #fff) !important;
    border: 1px solid var(--os-line, rgba(0, 0, 0, 0.07));
    color: var(--os-text-2, #3a3a3a);
    border-radius: 16px 16px 16px 4px !important;
}

/* composer */
.rise-chat-footer {
    flex: 0 0 auto;
    padding: 10px 12px 12px;
    background: var(--os-surface-3, #fff) !important;
    border-top: 1px solid var(--os-line, rgba(0, 0, 0, 0.07)) !important;
}
#chat-message-reply-form { position: relative; }
.rise-chat-footer textarea {
    display: block;
    width: 100%;
    height: 46px;
    min-height: 46px;
    max-height: 110px;
    padding: 13px 48px 13px 42px !important;
    background: var(--os-surface-2, #f2f2f2);
    border: 1px solid var(--os-line-2, rgba(0, 0, 0, 0.11)) !important;
    border-radius: 14px;
    color: var(--os-text, #151515);
    font: 13px/1.4 var(--os-font, inherit);
    resize: none;
    transition: border-color 140ms ease, box-shadow 140ms ease;
}
.rise-chat-footer textarea::placeholder { color: var(--os-faint, #a2a2a2); }
.rise-chat-footer textarea:focus { border-color: var(--bot-blue, #2b86ff) !important; box-shadow: 0 0 0 3px rgba(43, 134, 255, 0.18); outline: none; }
.chat-file-upload-icon { left: 6px; bottom: 8px; width: 32px; padding: 0; color: var(--os-muted, #727272); }
.message-send-button {
    position: absolute;
    right: 6px;
    bottom: 6px;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--bot-grad-soft, #3a6bff);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 140ms ease;
}
.message-send-button:hover { transform: translateY(-1px); }
.message-send-button svg { stroke: #fff; }
