/* ==========================================================================
   Website assistant: floating chat, bottom-right on every public page
   (markup: includes/chatbot.php, behaviour: assets/js/chatbot.js)
   ========================================================================== */
.twk-chat { --c: #169ef5; --c-d: #0f86d6; --ink: #0b2a4a; --y: #ffd749;
  position: fixed; right: 18px; bottom: 18px; z-index: 990; font-family: inherit; }
.twk-chat * { box-sizing: border-box; }
.twk-chat[hidden], .twk-chat [hidden] { display: none !important; }
.twiki-menu-lock .twk-chat { display: none; }

/* launcher */
.twk-chat__launcher { position: relative; display: grid; place-items: center; width: 62px; height: 62px; padding: 0; border: 3px solid var(--c); border-radius: 50%; background: #fff; cursor: pointer;
  box-shadow: 0 14px 30px -10px rgba(22, 158, 245, .65), 0 2px 6px rgba(11, 42, 74, .15); transition: transform .25s ease, box-shadow .25s ease; }
.twk-chat__launcher::before { content: ""; position: absolute; inset: -8px; border-radius: 50%; border: 2px solid var(--c); opacity: 0; animation: twkChatPulse 2.6s ease-out infinite; }
.twk-chat__launcher:hover, .twk-chat__launcher:focus-visible { transform: translateY(-3px) scale(1.04); }
.twk-chat__launcher:focus-visible { outline: 3px solid rgba(22, 158, 245, .45); outline-offset: 3px; }
.twk-chat__launcher img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.twk-chat__x { position: absolute; display: none; color: var(--c); }
.twk-chat.is-open .twk-chat__launcher img, .twk-chat.is-open .twk-chat__launcher .twk-chat__dot { display: none; }
.twk-chat.is-open .twk-chat__x { display: block; }
.twk-chat.is-open .twk-chat__launcher::before { animation: none; }
.twk-chat__dot { position: absolute; width: 14px; height: 14px; border: 2px solid #fff; border-radius: 50%; background: #22c55e; }
.twk-chat__launcher .twk-chat__dot { right: 0; bottom: 2px; }
@keyframes twkChatPulse { 0% { opacity: .55; transform: scale(.92); } 100% { opacity: 0; transform: scale(1.35); } }

/* nudge bubble */
.twk-chat__nudge { position: absolute; right: 0; bottom: 78px; width: 230px; padding: 12px 30px 12px 14px; background: #fff; border: 1px solid #e3eaf4; border-radius: 0; color: var(--ink); font-size: 14px; line-height: 1.45;
  box-shadow: 0 18px 34px -18px rgba(11, 42, 74, .55); animation: twkChatIn .4s ease both; }
.twk-chat__nudge::after { content: ""; position: absolute; right: 22px; bottom: -7px; width: 12px; height: 12px; background: #fff; border-right: 1px solid #e3eaf4; border-bottom: 1px solid #e3eaf4; transform: rotate(45deg); }
.twk-chat__nudge-close { position: absolute; top: 4px; right: 6px; border: 0; background: none; color: #6b7280; font-size: 20px; line-height: 1; cursor: pointer; }

/* panel */
.twk-chat__panel { position: absolute; right: 0; bottom: 78px; display: flex; flex-direction: column; width: min(380px, calc(100vw - 36px)); height: min(560px, calc(100vh - 235px)); height: min(560px, calc(100dvh - 235px)); min-height: 300px;
  background: #fff; border: 1px solid #e3eaf4; border-radius: 0; overflow: hidden; box-shadow: 0 30px 60px -20px rgba(11, 42, 74, .55), 0 4px 12px rgba(11, 42, 74, .12); animation: twkChatIn .3s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes twkChatIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.twk-chat__head { display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px; background: var(--c); color: #fff; }
.twk-chat__avatar { position: relative; flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: #fff; }
.twk-chat__avatar img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.twk-chat__avatar .twk-chat__dot { right: -1px; bottom: 0; width: 13px; height: 13px; border-color: var(--c); }
.twk-chat__who { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.twk-chat__who strong { font-size: 16px; font-weight: 700; }
.twk-chat__who small { font-size: 12.5px; opacity: .92; }
.twk-chat__close { margin-left: auto; display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .18); color: #fff; cursor: pointer; transition: background-color .2s ease; }
.twk-chat__close:hover, .twk-chat__close:focus-visible { background: rgba(255, 255, 255, .32); }

.twk-chat__log { flex: 1; overflow-y: auto; padding: 16px 14px 8px; background: #f5f9fe; scroll-behavior: smooth; overscroll-behavior: contain; }
.twk-chat__msg { display: flex; margin: 0 0 10px; animation: twkChatIn .25s ease both; }
.twk-chat__msg--user { justify-content: flex-end; }
.twk-chat__bubble { max-width: 86%; padding: 10px 13px; font-size: 14.5px; line-height: 1.5; color: var(--ink); background: #fff; border: 1px solid #e3eaf4; border-radius: 4px 14px 14px 14px; white-space: pre-line; word-wrap: break-word; }
.twk-chat__msg--user .twk-chat__bubble { background: var(--c); border-color: var(--c); color: #fff; border-radius: 14px 4px 14px 14px; }
.twk-chat__links { display: flex; flex-wrap: wrap; gap: 8px; margin: -2px 0 12px; }
.twk-chat__links a { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border: 1.5px solid var(--c); background: #fff; color: var(--c); font-size: 13.5px; font-weight: 700; text-decoration: none; transition: background-color .2s ease, color .2s ease; }
.twk-chat__links a:hover, .twk-chat__links a:focus-visible { background: var(--c); color: #fff; }
.twk-chat__links a.is-wa { border-color: #25d366; color: #138a45; }
.twk-chat__links a.is-wa:hover, .twk-chat__links a.is-wa:focus-visible { background: #25d366; color: #fff; }
.twk-chat__typing { display: inline-flex; gap: 4px; padding: 13px 14px; }
.twk-chat__typing i { width: 7px; height: 7px; border-radius: 50%; background: #9db8d6; animation: twkChatDot 1s ease-in-out infinite; }
.twk-chat__typing i:nth-child(2) { animation-delay: .15s; } .twk-chat__typing i:nth-child(3) { animation-delay: .3s; }
@keyframes twkChatDot { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-5px); opacity: 1; } }

.twk-chat__chips { display: flex; gap: 8px; padding: 10px 14px; overflow-x: auto; background: #f5f9fe; border-top: 1px solid #e3eaf4; scrollbar-width: none; }
.twk-chat__chips::-webkit-scrollbar { display: none; }
.twk-chat__chips:empty { display: none; }
.twk-chat__chips button { flex: none; padding: 7px 13px; border: 1.5px solid var(--c); border-radius: 999px; background: #fff; color: var(--c-d); font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer; transition: background-color .2s ease, color .2s ease; }
.twk-chat__chips button:hover, .twk-chat__chips button:focus-visible { background: var(--c); color: #fff; }

.twk-chat__form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid #e3eaf4; background: #fff; }
.twk-chat__form input { flex: 1; min-width: 0; height: 44px; padding: 0 14px; border: 1px solid #d5dfec; border-radius: 0; background: #fff; color: var(--ink); font: inherit; font-size: 15px; }
.twk-chat__form input:focus { outline: 2px solid rgba(22, 158, 245, .45); outline-offset: 0; border-color: var(--c); }
.twk-chat__form button { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border: 0; background: var(--c); color: #fff; cursor: pointer; transition: background-color .2s ease; }
.twk-chat__form button:hover, .twk-chat__form button:focus-visible { background: var(--c-d); }
.twk-chat__foot { display: flex; justify-content: center; gap: 8px; padding: 7px 10px 10px; background: #fff; font-size: 12.5px; color: #6b7280; }
.twk-chat__foot a { color: var(--c-d); font-weight: 600; text-decoration: none; }
.twk-chat__foot a:hover { text-decoration: underline; }

@media (max-width: 575px) {
  .twk-chat { right: 12px; bottom: 12px; }
  .twk-chat__panel { position: fixed; left: 10px; right: 10px; bottom: 86px; width: auto; height: min(calc(100vh - 195px), 560px); height: min(calc(100dvh - 195px), 560px); }
  .twk-chat__nudge { width: 210px; }
}
@media (prefers-reduced-motion: reduce) {
  .twk-chat__launcher::before, .twk-chat__typing i { animation: none; }
  .twk-chat__panel, .twk-chat__msg, .twk-chat__nudge { animation: none; }
  .twk-chat__log { scroll-behavior: auto; }
}

/* ---------- Tia's 3D profile picture ---------- */
.twk-chat__launcher { width: 70px; height: 70px; perspective: 520px; overflow: visible; background: #fff;
  transform: perspective(520px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transform-style: preserve-3d; }
.twk-chat__launcher:hover, .twk-chat__launcher:focus-visible { transform: perspective(520px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(-4px) scale(1.06); }
.twk-chat__launcher img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; object-position: 50% 30%; transform: scale(1.12);
  transform-origin: 50% 60%; animation: twkChat3d 5.5s ease-in-out infinite; filter: drop-shadow(0 6px 5px rgba(11, 42, 74, .25)); will-change: transform; }
.twk-chat__launcher { border-color: var(--c); box-shadow: 0 16px 32px -10px rgba(22, 158, 245, .7), 0 2px 6px rgba(11, 42, 74, .15), inset 0 0 0 2px #fff; }
.twk-chat__launcher .twk-chat__dot { right: 1px; bottom: 3px; width: 15px; height: 15px; z-index: 2; }
@keyframes twkChat3d {
  0%, 100% { transform: scale(1.12) perspective(260px) rotateY(-16deg) rotateX(5deg) translateY(1px); }
  50%      { transform: scale(1.16) perspective(260px) rotateY(16deg) rotateX(-5deg) translateY(-3px); }
}
.twk-chat__avatar { width: 54px; height: 54px; perspective: 300px; background: #fff; box-shadow: 0 0 0 2px rgba(255, 255, 255, .55), 0 8px 14px -6px rgba(0, 0, 0, .35); }
.twk-chat__avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; object-position: 50% 30%; transform: scale(1.12); animation: twkChat3d 6.5s ease-in-out infinite; }
.twk-chat__avatar .twk-chat__dot { z-index: 2; }
.twk-chat__who strong { font-size: 16px; }

.twk-chat__msg { align-items: flex-end; gap: 8px; }
.twk-chat__mini { flex: none; width: 32px; height: 32px; border-radius: 50%; object-fit: cover; object-position: 50% 30%; background: #fff; border: 1px solid #d5e6f7; box-shadow: 0 4px 8px -4px rgba(11, 42, 74, .4); }
.twk-chat__msg--user { justify-content: flex-end; }
.twk-chat__bubble { max-width: calc(86% - 40px); }
.twk-chat__msg--user .twk-chat__bubble { max-width: 86%; }
@media (prefers-reduced-motion: reduce) {
  .twk-chat__launcher img, .twk-chat__avatar img { animation: none; }
  .twk-chat__launcher, .twk-chat__launcher:hover { transform: none; }
}

/* ---------- Taller chat window; the round button hides while the chat is open (the header has its own close button) ---------- */
.twk-chat.is-open .twk-chat__launcher { display: none; }
.twk-chat__panel { bottom: 0; height: min(680px, calc(100vh - 150px)); height: min(680px, calc(100dvh - 150px)); min-height: 340px; }
@media (max-width: 575px) {
  .twk-chat__panel { bottom: 12px; height: min(calc(100vh - 110px), 700px); height: min(calc(100dvh - 110px), 700px); }
}

/* ---------- Show Tia's whole picture (no circular crop), highlighted ---------- */
.twk-chat__launcher { width: 78px; height: 78px; border-radius: 22px; border: 3px solid var(--c); background: #fff;
  box-shadow: 0 0 0 5px rgba(22, 158, 245, .18), 0 18px 34px -10px rgba(22, 158, 245, .75), 0 3px 8px rgba(11, 42, 74, .18); }
.twk-chat__launcher::before { inset: -9px; border-radius: 28px; }
.twk-chat__launcher img { width: 100%; height: 100%; border-radius: 18px; object-fit: contain; object-position: 50% 50%; transform: none;
  animation: twkChat3dSafe 5.5s ease-in-out infinite; filter: drop-shadow(0 5px 4px rgba(11, 42, 74, .22)); }
@keyframes twkChat3dSafe {
  0%, 100% { transform: perspective(300px) rotateY(-11deg) rotateX(3deg) translateY(0); }
  50%      { transform: perspective(300px) rotateY(11deg) rotateX(-3deg) translateY(-3px); }
}
.twk-chat__launcher .twk-chat__dot { right: -5px; bottom: -5px; width: 17px; height: 17px; border-width: 3px; }
.twk-chat__avatar { width: 60px; height: 60px; border-radius: 14px; background: #fff; }
.twk-chat__avatar img { border-radius: 12px; object-fit: contain; transform: none; animation: twkChat3dSafe 6.5s ease-in-out infinite; }
.twk-chat__avatar .twk-chat__dot { right: -4px; bottom: -4px; }
.twk-chat__mini { width: 36px; height: 36px; border-radius: 10px; object-fit: contain; border: 1px solid #d5e6f7; }
.twk-chat__bubble { max-width: calc(86% - 44px); }
@media (max-width: 575px) { .twk-chat__launcher { width: 72px; height: 72px; } }
@media (prefers-reduced-motion: reduce) { .twk-chat__launcher img, .twk-chat__avatar img { animation: none; } }

/* ---------- Final: no 3D rotation (it sliced the picture). Full picture + gentle float only ---------- */
.twk-chat__launcher, .twk-chat__launcher:hover, .twk-chat__launcher:focus-visible { perspective: none; transform-style: flat; }
.twk-chat__launcher { transform: none; }
.twk-chat__launcher:hover, .twk-chat__launcher:focus-visible { transform: translateY(-3px) scale(1.05); }
.twk-chat__launcher img, .twk-chat__avatar img { transform: none; will-change: auto; animation: twkChatFloat 3.2s ease-in-out infinite; backface-visibility: visible; }
.twk-chat__avatar img { animation-duration: 4s; }
@keyframes twkChatFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .twk-chat__launcher img, .twk-chat__avatar img { animation: none; } }
