/* Tend AI chat widget — shared across pages that include js/chat.js */

#tc-fab {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--color-primary); color: #fff;
  box-shadow: 0 4px 16px rgba(212,65,111,.45);
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, transform .15s;
}
#tc-fab:hover { background: var(--color-primary-dark); transform: scale(1.07); }
#tc-fab svg { width: 24px; height: 24px; }

#tc-panel {
  position: fixed; bottom: 92px; right: 24px; z-index: 9998;
  width: 360px; max-width: calc(100vw - 32px);
  height: 500px; max-height: calc(100vh - 110px);
  background: #fff; border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,.16);
  display: flex; flex-direction: column; overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
#tc-panel[hidden] { display: none; }

/* ── greeting bubble (proactive, appears before the panel is opened) ── */
#tc-greeting {
  position: fixed; bottom: 92px; right: 24px; z-index: 9997;
  max-width: 260px; background: #fff; color: var(--color-text);
  border-radius: 16px; border-bottom-right-radius: 4px;
  padding: 14px 16px; box-shadow: 0 8px 24px rgba(0,0,0,.16);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px; line-height: 1.5;
  display: flex; align-items: flex-start; gap: 8px;
  cursor: pointer;
  animation: tc-greeting-in .25s ease-out;
}
#tc-greeting[hidden] { display: none; }
#tc-greeting span.tc-greeting-text { flex: 1; }
#tc-greeting .tc-greeting-close {
  background: none; border: none; cursor: pointer; color: var(--color-text-muted);
  padding: 0; line-height: 1; flex-shrink: 0; font-size: 16px;
}
@keyframes tc-greeting-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── shared header ── */
.tc-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--color-primary); color: #fff;
  flex-shrink: 0;
}
.tc-header-left { display: flex; align-items: center; gap: 10px; }
#tc-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,.2); display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; color: #fff;
}
.tc-header-title { font-weight: 700; font-size: 15px; line-height: 1.2; }
.tc-header-sub   { font-size: 11px; opacity: .8; }
.tc-header-actions { display: flex; align-items: center; gap: 4px; }
.tc-hbtn {
  background: none; border: none; color: #fff; cursor: pointer;
  font-size: 18px; line-height: 1; padding: 6px; opacity: .8;
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  transition: opacity .15s, background .15s;
}
.tc-hbtn:hover { opacity: 1; background: rgba(255,255,255,.15); }

/* ── list view ── */
#tc-list-view { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
#tc-list-body {
  flex: 1; overflow-y: auto; background: var(--color-bg-soft);
}
.tc-convo-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--color-border);
  cursor: pointer; background: #fff; transition: background .15s;
}
.tc-convo-item:hover { background: var(--color-bg-soft); }
.tc-convo-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--color-bg-soft); border: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: var(--color-primary);
}
.tc-convo-info { flex: 1; min-width: 0; }
.tc-convo-title {
  font-size: 14px; font-weight: 600; color: var(--color-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tc-convo-time { font-size: 11px; color: var(--color-text-muted); margin-top: 2px; }
.tc-convo-chevron { color: var(--color-border); flex-shrink: 0; }
#tc-list-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; padding: 32px 24px; text-align: center; color: var(--color-text-muted);
  gap: 10px;
}
#tc-list-empty svg { opacity: .25; }
#tc-list-empty p { font-size: 13px; line-height: 1.5; }
#tc-new-chat-btn {
  margin: 16px; padding: 11px; border-radius: 24px;
  background: var(--color-primary); color: #fff; border: none; cursor: pointer;
  font-weight: 600; font-size: 14px; font-family: inherit;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .2s; flex-shrink: 0;
}
#tc-new-chat-btn:hover { background: var(--color-primary-dark); }

/* ── chat view ── */
#tc-chat-view { display: none; flex-direction: column; flex: 1; overflow: hidden; }
#tc-chat-view.active { display: flex; }
#tc-messages {
  flex: 1; overflow-y: auto; padding: 14px 12px;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--color-bg-soft);
}
.tc-msg { display: flex; }
.tc-user { justify-content: flex-end; }
.tc-bot  { justify-content: flex-start; }
.tc-bubble {
  max-width: 80%; padding: 9px 13px; border-radius: 14px;
  font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
}
.tc-user .tc-bubble { background: var(--color-primary); color: #fff; border-bottom-right-radius: 4px; }
.tc-bot  .tc-bubble { background: #fff; color: var(--color-text); border-bottom-left-radius: 4px; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.tc-bubble a { color: inherit; text-decoration: underline; }

.tc-typing { display: flex; align-items: center; gap: 5px; padding: 12px 14px; }
.tc-typing span {
  display: block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--color-primary); opacity: .5;
  animation: tc-bounce .9s infinite ease-in-out;
}
.tc-typing span:nth-child(2) { animation-delay: .15s; }
.tc-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes tc-bounce {
  0%,80%,100% { transform: translateY(0); opacity:.4; }
  40% { transform: translateY(-5px); opacity:1; }
}

#tc-input-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-top: 1px solid var(--color-border);
  background: #fff; flex-shrink: 0;
}
#tc-input {
  flex: 1; border: 1px solid var(--color-border); border-radius: 20px;
  padding: 8px 14px; font-size: 14px; font-family: inherit;
  outline: none; color: var(--color-text); background: var(--color-bg-soft);
  transition: border-color .15s;
}
#tc-input:focus { border-color: var(--color-primary); }
#tc-send {
  width: 36px; height: 36px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--color-primary); color: #fff; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; transition: background .2s;
}
#tc-send:hover { background: var(--color-primary-dark); }
#tc-send:disabled { opacity: .5; cursor: default; }
#tc-send svg { width: 16px; height: 16px; }

@media (max-width: 420px) {
  #tc-panel { bottom: 84px; right: 12px; left: 12px; width: auto; }
  #tc-fab { bottom: 16px; right: 16px; }
  #tc-greeting { right: 12px; left: 12px; max-width: none; bottom: 84px; }
}
