/* ============================================================
 * Logic Talk AI — Chatbot widget styles
 * Brand-aligned with css/own-it.css tokens. Self-contained so this
 * file can be dropped onto any page without conflicts.
 * ============================================================ */

.ltai-chat-root,
.ltai-chat-root * {
  box-sizing: border-box;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ===== Floating launcher (the button + pill) ===== */
.ltai-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9990;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none; /* children re-enable */
}

/* ===== Greeting teaser card (replaces the old "Ask anything" pill) =====
 * Greets new visitors with the assistant's opener + quick-start chips.
 * Client-side only — no API call happens until a chip/message is sent. */
.ltai-chat-teaser {
  pointer-events: auto;
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 300px;
  background: #FFFFFF;
  border: 1px solid #E5DED4;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 24px 64px rgba(14, 17, 22, 0.16), 0 4px 12px rgba(14, 17, 22, 0.06);
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  transition: opacity 320ms ease, transform 320ms ease;
  pointer-events: none;
}

.ltai-chat-teaser.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.ltai-chat-teaser__close {
  position: absolute;
  top: 10px;
  right: 12px;
  padding: 2px 6px;
  background: transparent;
  border: 0;
  color: #8C857C;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
}
.ltai-chat-teaser__close:hover { color: #0E1116; }

.ltai-chat-teaser__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.ltai-chat-teaser__avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #1e3a5f;
  color: #FAF7F4;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ltai-chat-teaser__id { display: flex; flex-direction: column; }
.ltai-chat-teaser__name {
  font-size: 13px;
  font-weight: 600;
  color: #0E1116;
  line-height: 1.25;
}
.ltai-chat-teaser__label {
  font-size: 11px;
  color: #6B655C;
  line-height: 1.25;
}

.ltai-chat-teaser__msg {
  margin: 0 0 12px;
  font-size: 13.5px;
  line-height: 1.5;
  color: #0E1116;
}

.ltai-chat-teaser__chips {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ltai-chat-teaser__chip {
  text-align: left;
  background: #FAF7F4;
  border: 1px solid #E5DED4;
  color: #1e3a5f;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}
.ltai-chat-teaser__chip:hover {
  background: #F2EDE7;
  border-color: #1e3a5f;
}

.ltai-chat-button {
  pointer-events: auto;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #1e3a5f;
  color: #FAF7F4;
  border: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 32px rgba(14, 17, 22, 0.18), 0 2px 6px rgba(14, 17, 22, 0.08);
  transition: transform 200ms ease, background-color 200ms ease, box-shadow 200ms ease;
  position: relative;
}

.ltai-chat-button:hover {
  background: #15294a;
  transform: translateY(-1px);
  box-shadow: 0 16px 40px rgba(14, 17, 22, 0.22), 0 3px 8px rgba(14, 17, 22, 0.10);
}

.ltai-chat-button:focus-visible {
  outline: 2px solid #d97706;
  outline-offset: 3px;
}

.ltai-chat-button svg { width: 24px; height: 24px; display: block; }

/* Notification dot — small "you have a message" indicator. Persistent
 * until the user opens the chat for the first time. Brand orange to
 * match the existing pulse + focus accent. */
.ltai-chat-button__notification {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #d97706;
  border: 2px solid #FAF7F4;
  box-shadow: 0 1px 3px rgba(217, 119, 6, 0.35);
  pointer-events: none;
  animation: ltai-notification-pulse 2.4s ease-in-out infinite;
}

.ltai-chat-button__notification.is-hidden {
  display: none;
}

@keyframes ltai-notification-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.55), 0 1px 3px rgba(217, 119, 6, 0.35);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(217, 119, 6, 0), 0 1px 3px rgba(217, 119, 6, 0.35);
  }
}

/* Subtle pulse on first page load — runs twice, then stops.
 * Honors prefers-reduced-motion (defined further down). */
.ltai-chat-button.is-pulsing::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid #d97706;
  opacity: 0;
  animation: ltai-pulse 1.6s ease-out 2;
  pointer-events: none;
}
@keyframes ltai-pulse {
  0%   { opacity: 0.55; transform: scale(0.95); }
  100% { opacity: 0;    transform: scale(1.35); }
}

/* Hide launcher when modal is open */
.ltai-chat-root.is-open .ltai-chat-launcher { display: none; }

/* ===== Modal ===== */
.ltai-chat-modal {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 380px;
  height: min(600px, calc(100vh - 48px));
  background: #FAF7F4;
  border-radius: 14px;
  border: 1px solid #E5DED4;
  box-shadow: 0 24px 64px rgba(14, 17, 22, 0.18), 0 4px 12px rgba(14, 17, 22, 0.06);
  z-index: 9991;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition: opacity 200ms ease, transform 200ms ease;
  /* CRITICAL: opacity:0 elements still intercept clicks. Without this,
   * the invisible modal sits on top of the launcher (same corner, higher
   * z-index) and swallows every click to the button. */
  pointer-events: none;
}

.ltai-chat-root.is-open .ltai-chat-modal {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Mobile: full-screen modal — only for true mobile devices (≤480px).
 * Above 480px (including narrow desktop windows with DevTools open or
 * split-screen layouts), keep the floating card variant.
 *
 * For modal widths that would exceed available viewport on small screens,
 * the card auto-constrains via `max-width: calc(100vw - 24px)` below. */
@media (max-width: 480px) {
  .ltai-chat-modal {
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    border-radius: 0;
    border: 0;
  }
}

/* Narrow-desktop safeguard: constrain card width so it doesn't overflow
 * viewport when the browser window is narrow but above mobile breakpoint. */
@media (min-width: 481px) and (max-width: 700px) {
  .ltai-chat-modal {
    width: calc(100vw - 32px);
    max-width: 380px;
    right: 16px;
    bottom: 16px;
  }
}

/* ===== Modal header ===== */
.ltai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, #1e3a5f 0%, #15294a 100%);
  color: #FAF7F4;
  border-bottom: 1px solid #15294a;
}

.ltai-chat-header__left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ltai-chat-header__avatar {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(250, 247, 244, 0.14);
  border: 1px solid rgba(250, 247, 244, 0.25);
  color: #FAF7F4;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Presence dot — brand amber, not green: "service online", never "human
 * online" (red-team 2026-06-12: green dot + AI-label drift = FTC risk) */
.ltai-chat-header__dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #d97706;
  border: 2px solid #1e3a5f;
}

.ltai-chat-header__badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 1px 5px;
  background: rgba(250, 247, 244, 0.18);
  border: 1px solid rgba(250, 247, 244, 0.28);
  border-radius: 4px;
  flex-shrink: 0;
  margin-right: 2px;
}

.ltai-chat-header__title {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ltai-chat-header__subtitle {
  font-size: 11px;
  color: rgba(250, 247, 244, 0.72);
  font-weight: 400;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ltai-chat-header__close {
  background: transparent;
  color: #FAF7F4;
  border: 0;
  padding: 6px;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms ease;
  flex-shrink: 0;
}
.ltai-chat-header__close:hover { background: rgba(250, 247, 244, 0.12); }
.ltai-chat-header__close svg { width: 18px; height: 18px; }

/* ===== Quick actions bar ===== */
.ltai-chat-quickbar {
  padding: 10px 12px;
  background: #F2EDE7;
  border-bottom: 1px solid #EFE9E0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
}

.ltai-chat-quickbar a {
  color: #1e3a5f;
  text-decoration: none;
  font-weight: 500;
  padding: 4px 0;
}
.ltai-chat-quickbar a:hover { color: #0E1116; text-decoration: underline; }
.ltai-chat-quickbar .ltai-sep { color: #8C857C; }

/* ===== Conversation thread ===== */
.ltai-chat-thread {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #FAF7F4;
  scroll-behavior: smooth;
}

.ltai-chat-msg {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.ltai-chat-msg--bot {
  align-self: flex-start;
  background: #FFFFFF;
  color: #0E1116;
  border: 1px solid #EFE9E0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(14, 17, 22, 0.04);
}

.ltai-chat-msg--user {
  align-self: flex-end;
  background: linear-gradient(135deg, #1e3a5f 0%, #15294a 100%);
  color: #FAF7F4;
  border-bottom-right-radius: 4px;
}

.ltai-chat-msg--system {
  align-self: center;
  background: rgba(217, 119, 6, 0.10);
  color: #4A463F;
  font-size: 12px;
  border-radius: 8px;
  max-width: 90%;
  text-align: center;
  padding: 6px 12px;
}

.ltai-chat-msg a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: currentColor;
}

.ltai-chat-msg--bot a { color: #1e3a5f; }

/* Typing indicator */
.ltai-chat-typing {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}
.ltai-chat-typing span {
  width: 6px;
  height: 6px;
  background: #8C857C;
  border-radius: 50%;
  animation: ltai-typing 1.2s infinite ease-in-out;
}
.ltai-chat-typing span:nth-child(2) { animation-delay: 0.18s; }
.ltai-chat-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes ltai-typing {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.9); }
  30%           { opacity: 1;   transform: scale(1.1); }
}

/* Suggestion chips (first-load only) */
.ltai-chat-chips {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 4px 4px 4px;
  margin-top: 4px;
}

.ltai-chat-chip {
  text-align: left;
  background: #FFFFFF;
  border: 1px solid #E5DED4;
  color: #1e3a5f;
  font-weight: 500;
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, transform 100ms ease;
}
.ltai-chat-chip:hover {
  background: #F2EDE7;
  border-color: #1e3a5f;
}
.ltai-chat-chip:active { transform: scale(0.98); }

/* ===== Input area ===== */
.ltai-chat-input-area {
  padding: 10px 12px 12px 12px;
  background: #FAF7F4;
  border-top: 1px solid #EFE9E0;
}

.ltai-chat-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #FFFFFF;
  border: 1px solid #E5DED4;
  border-radius: 12px;
  padding: 8px 8px 8px 12px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.ltai-chat-input-wrap:focus-within {
  border-color: #1e3a5f;
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.10);
}

.ltai-chat-textarea {
  flex: 1;
  border: 0;
  background: transparent;
  resize: none;
  font-size: 14px;
  line-height: 1.4;
  color: #0E1116;
  max-height: 120px;
  min-height: 22px;
  padding: 4px 0;
  outline: none;
  font-family: inherit;
}
.ltai-chat-textarea::placeholder { color: #8C857C; }

.ltai-chat-send {
  background: #1e3a5f;
  color: #FAF7F4;
  border: 0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 150ms ease;
}
.ltai-chat-send:hover:not(:disabled) { background: #15294a; }
.ltai-chat-send:disabled {
  background: #E5DED4;
  cursor: not-allowed;
}
.ltai-chat-send svg { width: 16px; height: 16px; }

.ltai-chat-footer {
  font-size: 10px;
  color: #8C857C;
  text-align: center;
  margin-top: 6px;
  line-height: 1.4;
}
.ltai-chat-footer a { color: #8C857C; text-decoration: underline; }

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  .ltai-chat-button.is-pulsing::before { animation: none; opacity: 0; }
  .ltai-chat-button__notification { animation: none; }
  .ltai-chat-teaser { transition: opacity 1ms; transform: none !important; }
  .ltai-chat-modal { transition: opacity 1ms; transform: none !important; }
  .ltai-chat-typing span { animation: none; opacity: 0.6; }
  .ltai-chat-thread { scroll-behavior: auto; }
}

/* ===== Mobile fixes (2026-06-11 CX audit) =====
 * 1. Lift the launcher above the sticky CTA bar (<820px) so it never covers
 *    the "Book audit" button (bar = ~64px + safe-area; see own-it.css).
 * 2. Drop the greeting teaser on mobile — the old pill overlapped the sticky
 *    CTAs there, and a card would too. Mobile visitors still get the
 *    notification dot + pulse.
 * 3. 16px textarea font prevents iOS Safari focus auto-zoom inside the modal.
 * 4. 44px send button meets the tap-target minimum. */
@media (max-width: 820px) {
  .ltai-chat-launcher { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .ltai-chat-teaser { display: none; }
  .ltai-chat-textarea { font-size: 16px; }
  .ltai-chat-send { width: 44px; height: 44px; }
}
