/* ----- Ask AI — modern, minimal, professional ----- */
/* Primary #4c6ef5, surfaces #fff / #f8fafc, text #0f172a, secondary slate */

/* Prevent background page from scrolling when modal is open */
body.ts-askai-modal-open { overflow: hidden; }

#ts-askai-modal { display: none; }
#ts-askai-modal.open { display: block; }

.ts-askai-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9998;
  touch-action: none;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: saturate(160%) blur(8px);
  -webkit-backdrop-filter: saturate(160%) blur(8px);
}
@media (prefers-reduced-motion: reduce) {
  .ts-askai-backdrop {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}
/* Theme custom.scss .ask-ai-modal used to set padding: 24px on this same node */
#ts-askai-modal .ts-askai-panel.ask-ai-modal {
  padding: 0;
}

.ts-askai-panel {
  --ts-askai-radius: 16px;
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  width: 760px;
  max-width: 92vw;
  max-height: calc(100vh - 80px);
  height: auto;
  min-height: 0;
  display: flex; flex-direction: column;
  background: #ffffff;
  border-radius: var(--ts-askai-radius);
  border: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.04),
    0 4px 12px rgba(15, 23, 42, 0.05),
    0 24px 48px rgba(15, 23, 42, 0.12);
  z-index: 9999;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
/* When no messages, allow suggestions dropdown to extend below panel (no clipping) */
.ts-askai-panel:not(.ts-askai-has-messages) {
  overflow: visible;
}
.ts-askai-panel.ts-askai-has-messages {
  height: calc(100vh - 80px);
  /* Conversation mode: widen to 50vw so answers have more horizontal room.
     Mobile breakpoint below overrides this back to 100%. */
  width: 50vw;
  max-width: 50vw;
  overflow: hidden;
}
/* When suggestions dropdown is open (first or later queries), allow it to extend below the panel */
.ts-askai-panel.ts-askai-suggest-open {
  overflow: visible !important;
}

.ts-askai-chat-panel {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
/* Header — stays on top */
.ts-askai-chat-header {
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px 6px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
  border-radius: var(--ts-askai-radius) var(--ts-askai-radius) 0 0;
}
.ts-askai-chat-header-left {
  display: flex; align-items: center; gap: 10px;
}
.ts-askai-chat-avatar {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, #6b8cff 0%, #4c6ef5 52%, #3b5bdb 100%);
  color: #fff;
  border-radius: 11px;
  box-shadow:
    0 2px 10px rgba(76, 110, 245, 0.28),
    0 0 0 1px rgba(255, 255, 255, 0.14) inset;
}
.ts-askai-chat-avatar .ts-askai-btn-icon-svg { width: 18px; height: 18px; }
.ts-askai-chat-header-text { display: flex; flex-direction: column; gap: 1px; }
.ts-askai-chat-title {
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.02em;
  color: #0f172a;
}
.ts-askai-chat-subtitle {
  font-size: 0.8125rem; color: #64748b; margin-top: 1px;
}
.ts-askai-chat-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: #16a34a;
  transition: color 0.2s ease;
}
.ts-askai-chat-status::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.18);
  flex-shrink: 0;
}
.ts-askai-chat-status[data-status="active"] {
  color: #4c6ef5;
}
.ts-askai-chat-status[data-status="active"]::before {
  background: #4c6ef5;
  box-shadow: 0 0 0 2px rgba(76, 110, 245, 0.18);
}
.ts-askai-close {
  border: 0;
  background: transparent;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  color: #94a3b8;
  border-radius: 10px;
  transition: color 0.18s ease, background 0.18s ease;
}
.ts-askai-close:hover { color: #475569; background: #f1f5f9; }
.ts-askai-close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(76, 110, 245, 0.45);
}

/* Messages area (AI Answer section) — scrolls below header; first message has clear top spacing */
.ts-askai-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 14px 12px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: #f8fafc;
  position: relative;
  z-index: 1;
}
/* Minimal view: hide messages area so modal opens compact (header + hint + input only) */
.ts-askai-chat-messages.ts-askai-messages-empty,
#ts-askai-modal .ts-askai-panel:not(.ts-askai-has-messages) .ts-askai-chat-messages {
  display: none !important;
  flex: 0 0 0 !important;
  min-height: 0 !important;
  max-height: 0 !important;
  overflow: hidden !important;
  padding: 0 !important;
  margin: 0 !important;
}
.ts-askai-panel.ts-askai-has-messages .ts-askai-chat-messages:not(.ts-askai-messages-empty) {
  display: flex !important;
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 14px 12px;
}
.ts-askai-chat-messages::-webkit-scrollbar { width: 8px; }
.ts-askai-chat-messages::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 4px; }
.ts-askai-chat-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.ts-askai-chat-messages::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Message rows: user right, AI left */
.ts-askai-msg { display: flex; }
.ts-askai-msg-wrap-user { justify-content: flex-end; }
.ts-askai-msg-wrap-ai { justify-content: flex-start; }
.ts-askai-msg-content {
  max-width: 95%;
  min-width: 0; /* allow flex child to shrink so long URLs wrap instead of overflowing */
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.6;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.ts-askai-msg-user {
  background: #4c6ef5;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ts-askai-msg-ai {
  background: #fff;
  color: #0f172a;
  border: 1px solid #e6edf4;
  border-bottom-left-radius: 4px;
}
.ts-askai-msg-thinking,
.ai-thinking {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #64748b;
  font-size: 14px;
  flex-wrap: nowrap;
}
.ts-askai-thinking-text {
  white-space: nowrap;
}
.ts-askai-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}
.ts-askai-dot {
  width: 6px;
  height: 6px;
  background: #64748b;
  border-radius: 50%;
  animation: ts-askai-blink 1.2s ease-in-out infinite;
}
.ts-askai-dot:nth-child(1) { animation-delay: 0s; }
.ts-askai-dot:nth-child(2) { animation-delay: 0.15s; }
.ts-askai-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes ts-askai-blink {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

/* Input area — never shrink so search box is always visible */
.ts-askai-chat-input-wrap {
  flex-shrink: 0;
  flex-grow: 0;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  background: #fafbfc;
  overflow: visible;
  padding: 6px 12px 8px;
  min-height: 0;
  border-radius: 0 0 var(--ts-askai-radius) var(--ts-askai-radius);
}
.ts-askai-empty-hint {
  margin: 0 0 4px 0;
  padding: 0;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: #64748b;
  line-height: 1.3;
}
.ts-askai-panel.ts-askai-has-messages .ts-askai-empty-hint {
  display: none;
}
.ts-askai-chat-input-row {
  flex-shrink: 0;
  display: flex;
  gap: 6px;
  align-items: stretch;
  padding: 3px;
  position: relative;
  background: #f1f5f9;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.04);
}
.ts-askai-input-wrap {
  flex: 1;
  min-width: 0;
  position: relative;
  background: #ffffff;
  border-radius: 9px;
  box-shadow: inset 0 0 0 1px #e2e8f0;
  transition: box-shadow 0.2s ease;
}
.ts-askai-input-wrap:focus-within {
  box-shadow: inset 0 0 0 2px rgba(76, 110, 245, 0.4);
}
.ts-askai-input-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: #94A3B8;
  pointer-events: none;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ts-askai-input-search-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}
.ts-askai-input {
  width: 100%;
  padding: 9px 12px 9px 40px;
  border: none;
  border-radius: 9px;
  font-size: 14px;
  min-width: 0;
  background: transparent;
  color: #0f172a;
  transition: color 0.2s ease;
  box-sizing: border-box;
}
.ts-askai-input::placeholder {
  color: #94a3b8;
}
.ts-askai-input:focus {
  outline: none;
}
.ts-askai-send {
  padding: 0 1rem;
  border-radius: 9px;
  border: none;
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  background: linear-gradient(180deg, #5b7cfa 0%, #4c6ef5 55%, #3d5ae8 100%);
  color: #fff;
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(76, 110, 245, 0.35);
  transition: background 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
}
.ts-askai-send:hover {
  background: linear-gradient(180deg, #4c6ef5 0%, #3b5bdb 100%);
  box-shadow: 0 2px 10px rgba(76, 110, 245, 0.35);
}
.ts-askai-send:active {
  transform: translateY(1px);
}
.ts-askai-send:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(76, 110, 245, 0.45);
}

/* Suggestions dropdown — below input when no messages, above when follow-up (has-messages) */
.ts-askai-input-suggest-wrap {
  position: relative;
  overflow: visible;
}
.ts-askai-suggest-dropdown {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 8px;
  min-height: 0;
  max-height: 280px;
  overflow-y: auto;
  overflow-x: hidden;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.1), 0 4px 12px rgba(15, 23, 42, 0.04);
  z-index: 10001;
  padding: 6px 0;
  animation: ts-askai-fadeIn 0.18s ease;
}
/* When panel has messages (follow-up query), show suggestions above the input — more space */
.ts-askai-panel.ts-askai-has-messages .ts-askai-suggest-dropdown {
  top: auto;
  bottom: 100%;
  margin-top: 0;
  margin-bottom: 8px;
  animation: ts-askai-fadeInUp 0.18s ease;
}
@keyframes ts-askai-fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes ts-askai-fadeInUp {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.ts-askai-suggest-dropdown.ts-askai-suggest-visible {
  display: block;
}
.suggestion-section-title,
.ts-askai-suggest-section-title {
  font-size: 11px;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 4px;
  padding: 0 12px 2px;
  display: block;
}
.ts-askai-suggest-section {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #64748b;
}
.ts-askai-suggest-section:first-child { padding-top: 0; }
.ts-askai-suggest-section-icon {
  font-size: 12px;
  opacity: 0.9;
}
.suggestion-item,
.ts-askai-suggest-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: #0f172a;
  cursor: pointer;
  transition: all 0.18s ease;
  margin: 0 6px;
}
.suggestion-item:hover,
.ts-askai-suggest-item:hover {
  background: #f4f7ff;
  transform: translateX(2px);
}
.ts-askai-suggest-item.ts-askai-suggest-highlight,
.ts-askai-suggest-item.suggestion-active {
  background: #eef2ff;
}
.ts-askai-suggest-item.ts-askai-suggest-highlight:hover,
.ts-askai-suggest-item.suggestion-active:hover {
  background: #eef2ff;
  transform: none;
}
.ts-askai-suggest-icon {
  flex-shrink: 0;
  font-size: 1.1rem;
  opacity: 0.9;
  width: 1.25em;
  text-align: center;
}
.ts-askai-suggest-item .ts-askai-suggest-match {
  font-weight: 600;
  color: #4c6ef5;
  background: rgba(76, 110, 245, 0.1);
  padding: 0 2px;
  border-radius: 3px;
}
.ts-askai-suggest-empty {
  padding: 12px 12px;
  font-size: 13px;
  color: #64748b;
  line-height: 1.4;
  text-align: center;
}
/* Skeleton loading for suggestions */
.ts-askai-suggest-skeleton {
  padding: 6px 12px;
  margin: 0 6px;
}
.ts-askai-skeleton {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 37%, #f1f5f9 63%);
  background-size: 200% 100%;
  animation: ts-askai-shimmer 1.4s infinite;
}
.ts-askai-skeleton:first-child { width: 85%; }
.ts-askai-skeleton:nth-child(2) { width: 70%; margin-top: 8px; }
.ts-askai-skeleton:nth-child(3) { width: 90%; margin-top: 8px; }
.ts-askai-skeleton:nth-child(4) { width: 60%; margin-top: 8px; }
.ts-askai-skeleton:nth-child(5) { width: 75%; margin-top: 8px; }
@keyframes ts-askai-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* AI answer area — markdown, lists, code */
.ai-answer,
.ts-askai-msg-ai .ts-askai-answer {
  line-height: 1.7;
  font-size: 15px;
  padding: 16px;
  color: #0f172a;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}
.ts-askai-msg-ai .ts-askai-answer p { margin: 0 0 12px; }
.ts-askai-msg-ai .ts-askai-answer p:last-child { margin-bottom: 0; }
.ts-askai-msg-ai .ts-askai-answer ol,
.ts-askai-msg-ai .ts-askai-answer ul {
  margin: 0 0 16px;
  padding-left: 24px;
}
.ts-askai-msg-ai .ts-askai-answer li { margin-bottom: 6px; }
.ts-askai-msg-ai .ts-askai-answer li:last-child { margin-bottom: 0; }
.ts-askai-msg-ai .ts-askai-answer code {
  background: #f6f8fa;
  color: #0f172a;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.9em;
  font-family: ui-monospace, monospace;
}
.ts-askai-msg-ai .ts-askai-answer pre {
  margin: 12px 0;
  padding: 14px;
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 8px;
  overflow-x: auto;
}
.ts-askai-msg-ai .ts-askai-answer pre code { background: transparent; color: inherit; padding: 0; }
.ts-askai-msg-ai .ts-askai-answer strong { font-weight: 600; color: #0f172a; }
.ts-askai-msg-ai .ts-askai-answer a {
  color: #4c6ef5;
  text-decoration: none;
  font-weight: 500;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}
.ts-askai-msg-ai .ts-askai-answer a:hover { text-decoration: underline; }
.ts-askai-msg-ai .ts-askai-answer h1,
.ts-askai-msg-ai .ts-askai-answer h2,
.ts-askai-msg-ai .ts-askai-answer h3 {
  margin: 16px 0 8px;
  font-weight: 600;
  color: #0f172a;
}
.ts-askai-msg-ai .ts-askai-answer h1 { font-size: 1.25rem; }
.ts-askai-msg-ai .ts-askai-answer h2 { font-size: 1.1rem; }
.ts-askai-msg-ai .ts-askai-answer h3 { font-size: 1rem; }

.ts-askai-msg-ai .ts-askai-sources {
  margin-top: 16px;
  padding: 14px 16px;
  background: #f8fafc;
  border: 1px solid #e6edf4;
  border-radius: 8px;
}
.ts-askai-msg-ai .ts-askai-sources-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  margin-bottom: 10px;
}
.ts-askai-msg-ai .ts-askai-source-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  color: #4c6ef5;
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
  border-bottom: 1px solid #e6edf4;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.ts-askai-msg-ai .ts-askai-source-link:last-child { border-bottom: none; }
.ts-askai-msg-ai .ts-askai-source-link::before {
  content: "";
  width: 6px;
  height: 6px;
  background: #4c6ef5;
  border-radius: 50%;
  flex-shrink: 0;
}
.ts-askai-msg-ai .ts-askai-source-link:hover { color: #3b5bdb; text-decoration: underline; }

/* No-answer state: calm, premium (no raw scores by default) */
.ts-askai-noanswer {
  padding: 0;
  border: none;
  background: transparent;
  color: #334155;
}
.ts-askai-noanswer-inner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 14px 14px 12px;
  border-radius: 12px;
  background: linear-gradient(145deg, #f8fafc 0%, #f1f5f9 50%, #eef2ff 100%);
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px -8px rgba(15, 23, 42, 0.08);
}
.ts-askai-noanswer-icon-wrap {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
  color: #4338ca;
  box-shadow: 0 2px 8px rgba(67, 56, 202, 0.12);
}
.ts-askai-noanswer-icon {
  display: block;
}
.ts-askai-noanswer-copy {
  flex: 1;
  min-width: 0;
}
.ts-askai-noanswer-title {
  margin: 0 0 8px 0;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #0f172a;
  line-height: 1.35;
}
.ts-askai-noanswer-lead {
  margin: 0 0 10px 0;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: #475569;
}
.ts-askai-noanswer-support {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.35);
  font-size: 0.875rem;
  line-height: 1.5;
  color: #475569;
}
.ts-askai-noanswer-support-title {
  margin: 0 0 8px 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #0f172a;
  letter-spacing: -0.01em;
}
.ts-askai-noanswer-support-line {
  margin: 0 0 6px 0;
}
.ts-askai-noanswer-support-note {
  margin: 8px 0 0 0;
  font-size: 0.8125rem;
  color: #64748b;
}
.ts-askai-noanswer-support-link {
  color: #4c6ef5;
  font-weight: 600;
  text-decoration: none;
}
.ts-askai-noanswer-support-link:hover {
  color: #3b5bdb;
  text-decoration: underline;
}
.ts-askai-noanswer-support-link:focus-visible {
  outline: none;
  border-radius: 4px;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(76, 110, 245, 0.45);
}
.ts-askai-noanswer-tips {
  margin: 0;
  padding: 0 0 0 1.15rem;
  font-size: 0.875rem;
  line-height: 1.55;
  color: #64748b;
}
.ts-askai-noanswer-tips li {
  margin-bottom: 8px;
}
.ts-askai-noanswer-tips li:last-child {
  margin-bottom: 0;
}
.ts-askai-noanswer-tips strong {
  color: #334155;
  font-weight: 600;
}
.ts-askai-noanswer-details {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(148, 163, 184, 0.35);
  font-size: 0.8125rem;
  color: #64748b;
}
.ts-askai-noanswer-details-summary {
  cursor: pointer;
  color: #64748b;
  font-weight: 500;
  list-style: none;
}
.ts-askai-noanswer-details-summary::-webkit-details-marker {
  display: none;
}
.ts-askai-noanswer-details-body {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
}
.ts-askai-noanswer-metric {
  font-variant-numeric: tabular-nums;
}

.ts-askai-confidence {
  margin-top: 8px;
  font-size: 13px;
  color: #64748b;
}

/* Loading / thinking state */
.ts-askai-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #6b7280;
}
.ts-askai-thinking-text {
  min-width: 4.5em;
  display: inline-block;
}

.ts-askai-spinner {
  width: 16px;
  height: 16px;
  border: 3px solid #e6edf4;
  border-top: 3px solid #4c6ef5;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* AI disclaimer below each response (inside AI bubble) */
.ts-askai-msg-ai .ts-askai-disclaimer {
  margin-top: 12px;
  padding-top: 10px;
  font-size: 0.75rem;
  line-height: 1.4;
  color: #94a3b8;
  border-top: 1px solid #f1f5f9;
}

/* ----- Ask AI: Mobile view ----- */
@media (max-width: 767.98px) {
  .ts-askai-panel {
    /* Small gap from viewport top (header still uses safe-area padding for content) */
    top: 12px;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    transform: none;
    max-height: calc(100vh - 12px);
    max-height: calc(100dvh - 12px);
    border-radius: 0;
    --ts-askai-radius: 0;
    box-shadow: none;
  }
  .ts-askai-panel.ts-askai-has-messages {
    height: calc(100vh - 12px);
    height: calc(100dvh - 12px);
    /* Override the desktop 50vw so mobile stays full-bleed in conversation mode. */
    width: 100%;
    max-width: 100%;
  }
  .ts-askai-chat-header {
    padding: 8px 12px;
    padding-top: max(8px, env(safe-area-inset-top));
  }
  .ts-askai-chat-header-left { gap: 10px; }
  .ts-askai-chat-avatar { width: 36px; height: 36px; border-radius: 10px; }
  .ts-askai-chat-avatar .ts-askai-btn-icon-svg { width: 18px; height: 18px; }
  .ts-askai-chat-title { font-size: 1rem; }
  .ts-askai-chat-subtitle { display: none; }
  .ts-askai-chat-status { font-size: 0.7rem; }
  .ts-askai-close { font-size: 20px; padding: 6px; }
  .ts-askai-chat-messages {
    padding: 10px 14px 12px;
    gap: 10px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .ts-askai-panel.ts-askai-has-messages .ts-askai-chat-messages:not(.ts-askai-messages-empty) {
    padding: 10px 14px 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .ts-askai-msg-content {
    max-width: 92%;
    padding: 10px 12px;
    font-size: 14px;
    border-radius: 12px;
  }
  .ts-askai-msg-ai .ts-askai-answer {
    font-size: 14px;
    line-height: 1.6;
    padding: 10px;
  }
  .ts-askai-msg-ai .ts-askai-answer code { font-size: 0.85em; }
  .ts-askai-msg-ai .ts-askai-answer pre { padding: 8px; margin: 8px 0; }
  .ts-askai-chat-input-wrap {
    padding: 6px 12px 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  .ts-askai-empty-hint { font-size: 0.75rem; margin-bottom: 4px; }
  .ts-askai-chat-input-row { gap: 6px; }
  .ts-askai-input {
    padding: 10px 12px 10px 34px;
    font-size: 16px;
    min-height: 44px;
    border-radius: 9px;
  }
  .ts-askai-input-search-icon { left: 12px; font-size: 1rem; }
  .ts-askai-send {
    padding: 10px 14px;
    font-size: 14px;
    min-height: 44px;
    border-radius: 9px;
    flex-shrink: 0;
  }
  .ts-askai-suggest-dropdown {
    max-height: 50vh;
    max-height: 50dvh;
    padding: 6px 0;
  }
}

@media (max-width: 575.98px) {
  .ts-askai-chat-panel { width: 100%; max-width: 100%; }
  .ts-askai-chat-header { padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); }
  .ts-askai-chat-avatar { width: 32px; height: 32px; }
  .ts-askai-chat-avatar .ts-askai-btn-icon-svg { width: 16px; height: 16px; }
  .ts-askai-chat-title { font-size: 0.9375rem; }
  .ts-askai-chat-messages { padding: 10px 12px 12px; }
  .ts-askai-msg-content { padding: 10px 12px; font-size: 13px; }
  .ts-askai-chat-input-wrap { padding: 6px 10px 8px; }
  .ts-askai-input {
    padding: 10px 14px 10px 36px;
    font-size: 16px;
    min-height: 44px;
  }
  .ts-askai-send { padding: 10px 14px; min-height: 44px; font-size: 14px; }
}

/* ----- Header: single row on desktop, wrap only on mobile ----- */
.o_main_header {
  overflow: visible;
  gap: 0.5rem;
  flex-wrap: nowrap;
}
.o_header_actions {
  gap: 0.5rem;
  min-width: 0;
  overflow: visible;
  flex-wrap: nowrap;
}
.o_header_actions .o_search_wrapper {
  min-width: 0;
  flex: 1 1 auto;
}

/* Buy Now: hidden by default, shown via .o_buy_now_visible */
.o_buy_now_btn {
  display: none !important;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.85rem;
  min-height: 2.25rem;
  white-space: nowrap;
  border-radius: 0.375rem;
  text-decoration: none;
  font-weight: 600;
  flex-shrink: 0;
}
.o_buy_now_btn.o_buy_now_visible {
  display: inline-flex !important;
}
.o_header_btn {
  padding: 0.45rem 0.85rem;
  min-height: 2.25rem;
  flex-shrink: 0;
  align-items: center;
  white-space: nowrap;
  border-radius: 0.375rem;
  text-decoration: none;
}

/* Ask AI: gradient (lavender → purple), always visible (desktop + mobile) */
#ts-askai-btn,
.ts-askai-header-btn {
  display: inline-flex !important;
  align-items: center;
  white-space: nowrap;
  flex-shrink: 0;
  padding: 0.45rem 0.85rem;
  margin-right: 0.25rem;
  background: #ffffff !important;
  border: 1px solid #e6edf4 !important;
  color: #0f172a !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  border-radius: 0.5rem;
  transition: background 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
#ts-askai-btn:hover,
.ts-askai-header-btn:hover {
  background: #f4f7ff !important;
  border-color: rgba(76, 110, 245, 0.35) !important;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
  transform: translateY(-1px);
  color: #0f172a !important;
}
#ts-askai-btn:focus-visible,
.ts-askai-header-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(76, 110, 245, 0.12), 0 6px 18px rgba(15, 23, 42, 0.12);
  border-color: rgba(76, 110, 245, 0.55) !important;
}
#ts-askai-btn .ts-askai-btn-icon {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-right: 0.35em;
  flex-shrink: 0;
}
#ts-askai-btn .ts-askai-btn-icon-svg {
  width: 1em;
  height: 1em;
  color: #4c6ef5;
  stroke: #4c6ef5;
}
#ts-askai-btn .ts-askai-btn-label {
  color: #0f172a;
}

/* Mobile / tablet (< lg): Ask AI sits in brand row, left of Buy — compact, not full width */
@media (max-width: 991.98px) {
  .o_header_actions {
    gap: 0.4rem;
  }
  .o_header_actions .o_search_wrapper {
    min-width: 0;
  }
  .o_header_mobile_actions .ts-askai-header-btn--mobile {
    width: auto;
    max-width: none;
    justify-content: center;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 0.35rem 0.55rem;
    font-size: 0.8125rem;
    min-height: 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  }
  .o_header_mobile_actions .ts-askai-header-btn--mobile .ts-askai-btn-label {
    display: inline;
  }
  .o_buy_now_btn.o_buy_now_visible {
    padding: 0.4rem 0.65rem;
    font-size: 0.875rem;
    min-height: 2rem;
  }
}
@media (max-width: 380px) {
  .o_header_mobile_actions .ts-askai-header-btn--mobile {
    padding: 0.3rem 0.45rem;
    font-size: 0.75rem;
  }
  .o_header_mobile_actions .ts-askai-header-btn--mobile .ts-askai-btn-label {
    display: none;
  }
  .o_header_mobile_actions .ts-askai-header-btn--mobile .ts-askai-btn-icon {
    margin-right: 0;
  }
}
@media (max-width: 575.98px) {
  .o_buy_now_btn.o_buy_now_visible {
    padding: 0.35rem 0.55rem;
    font-size: 0.8125rem;
    min-height: 1.875rem;
  }
}

/* === Screenshots inside AI answers ============================
 * Rendered by the marked image renderer override in ask_ai.js.
 * Sized to fit the chat bubble; click opens the original in a new tab. */
.ts-askai-msg-content .ts-askai-screenshot-link {
  display: block;
  margin: 8px 0;
  text-decoration: none;
  line-height: 0;
}
.ts-askai-msg-content .ts-askai-screenshot {
  display: block;
  max-width: 100%;
  max-height: 360px;
  width: auto;
  height: auto;
  border: 1px solid #e6edf4;
  border-radius: 8px;
  background: #f8fafc;
  cursor: zoom-in;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.ts-askai-msg-content .ts-askai-screenshot-link:hover .ts-askai-screenshot,
.ts-askai-msg-content .ts-askai-screenshot-link:focus-visible .ts-askai-screenshot {
  border-color: #4c6ef5;
  box-shadow: 0 2px 8px rgba(76, 110, 245, 0.18);
}
.ts-askai-msg-content .ts-askai-screenshot-link:focus-visible {
  outline: 2px solid #4c6ef5;
  outline-offset: 2px;
  border-radius: 8px;
}
@media (max-width: 575.98px) {
  .ts-askai-msg-content .ts-askai-screenshot {
    max-height: 240px;
  }
}
/* ----- Scope chip dropdown (header-mounted switcher) -----
   The chip row is no longer rendered above the input. The header chip is the
   only switcher; clicking it toggles ts-askai-scope-revealed on the panel,
   which pops the chip list out as a vertical dropdown anchored under the
   header on the right. */
.ts-askai-scope-row {
  display: none;
}
.ts-askai-panel.ts-askai-scope-revealed .ts-askai-scope-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: absolute;
  top: 54px;
  right: 14px;
  min-width: 240px;
  max-width: 320px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  z-index: 10;
  background: #ffffff;
  border-radius: 12px;
  padding: 6px;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.06),
    0 18px 40px rgba(15, 23, 42, 0.16);
  animation: ts-askai-scope-pop 160ms ease-out both;
}
@keyframes ts-askai-scope-pop {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ts-askai-panel.ts-askai-scope-revealed .ts-askai-scope-chips {
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 2px;
  width: 100%;
}
/* Inside the dropdown, chips become full-width list rows — premium look. */
.ts-askai-panel.ts-askai-scope-revealed .ts-askai-scope-chip {
  width: 100%;
  justify-content: flex-start;
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  transform: none;
}
.ts-askai-panel.ts-askai-scope-revealed .ts-askai-scope-chip:hover {
  background: #F1F5F9;
  transform: none;
}
.ts-askai-panel.ts-askai-scope-revealed .ts-askai-scope-chip.ts-askai-scope-active {
  background: rgba(67, 97, 238, 0.10);
  color: #4361EE;
  font-weight: 600;
}
.ts-askai-panel.ts-askai-scope-revealed .ts-askai-scope-chip.ts-askai-scope-active:hover {
  background: rgba(67, 97, 238, 0.14);
}
.ts-askai-panel.ts-askai-scope-revealed .ts-askai-scope-chip.ts-askai-scope-suggested:not(.ts-askai-scope-active) {
  background: rgba(67, 97, 238, 0.04);
  color: #4361EE;
}
.ts-askai-panel.ts-askai-scope-revealed .ts-askai-scope-chip-icon {
  width: 16px;
  height: 16px;
  min-width: 16px;
}
.ts-askai-panel.ts-askai-scope-revealed .ts-askai-scope-chip-icon-svg {
  width: 16px;
  height: 16px;
}

/* Header right cluster (prefix label + app chip + close). */
.ts-askai-chat-header-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.ts-askai-header-scope-prefix {
  font-size: 12px;
  font-weight: 500;
  color: #64748b;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
@media (max-width: 575.98px) {
  .ts-askai-header-scope-prefix { display: none; }
}

/* Header-mounted current-app chip — compact pill with caret. */
.ts-askai-header-app-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  color: #1E293B;
  background: #F0F0F0;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  transition: background 180ms ease, color 180ms ease;
}
.ts-askai-header-app-chip:hover {
  background: #E5E7EB;
}
.ts-askai-header-app-chip:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.16);
}
.ts-askai-header-app-chip[aria-expanded="true"] {
  background: rgba(67, 97, 238, 0.10);
  color: #4361EE;
}
.ts-askai-header-app-chip .ts-askai-scope-chip-icon {
  width: 16px;
  height: 16px;
  min-width: 16px;
}
.ts-askai-header-app-chip .ts-askai-scope-chip-icon-svg {
  width: 16px;
  height: 16px;
}
.ts-askai-header-app-caret {
  font-size: 10px;
  color: #94A3B8;
  margin-left: 2px;
}
.ts-askai-header-app-chip[aria-expanded="true"] .ts-askai-header-app-caret {
  color: #4361EE;
}
.ts-askai-scope-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  color: #64748b;
  text-transform: uppercase;
}
.ts-askai-scope-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  flex: 1 1 auto;
}

/* Compact pill — non-selected. No border, no shadow. Surface lift via subtle gradient only. */
.ts-askai-scope-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  color: #1E293B;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  transition: background 180ms ease, color 180ms ease, transform 180ms ease;
  box-shadow: none;
}
.ts-askai-scope-chip:hover {
  background: #F1F5F9;
  transform: translateY(-1px);
}
.ts-askai-scope-chip:focus-visible {
  outline: none;
  /* a11y focus ring kept; not a decorative shadow */
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.16);
}

/* Icon slot (img or inline SVG). Fixed size so it never collapses on flex shrink. */
.ts-askai-scope-chip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  min-width: 14px;
  flex-shrink: 0;
  color: #64748B;
  line-height: 0;
}
.ts-askai-scope-chip-icon-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.ts-askai-scope-chip-icon-svg {
  width: 14px;
  height: 14px;
  display: block;
  /* New fallback SVGs set fill via element attributes (gradient + paths). Don't
     force fill via CSS — would break the colored package icon. */
}
.ts-askai-scope-chip-label {
  white-space: nowrap;
}

/* Page-detected: small green dot before the icon. Pure CSS — no extra DOM. */
.ts-askai-scope-chip.ts-askai-scope-page:not(.ts-askai-scope-active)::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #22c55e;
  margin-right: 1px;
  flex-shrink: 0;
}

/* Suggested (server hint) — soft slate background only, no shadow, no border. */
.ts-askai-scope-chip.ts-askai-scope-suggested:not(.ts-askai-scope-active) {
  background: rgba(67, 97, 238, 0.08);
  color: #4361EE;
}

/* Active/selected. Blue→violet gradient. No glow shadow. */
.ts-askai-scope-chip.ts-askai-scope-active {
  color: #FFFFFF;
  font-weight: 600;
  background: linear-gradient(135deg, #4361EE 0%, #5B5FF5 48%, #6C3DF4 100%);
  box-shadow: none;
}
.ts-askai-scope-chip.ts-askai-scope-active:hover {
  transform: translateY(-1px);
}
.ts-askai-scope-chip.ts-askai-scope-active .ts-askai-scope-chip-icon {
  color: #FFFFFF;
}
.ts-askai-scope-chip.ts-askai-scope-active .ts-askai-scope-chip-icon-img {
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.18));
}

/* ----- Image lightbox (zoom + pan) ----- */
body.ts-askai-lightbox-locked { overflow: hidden; }
.ts-askai-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  /* Above the chat modal (which is z-index 9999) so it always sits on top. */
  z-index: 10001;
}
.ts-askai-lightbox.ts-askai-lightbox-open {
  display: block;
}
.ts-askai-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: saturate(140%) blur(6px);
  -webkit-backdrop-filter: saturate(140%) blur(6px);
}
.ts-askai-lightbox-close {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms ease;
}
.ts-askai-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.24);
}
.ts-askai-lightbox-hint {
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  letter-spacing: 0.02em;
  pointer-events: none;
  z-index: 2;
  text-align: center;
}
@media (max-width: 575.98px) {
  .ts-askai-lightbox-hint { display: none; }
}
.ts-askai-lightbox-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: grab;
}
.ts-askai-lightbox-stage.ts-askai-lightbox-grabbing {
  cursor: grabbing;
}
.ts-askai-lightbox-img {
  max-width: 92vw;
  max-height: 86vh;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: center center;
  transition: transform 80ms ease-out;
  will-change: transform;
}
