/*!
 * Travel Concierge AI — widget styles
 * Scoped to .tcai-root so it cannot leak into the host theme.
 */

.tcai-root {
  --tcai-primary: #0f766e;
  --tcai-accent: #f59e0b;
  --tcai-ink: #0f172a;
  --tcai-muted: #64748b;
  --tcai-line: #e2e8f0;
  --tcai-surface: #ffffff;
  --tcai-bot-bubble: #f1f5f9;
  --tcai-radius: 18px;
  --tcai-shadow: 0 24px 60px -20px rgba(15, 23, 42, 0.35), 0 8px 24px -12px rgba(15, 23, 42, 0.2);

  position: fixed;
  z-index: 2147483000;
  inset: auto 0 0 auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--tcai-ink);
  -webkit-font-smoothing: antialiased;
}

.tcai-root *,
.tcai-root *::before,
.tcai-root *::after { box-sizing: border-box; }

.tcai-root[data-position="bottom-right"] { right: 20px; bottom: 20px; left: auto; }
.tcai-root[data-position="bottom-left"] { left: 20px; bottom: 20px; right: auto; }

html.tcai-noscroll { overflow: hidden; }

/* ---------- launcher ---------- */

.tcai-launcher {
  position: relative;
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(150deg, var(--tcai-primary), #0b5d57 65%, #083f3b);
  box-shadow: 0 14px 30px -10px rgba(15, 118, 110, 0.65), 0 4px 10px rgba(15, 23, 42, 0.15);
  cursor: pointer;
  transition: transform .22s cubic-bezier(.2,.9,.3,1.3), box-shadow .22s ease;
}

.tcai-root[data-position="bottom-left"] .tcai-launcher { margin-left: 0; margin-right: auto; }

.tcai-launcher:hover { transform: translateY(-2px) scale(1.04); }
.tcai-launcher:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--tcai-accent) 80%, #fff);
  outline-offset: 3px;
}

.tcai-launcher-icon { display: grid; place-items: center; }

.tcai-launcher-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  color: #3b2606;
  background: var(--tcai-accent);
  box-shadow: 0 2px 6px rgba(0,0,0,.18);
}

.tcai-launcher.tcai-pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--tcai-primary);
  animation: tcai-ping 2.4s ease-out 2;
  pointer-events: none;
}

@keyframes tcai-ping {
  0% { transform: scale(1); opacity: .55; }
  70% { transform: scale(1.5); opacity: 0; }
  100% { transform: scale(1.5); opacity: 0; }
}

.tcai-root.tcai-open .tcai-launcher { transform: scale(.92); }

/* ---------- panel ---------- */

.tcai-panel {
  position: absolute;
  right: 0;
  bottom: 76px;
  display: flex;
  flex-direction: column;
  width: min(400px, calc(100vw - 40px));
  max-height: min(640px, calc(100vh - 120px));
  overflow: hidden;
  border: 1px solid var(--tcai-line);
  border-radius: var(--tcai-radius);
  background: var(--tcai-surface);
  box-shadow: var(--tcai-shadow);
  transform-origin: bottom right;
  animation: tcai-in .26s cubic-bezier(.2,.9,.3,1.05);
}

.tcai-root[data-position="bottom-left"] .tcai-panel {
  right: auto;
  left: 0;
  transform-origin: bottom left;
}

.tcai-panel[hidden] { display: none; }

@keyframes tcai-in {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- header ---------- */

.tcai-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--tcai-primary), #0b5d57 70%, #0a4f4a);
}

.tcai-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 17px;
  color: #062d2a;
  background: linear-gradient(150deg, #ffffff, #d7f2ee);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.6);
}

.tcai-head-meta { flex: 1 1 auto; min-width: 0; }

.tcai-head-name {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tcai-head-role {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0 0;
  font-size: 12px;
  opacity: .85;
}

.tcai-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, .22);
}

.tcai-close {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(255,255,255,.14);
  cursor: pointer;
  transition: background .18s ease;
}

.tcai-close:hover { background: rgba(255,255,255,.26); }
.tcai-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---------- message log ---------- */

.tcai-log {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 16px 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  background:
    radial-gradient(120% 60% at 100% 0%, rgba(15,118,110,.05), transparent 60%),
    #fbfdfd;
}

.tcai-log::-webkit-scrollbar { width: 8px; }
.tcai-log::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; }

.tcai-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 92%;
  animation: tcai-rise .22s ease both;
}

@keyframes tcai-rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.tcai-row-user { align-self: flex-end; align-items: flex-end; }
.tcai-row-bot { align-self: flex-start; align-items: flex-start; }

.tcai-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tcai-row-user .tcai-bubble {
  color: #fff;
  background: linear-gradient(150deg, var(--tcai-primary), #0d6b64);
  border-bottom-right-radius: 6px;
}

.tcai-row-bot .tcai-bubble {
  color: var(--tcai-ink);
  background: var(--tcai-bot-bubble);
  border: 1px solid #e6edf5;
  border-bottom-left-radius: 6px;
}

/* typing indicator */
.tcai-bubble.tcai-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 14px;
}

.tcai-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  animation: tcai-bounce 1.1s infinite ease-in-out;
}

.tcai-dot:nth-child(2) { animation-delay: .15s; }
.tcai-dot:nth-child(3) { animation-delay: .3s; }

@keyframes tcai-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .55; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- sources ---------- */

.tcai-sources {
  margin-top: 2px;
  padding: 8px 10px;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  background: #fff;
  max-width: 100%;
}

.tcai-sources-label {
  display: block;
  margin-bottom: 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--tcai-muted);
}

.tcai-source-list { display: flex; flex-direction: column; gap: 4px; }

.tcai-source {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  font-size: 12.5px;
  text-decoration: none;
  color: #0b5d57;
  border-radius: 6px;
}

.tcai-source:hover .tcai-source-name { text-decoration: underline; }
.tcai-source:focus-visible { outline: 2px solid var(--tcai-primary); outline-offset: 2px; }

.tcai-source-tag {
  flex: 0 0 auto;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #0b5d57;
  background: #d6f2ee;
}

.tcai-source.is-web .tcai-source-tag { color: #7c4a03; background: #fdeccd; }
.tcai-source.is-web { color: #8a5304; }

.tcai-source-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- feedback ---------- */

.tcai-rate {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-left: 2px;
}

.tcai-rate-btn {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  font-size: 12px;
  border: 1px solid var(--tcai-line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition: background .16s ease, transform .16s ease;
}

.tcai-rate-btn:hover:not(:disabled) { background: #f1f5f9; transform: translateY(-1px); }
.tcai-rate-btn:disabled { opacity: .45; cursor: default; }

.tcai-rate-done {
  font-size: 11.5px;
  color: var(--tcai-muted);
}

/* ---------- suggestions ---------- */

.tcai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 16px 0;
  background: #fff;
}

.tcai-chips[hidden] { display: none; }

.tcai-chip {
  max-width: 100%;
  padding: 6px 11px;
  font-size: 12.5px;
  font-family: inherit;
  color: #0b5d57;
  text-align: left;
  border: 1px solid #cfe9e5;
  border-radius: 999px;
  background: #f2fbf9;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tcai-chip:hover { background: #e2f5f1; border-color: #9dd8d0; }
.tcai-chip:focus-visible { outline: 2px solid var(--tcai-primary); outline-offset: 2px; }

/* ---------- composer ---------- */

.tcai-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 8px;
  border-top: 1px solid var(--tcai-line);
  background: #fff;
}

.tcai-input {
  flex: 1 1 auto;
  min-height: 40px;
  max-height: 120px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  color: var(--tcai-ink);
  border: 1px solid var(--tcai-line);
  border-radius: 12px;
  background: #f8fafc;
  resize: none;
  overflow-y: auto;
}

.tcai-input:focus {
  outline: none;
  border-color: var(--tcai-primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(15,118,110,.14);
}

.tcai-input::placeholder { color: #94a3b8; }

.tcai-send {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(150deg, var(--tcai-primary), #0d6b64);
  cursor: pointer;
  transition: opacity .16s ease, transform .16s ease;
}

.tcai-send:hover:not(:disabled) { transform: translateY(-1px); }
.tcai-send:disabled { opacity: .5; cursor: not-allowed; }
.tcai-send:focus-visible { outline: 3px solid var(--tcai-accent); outline-offset: 2px; }

/* ---------- footer ---------- */

.tcai-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 10px;
  padding: 0 14px 10px;
  background: #fff;
}

.tcai-footer-note {
  flex: 1 1 190px;
  font-size: 10.5px;
  line-height: 1.35;
  color: var(--tcai-muted);
}

.tcai-handoff {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--tcai-primary);
  text-decoration: none;
  white-space: nowrap;
}

.tcai-handoff:hover { text-decoration: underline; }

/* ---------- inline shortcode block ---------- */

.tcai-inline { margin: 1.5em 0; }

.tcai-inline-launch {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 20px;
  font-family: inherit;
  text-align: left;
  border: 1px solid #cfe9e5;
  border-radius: 16px;
  background: linear-gradient(135deg, #f0fbf9, #ffffff 60%);
  cursor: pointer;
  transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}

.tcai-inline-launch:hover {
  border-color: #9dd8d0;
  transform: translateY(-1px);
  box-shadow: 0 12px 26px -18px rgba(15,118,110,.7);
}

.tcai-inline-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 18px;
  color: #fff;
  background: linear-gradient(150deg, var(--tcai-primary, #0f766e), #0b5d57);
}

.tcai-inline-text { display: flex; flex-direction: column; gap: 2px; }
.tcai-inline-text strong { font-size: 15px; color: #0b3b38; }
.tcai-inline-text span { font-size: 13px; color: #52706e; }

/* ---------- mobile ---------- */

@media (max-width: 782px) {
  .tcai-root[data-position="bottom-right"] { right: 14px; bottom: 14px; }
  .tcai-root[data-position="bottom-left"] { left: 14px; bottom: 14px; }

  .tcai-launcher { width: 56px; height: 56px; }

  .tcai-panel {
    position: fixed;
    inset: 0;
    width: 100vw;
    max-height: 100vh;
    height: 100vh;
    border: 0;
    border-radius: 0;
    animation: tcai-in-mobile .22s ease;
  }

  .tcai-log { padding: 14px 14px 4px; }
  .tcai-row { max-width: 100%; }
  .tcai-chips { padding: 8px 14px 0; flex-wrap: nowrap; overflow-x: auto; }
  .tcai-chip { flex: 0 0 auto; }
  .tcai-composer { padding-bottom: max(8px, env(safe-area-inset-bottom)); }

  @keyframes tcai-in-mobile {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

@media (prefers-reduced-motion: reduce) {
  .tcai-root *,
  .tcai-root *::before,
  .tcai-root *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
