/* TI Chat Widget — scoped under #ti-chat-root */

#ti-chat-root * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Launcher bubble ─────────────────────────────────────── */
#ti-chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #074561;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  box-shadow: 0 4px 16px rgba(7,69,97,.45);
  transition: background .15s, transform .15s;
}
#ti-chat-toggle:hover  { background: #053449; transform: scale(1.05); }
#ti-chat-toggle svg    { width: 26px; height: 26px; fill: #fff; flex-shrink: 0; }
#ti-chat-toggle .ti-chat-label {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 9px;
  font-weight: 600;
  color: #fff;
  letter-spacing: .3px;
  line-height: 1;
}
#ti-chat-toggle.ti-chat-open svg.ti-icon-chat { display: none; }
#ti-chat-toggle:not(.ti-chat-open) svg.ti-icon-close { display: none; }

/* ── Chat window ─────────────────────────────────────────── */
#ti-chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 99998;
  width: 440px;
  max-height: 620px;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transition: opacity .2s, transform .2s;
}
#ti-chat-window[hidden] {
  display: none !important;
}
@media (max-width: 480px) {
  #ti-chat-window {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 88px;
    max-height: calc(100svh - 110px);
  }
}

/* ── Header ──────────────────────────────────────────────── */
.ti-chat-header {
  background: #074561;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.ti-chat-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #06A9F6;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ti-chat-header-avatar svg { width: 22px; height: 22px; fill: #fff; }
.ti-chat-header-info { flex: 1; min-width: 0; }
.ti-chat-header-title {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ti-chat-header-sub {
  color: #96DCFC;
  font-size: 11px;
  margin-top: 1px;
}
.ti-chat-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #96DCFC;
  font-size: 18px;
  line-height: 1;
  padding: 4px;
  flex-shrink: 0;
  opacity: .8;
  transition: opacity .15s;
}
.ti-chat-close:hover { opacity: 1; }

/* ── Message list ────────────────────────────────────────── */
.ti-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.ti-chat-messages::-webkit-scrollbar { width: 4px; }
.ti-chat-messages::-webkit-scrollbar-thumb { background: #d1d9e0; border-radius: 2px; }

/* Individual message bubbles */
.ti-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}
.ti-msg.ti-msg-user {
  align-self: flex-end;
  background: #074561;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ti-msg.ti-msg-bot {
  align-self: flex-start;
  background: none;
  color: #1a2733;
  max-width: 90%;
}
.ti-msg.ti-msg-error {
  align-self: flex-start;
  background: #fff3cd;
  color: #78350f;
  border: 1px solid #f59e0b;
  font-size: 13px;
}

/* Streaming cursor */
.ti-cursor {
  display: inline-block;
  width: 2px;
  height: 14px;
  background: #06A9F6;
  margin-left: 2px;
  vertical-align: middle;
  animation: ti-blink .7s step-end infinite;
}
@keyframes ti-blink { 50% { opacity: 0; } }

/* Retry link inside error bubble */
.ti-retry-btn {
  display: inline-block;
  margin-top: 6px;
  color: #074561;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  font-size: 12.5px;
}

/* Typing dots (while waiting for first token) */
.ti-typing {
  align-self: flex-start;
  background: none;
  padding: 4px 0;
  display: flex;
  gap: 4px;
  align-items: center;
}
.ti-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9aafc0;
  animation: ti-bounce 1.2s infinite;
}
.ti-typing span:nth-child(2) { animation-delay: .2s; }
.ti-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes ti-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-5px); }
}

/* ── Input row ───────────────────────────────────────────── */
.ti-chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #e8edf2;
  flex-shrink: 0;
}
#ti-chat-input {
  flex: 1;
  border: 1px solid #d1d9e0;
  border-radius: 20px;
  padding: 11px 16px;
  font-size: 14px;
  outline: none;
  color: #1a2733;
  background: #f8fafc;
  transition: border-color .15s;
  font-family: inherit;
}
#ti-chat-input:focus { border-color: #06A9F6; background: #fff; }
#ti-chat-input:disabled { opacity: .55; }
#ti-chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #06A9F6;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
#ti-chat-send:hover    { background: #0594d8; }
#ti-chat-send:disabled { background: #b0d8ed; cursor: default; }
#ti-chat-send svg      { width: 18px; height: 18px; fill: #fff; }

/* ── Disclaimer footer ───────────────────────────────────── */
.ti-chat-disclaimer {
  text-align: center;
  font-size: 10.5px;
  color: #9aafc0;
  padding: 0 12px 8px;
  flex-shrink: 0;
}
