/* TitanShield Chatbot Widget — bottom-right floating widget.
 *
 * Mobile (<=640px): full-screen overlay.
 * Desktop: 360x540 panel with launcher button.
 *
 * No transition fluff. Plain CSS, no preprocessing.
 */

.ts-chatbot-launcher {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 9990;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #00b96b;
  color: #ffffff;
  border: none;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.ts-chatbot-launcher:focus {
  outline: 2px solid #003528;
  outline-offset: 2px;
}

.ts-chatbot-launcher[aria-expanded="true"] .ts-chatbot-launcher-open { display: none; }
.ts-chatbot-launcher[aria-expanded="false"] .ts-chatbot-launcher-close { display: none; }

.ts-chatbot-panel {
  position: fixed;
  right: 1.25rem;
  bottom: 5.25rem;
  z-index: 9991;
  width: 360px;
  max-width: calc(100vw - 1rem);
  height: 540px;
  max-height: calc(100vh - 7rem);
  background: var(--bg, #ffffff);
  color: var(--tx, #111111);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.22);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: inherit;
}

[data-theme="dark"] .ts-chatbot-panel {
  background: #15191f;
  color: #f0f3f7;
  border-color: rgba(255, 255, 255, 0.08);
}

.ts-chatbot-panel.is-open { display: flex; }

.ts-chatbot-header {
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #003528, #00b96b);
  color: #ffffff;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ts-chatbot-header-title { font-size: 0.95rem; }

.ts-chatbot-close {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0 0.25rem;
}

.ts-chatbot-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: var(--bg-soft, #fafafa);
}

[data-theme="dark"] .ts-chatbot-body {
  background: #0f1318;
}

.ts-chatbot-msg {
  max-width: 84%;
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.ts-chatbot-msg-user {
  align-self: flex-end;
  background: #00b96b;
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.ts-chatbot-msg-assistant {
  align-self: flex-start;
  background: rgba(0, 0, 0, 0.06);
  color: inherit;
  border-bottom-left-radius: 4px;
}

[data-theme="dark"] .ts-chatbot-msg-assistant {
  background: rgba(255, 255, 255, 0.07);
}

.ts-chatbot-msg-time {
  display: block;
  font-size: 0.65rem;
  opacity: 0.6;
  margin-top: 0.25rem;
}

.ts-chatbot-typing {
  align-self: flex-start;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  padding: 0.55rem 0.75rem;
  display: inline-flex;
  gap: 4px;
}

.ts-chatbot-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #00b96b;
  animation: ts-chatbot-blink 1.2s infinite ease-in-out;
}

.ts-chatbot-typing span:nth-child(2) { animation-delay: 0.15s; }
.ts-chatbot-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ts-chatbot-blink {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

.ts-chatbot-input-row {
  display: flex;
  gap: 0.4rem;
  padding: 0.55rem 0.75rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: var(--bg, #ffffff);
}

[data-theme="dark"] .ts-chatbot-input-row {
  background: #15191f;
  border-color: rgba(255, 255, 255, 0.08);
}

.ts-chatbot-input {
  flex: 1 1 auto;
  resize: none;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  padding: 0.4rem 0.55rem;
  font: inherit;
  background: transparent;
  color: inherit;
  min-height: 38px;
  max-height: 100px;
}

[data-theme="dark"] .ts-chatbot-input { border-color: rgba(255, 255, 255, 0.15); }

.ts-chatbot-send {
  background: #00b96b;
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 0 0.85rem;
  cursor: pointer;
  font-weight: 600;
}

.ts-chatbot-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ts-chatbot-footer-actions {
  display: flex;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  background: var(--bg, #ffffff);
  font-size: 0.8rem;
}

[data-theme="dark"] .ts-chatbot-footer-actions {
  background: #15191f;
  border-color: rgba(255, 255, 255, 0.06);
}

.ts-chatbot-cta {
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  padding: 0.3rem 0.55rem;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

[data-theme="dark"] .ts-chatbot-cta { border-color: rgba(255, 255, 255, 0.15); }

/* Honest disclaimer line: brands the widget as keyword match, not AI.
 * Kept visually quiet (small + low-contrast) so it doesn't crowd the
 * conversation UI but stays readable. */
.ts-chatbot-disclaimer {
  padding: 0.35rem 0.75rem 0.5rem;
  font-size: 0.7rem;
  line-height: 1.3;
  color: rgba(0, 0, 0, 0.55);
  background: var(--bg, #ffffff);
  border-top: 1px solid rgba(0, 0, 0, 0.04);
  text-align: center;
}

[data-theme="dark"] .ts-chatbot-disclaimer {
  color: rgba(255, 255, 255, 0.55);
  background: #15191f;
  border-color: rgba(255, 255, 255, 0.05);
}

/* Auth gate modal — uses the same overlay pattern as tsConfirm. */
.ts-chatbot-auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.ts-chatbot-auth-overlay.is-open { display: flex; }

.ts-chatbot-auth-box {
  background: var(--bg, #ffffff);
  color: var(--tx, #111111);
  padding: 1.5rem;
  border-radius: 12px;
  max-width: 360px;
  width: calc(100% - 2rem);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.3);
  text-align: center;
}

[data-theme="dark"] .ts-chatbot-auth-box {
  background: #15191f;
  color: #f0f3f7;
}

.ts-chatbot-auth-box h3 { margin: 0 0 0.6rem 0; }
.ts-chatbot-auth-box p { margin: 0 0 1.1rem 0; opacity: 0.85; }
.ts-chatbot-auth-actions { display: flex; gap: 0.5rem; justify-content: center; }
.ts-chatbot-auth-actions a {
  background: #00b96b;
  color: #ffffff;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
}
.ts-chatbot-auth-actions a.secondary {
  background: transparent;
  color: inherit;
  border: 1px solid rgba(0, 0, 0, 0.18);
}

[data-theme="dark"] .ts-chatbot-auth-actions a.secondary {
  border-color: rgba(255, 255, 255, 0.2);
}

.ts-chatbot-source-tag {
  display: inline-block;
  font-size: 0.7rem;
  background: rgba(0, 185, 107, 0.12);
  color: #00875a;
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  margin-right: 0.25rem;
}

[data-theme="dark"] .ts-chatbot-source-tag {
  background: rgba(0, 185, 107, 0.22);
  color: #4dd99c;
}

.ts-chatbot-feedback {
  display: inline-flex;
  gap: 0.3rem;
  margin-top: 0.25rem;
}

.ts-chatbot-feedback button {
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  padding: 0.15rem 0.4rem;
  cursor: pointer;
  font-size: 0.75rem;
  color: inherit;
}

[data-theme="dark"] .ts-chatbot-feedback button {
  border-color: rgba(255, 255, 255, 0.2);
}

.ts-chatbot-feedback button.is-selected {
  background: #00b96b;
  color: #ffffff;
  border-color: #00b96b;
}

/* Mobile: full-screen overlay. */
@media (max-width: 640px) {
  .ts-chatbot-panel {
    right: 0;
    left: 0;
    bottom: 0;
    top: 0;
    width: 100%;
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }

  .ts-chatbot-launcher {
    right: 1rem;
    bottom: 1rem;
  }
}
