/* The UITC assistant chat window. Uses the theme colours from style.css, so it follows Light / Dark / Futuristic. */
.chat { position: fixed; right: 20px; bottom: 20px; z-index: 60; font-size: .9rem; }
.chat-fab { position: relative; width: 56px; height: 56px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .18); background: var(--btn); color: #fff;
  display: grid; place-items: center; cursor: pointer; box-shadow: 0 10px 25px -8px rgba(127, 29, 29, .7); transition: transform .2s, box-shadow .2s; }
.chat-fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 14px 30px -8px rgba(127, 29, 29, .85); }
/* the button is the UITC Assistant picture itself (a round robot on green) */
.chat-fab { width: 64px; height: 64px; padding: 0; background: #fff; border: 2px solid #fff; box-shadow: 0 10px 25px -8px rgba(6, 78, 59, .65); overflow: visible; }
.chat-fab:hover { box-shadow: 0 14px 30px -8px rgba(6, 78, 59, .8); }
.chat-fab .chat-badge { right: 0; top: 0; }
.chat-fab:focus-visible, .chat-icon-btn:focus-visible, .chat-chips button:focus-visible, .chat-retry:focus-visible { outline: 2px solid #fbbf24; outline-offset: 2px; }
.chat.is-open .chat-fab { display: none; }

.chat-badge { position: absolute; right: 2px; top: 2px; width: 13px; height: 13px; border-radius: 50%; background: #22c55e; border: 2px solid var(--surface); }
.chat-badge.is-inline { position: static; display: inline-block; width: 8px; height: 8px; border: 0; margin-right: 6px; vertical-align: 1px; }
.chat.is-offline .chat-badge { background: #94a3b8; }

.chat-win { display: none; flex-direction: column; width: 380px; max-width: calc(100vw - 24px); height: min(580px, calc(100vh - 40px));
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 1.1rem; overflow: hidden;
  box-shadow: 0 24px 60px -16px rgba(15, 23, 42, .45); }
.chat-win.is-open { display: flex; animation: chat-in .22s ease-out; }
@keyframes chat-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; background: linear-gradient(135deg, var(--btn), #5b0f0f); color: #fff; }
.chat-avatar { width: 52px; height: 52px; border-radius: 50%; background: #fff; border: 2px solid rgba(255, 255, 255, .85); display: grid; place-items: center; overflow: hidden; flex: none; }
.chat-title { display: grid; line-height: 1.2; min-width: 0; flex: 1; }
.chat-title strong { font-size: .95rem; }
.chat-title small { font-size: .72rem; opacity: .9; }
.chat-icon-btn { background: rgba(255, 255, 255, .12); border: 0; color: #fff; width: 32px; height: 32px; border-radius: 10px; font-size: 1.15rem; line-height: 1; cursor: pointer; }
.chat-icon-btn:hover { background: rgba(255, 255, 255, .25); }

.chat-msgs { flex: 1; overflow-y: auto; padding: 14px; display: grid; gap: 10px; align-content: start; background: var(--surface-2); overscroll-behavior: contain; }
.chat-row { display: flex; }
.chat-user { justify-content: flex-end; }
.chat-bubble { max-width: 88%; padding: 9px 13px; border-radius: 14px; overflow-wrap: anywhere; line-height: 1.5; }
.chat-bubble p { margin: 0 0 6px; }
.chat-bubble > :last-child { margin-bottom: 0; }
.chat-bubble ul, .chat-bubble ol { margin: 4px 0 6px; padding-left: 20px; }
.chat-bubble li { margin: 2px 0; }
.chat-bubble code { background: var(--border-soft); border-radius: 4px; padding: 0 4px; font-size: .88em; }
.chat-bot .chat-bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-user .chat-bubble { background: var(--btn); color: #fff; border-bottom-right-radius: 4px; }
.chat-bot .chat-bubble a { font-weight: 700; text-decoration: underline; }
.chat-retry { margin-top: 6px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: var(--text); padding: 3px 12px; font: inherit; font-size: .75rem; font-weight: 700; cursor: pointer; }
.chat-retry:hover { border-color: var(--maroon); }
.chat-typing { display: inline-flex; gap: 4px; padding: 3px 2px; }
.chat-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: chat-dot 1.1s infinite ease-in-out; }
.chat-typing i:nth-child(2) { animation-delay: .15s; }
.chat-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes chat-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.chat-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.chat-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; background: var(--surface-2); }
.chat-chips[hidden] { display: none; }
.chat-chips button { border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); padding: 5px 12px; font: inherit; font-size: .78rem; font-weight: 600; cursor: pointer; transition: border-color .2s, background-color .2s; }
.chat-chips button:hover { border-color: var(--maroon); background: var(--hover); }

.chat-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--surface); }
.chat-form input { flex: 1; min-width: 0; }
.chat-form .btn { padding: 9px 16px; }
.chat-idgate { padding: 12px 14px; border-top: 1px solid var(--border); background: var(--surface); display: grid; gap: 8px; }
.chat-idgate[hidden] { display: none; }
.chat-idgate label { font-size: .82rem; line-height: 1.45; }
.chat-idrow { display: flex; gap: 8px; }
.chat-idrow input { flex: 1; min-width: 0; }
.chat-idrow .btn { padding: 9px 14px; }
.chat-iderr { margin: 0; color: #b91c1c; font-size: .75rem; font-weight: 600; }
html.dark .chat-iderr { color: #fca5a5; }
.chat-form[hidden] { display: none; }
.chat-foot .mono { font-size: .95em; }
.chat-foot { margin: 0; padding: 0 14px 10px; background: var(--surface); color: var(--faint); font-size: .68rem; line-height: 1.4; }
.chat-foot a { text-decoration: underline; }

@media (max-width: 640px) {
  .chat { right: 12px; bottom: 12px; }
  .chat-win { position: fixed; right: 8px; bottom: 8px; width: auto; left: 8px; max-width: none; height: min(78vh, 600px); }
  .chat-fab { width: 52px; height: 52px; }
}
@media (prefers-reduced-motion: reduce) { .chat-win.is-open, .chat-typing i { animation: none; } .chat-fab { transition: none; } }
@media print { .chat { display: none; } }

/* Admin > Chatbot: the knowledge text editor */
.kb-text { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .8rem; line-height: 1.55; white-space: pre-wrap; min-height: 26rem; }

/* Futuristic theme */
html.fx .chat-win { background: rgba(10, 15, 34, .96); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-color: var(--border);
  box-shadow: 0 0 0 1px rgba(251, 191, 36, .18), 0 24px 60px -16px rgba(0, 0, 0, .9), 0 0 50px -20px var(--crimson-glow); }
html.fx .chat-head { background: linear-gradient(135deg, #8f1422, #3a0a12); border-bottom: 1px solid rgba(251, 191, 36, .35); font-family: var(--fx-display); }
html.fx .chat-fab { background: linear-gradient(135deg, #d12a3a, #8f1422); border-color: rgba(255, 120, 135, .45); box-shadow: 0 0 28px -4px var(--crimson-glow); }
html.fx .chat-fab:hover { box-shadow: 0 0 36px -2px rgba(224, 54, 74, .9); }
html.fx .chat-user .chat-bubble { background: linear-gradient(135deg, #d12a3a, #8f1422); }
html.fx .chat-bot .chat-bubble { background: var(--surface); }
html.fx .chat-form input:focus { border-color: var(--gold); }

/* ---- the animated robot face = the green Wi-Fi mascot (markup in _chatbot.html, the head and the eyes follow the pointer in static/js/chatface.js) ---- */
.bot-face { display: block; width: 100%; height: 100%; border-radius: 50%; --ex: 0px; --ey: 0px; --hx: 0px; --hy: 0px; --hr: 0deg; }
.bot-face .bf-all { animation: bf-bob 3.5s ease-in-out infinite; }
.bot-face .bf-wifi { transform-box: fill-box; transform-origin: center; animation: bf-wifi 1.8s ease-in-out infinite; }
.bot-face .bf-arm { transform-box: view-box; transform-origin: 230px 225px; animation: bf-wave 3.6s ease-in-out infinite; }
.bot-face .bf-head { transform-box: view-box; transform-origin: 160px 150px; transform: translate(var(--hx), var(--hy)) rotate(var(--hr)); transition: transform .14s ease-out; }
.bot-face .bf-arcs { transform-box: fill-box; transform-origin: center; animation: bf-blink 5.2s infinite; transition: opacity .15s; }
.bot-face .bf-pupils { opacity: 0; transition: opacity .15s; }
.bot-face .bf-look { transform: translate(var(--ex), var(--ey)); transition: transform .1s ease-out; }
.bot-face .bf-tip, .bot-face .bf-core { animation: bf-glow 2.2s ease-in-out infinite alternate; }
.bot-face .bf-bars, .bot-face .bf-dots { opacity: 0; }
.bot-face .bf-bars rect { transform-box: fill-box; transform-origin: center; }
.bot-face .bf-dots circle { animation: bf-dot 1s ease-in-out infinite; }
.bot-face .bf-dots circle:nth-child(2) { animation-delay: .15s; } .bot-face .bf-dots circle:nth-child(3) { animation-delay: .3s; }
/* the pointer is near: the eyes look at it (the happy arcs give way to the pupils) */
.bot-face.is-near .bf-arcs { opacity: 0; }
.bot-face.is-near .bf-pupils { opacity: 1; }
.chat-fab:hover .bf-arm { animation: bf-wave .7s ease-in-out 2; }
/* waiting for the answer: eyes look up, three dots instead of the smile */
.chat.is-thinking .bf-arcs { opacity: 0; }
.chat.is-thinking .bf-pupils { opacity: 1; }
.chat.is-thinking .bf-look { transform: translate(-4px, -6px); }
.chat.is-thinking .bf-smile { opacity: 0; }
.chat.is-thinking .bf-dots { opacity: 1; }
.chat.is-thinking .bf-wifi { animation-duration: .7s; }
/* the answer arrived: the mouth moves for a moment and the robot waves */
.chat.is-talking .bf-smile { opacity: 0; }
.chat.is-talking .bf-bars { opacity: 1; }
.chat.is-talking .bf-bars rect { animation: bf-talk .42s ease-in-out infinite; }
.chat.is-talking .bf-bars rect:nth-child(2) { animation-delay: .1s; } .chat.is-talking .bf-bars rect:nth-child(3) { animation-delay: .2s; } .chat.is-talking .bf-bars rect:nth-child(4) { animation-delay: .06s; }
.chat.is-talking .bf-bars rect:nth-child(5) { animation-delay: .14s; } .chat.is-talking .bf-bars rect:nth-child(6) { animation-delay: .24s; }
.chat.is-talking .bf-arm { animation: bf-wave .75s ease-in-out 3; }
@keyframes bf-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes bf-wifi { 0%, 100% { opacity: .45; transform: scale(.96); } 50% { opacity: 1; transform: scale(1.08); } }
@keyframes bf-blink { 0%, 90%, 100% { transform: scaleY(1); } 94% { transform: scaleY(.1); } }
@keyframes bf-glow { from { filter: brightness(1); } to { filter: brightness(1.35); } }
@keyframes bf-talk { 0%, 100% { transform: scaleY(.35); } 50% { transform: scaleY(1.3); } }
@keyframes bf-dot { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
@keyframes bf-wave { 0%, 40%, 100% { transform: rotate(0); } 8% { transform: rotate(-18deg); } 16% { transform: rotate(12deg); } 24% { transform: rotate(-18deg); } 32% { transform: rotate(8deg); } }
/* "Reduce motion" (often switched on by Windows when its animation effects are off): the robot still follows the pointer and thinks / talks, which is feedback, but the endless bobbing, waving and pulsing stop. */
@media (prefers-reduced-motion: reduce) { .bot-face .bf-all, .bot-face .bf-wifi, .bot-face .bf-arm, .bot-face .bf-tip, .bot-face .bf-core { animation: none !important; } }