/* ── TI CHAT WIDGET ── */
.ti-chat-widget {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 99999;
  font-family: 'Montserrat', sans-serif;
}

.ti-chat-launcher {
  width: 60px;
  height: 60px;
  background: var(--navy, #262451);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(38,36,81,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.ti-chat-launcher:hover {
  transform: scale(1.08);
}
.ti-chat-launcher svg {
  width: 32px;
  height: 32px;
}

.ti-chat-window {
  position: absolute;
  bottom: 80px;
  left: 0;
  width: 360px;
  max-width: calc(100vw - 48px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.95);
  transform-origin: bottom left;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.ti-chat-widget.open .ti-chat-window {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.ti-chat-widget.open .ti-chat-launcher {
  transform: scale(0.8);
  background: var(--red, #d31b2b);
}

/* Header */
.ti-chat-header {
  background: var(--navy, #262451);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.ti-chat-title strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
}
.ti-chat-title span {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: rgba(255,255,255,0.7);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.ti-chat-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.ti-chat-close:hover { opacity: 1; }

/* Body */
.ti-chat-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: #faf8f5;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
}
.ti-chat-body::-webkit-scrollbar { width: 6px; }
.ti-chat-body::-webkit-scrollbar-thumb { background: #ddd; border-radius: 10px; }

/* Messages */
.ti-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: popIn 0.3s ease;
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.ti-msg-content {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  color: #333;
}
.ti-msg-content p { margin-bottom: 8px; }
.ti-msg-content p:last-child { margin-bottom: 0; }
.ti-msg-content ul { margin-left: 20px; margin-bottom: 8px; }
.ti-msg-content li { margin-bottom: 4px; }

.ai-msg { align-self: flex-start; }
.ai-msg .ti-msg-content {
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  border-bottom-left-radius: 4px;
  border: 1px solid #eee;
}

.user-msg { align-self: flex-end; }
.user-msg .ti-msg-content {
  background: var(--navy, #262451);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Footer / Input */
.ti-chat-footer {
  padding: 16px;
  background: #fff;
  border-top: 1px solid #eee;
  flex-shrink: 0;
}
#tiChatForm {
  display: flex;
  align-items: center;
  background: #f5f5f5;
  border-radius: 30px;
  padding: 4px 4px 4px 16px;
}
#tiChatInput {
  flex: 1;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  color: #333;
}
#tiChatForm button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--red, #d31b2b);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}
#tiChatForm button:hover {
  background: var(--red-dark, #a81620);
}
#tiChatForm button svg {
  width: 18px;
  height: 18px;
  transform: translateX(-1px) translateY(-1px);
}

/* Typing Indicator */
.ti-typing { display: flex; gap: 4px; padding: 4px 0; }
.ti-typing span {
  width: 6px;
  height: 6px;
  background: #aaa;
  border-radius: 50%;
  animation: tiBlink 1.4s infinite both;
}
.ti-typing span:nth-child(1) { animation-delay: 0s; }
.ti-typing span:nth-child(2) { animation-delay: 0.2s; }
.ti-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes tiBlink {
  0% { opacity: 0.2; transform: translateY(0); }
  20% { opacity: 1; transform: translateY(-3px); }
  100% { opacity: 0.2; transform: translateY(0); }
}

@media(max-width:600px) {
  .ti-chat-widget { bottom: 16px; left: 16px; }
  .ti-chat-window { bottom: 70px; left: 0; width: calc(100vw - 32px); height: 80vh; }
}
