/*
 * Ticket Compare AI concierge.
 *
 * Tokens are scoped to .tc-chat-* so we cannot accidentally bleed into the
 * theme. Colors use CSS custom properties so the theme can override per
 * brand (set --tc-chat-accent on :root or html.tc-theme-x).
 */

:root {
  /* Aligned with homepage palette: navy primary + orange CTA accent. */
  --tc-chat-primary: #102f3f;
  --tc-chat-primary-dark: #0a2230;
  --tc-chat-accent: #fc904d;
  --tc-chat-accent-dark: #e87d36;
  --tc-chat-bg: #ffffff;
  --tc-chat-surface: #f4f6f8;
  --tc-chat-surface-2: #eaf0f4;
  --tc-chat-border: #dfe5ea;
  --tc-chat-text: #102f3f;
  --tc-chat-muted: #5f7585;
  --tc-chat-user-bg: var(--tc-chat-primary);
  --tc-chat-user-fg: #ffffff;
  --tc-chat-shadow: 0 18px 48px rgba(16, 47, 63, 0.22);
  --tc-chat-radius: 18px;
  --tc-chat-z: 99990;
}

#tc-chat-root[hidden] { display: none !important; }

#tc-chat-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: var(--tc-chat-z);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--tc-chat-text);
}

.tc-chat-launcher {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 20px;
  background: var(--tc-chat-primary);
  color: #fff;
  border: 0;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(16, 47, 63, 0.32);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.tc-chat-launcher:hover { background: var(--tc-chat-primary-dark); transform: translateY(-1px); box-shadow: 0 12px 28px rgba(16, 47, 63, 0.4); }
.tc-chat-launcher:focus-visible { outline: 2px solid var(--tc-chat-accent); outline-offset: 3px; }
.tc-chat-launcher svg { flex: 0 0 auto; }
[data-tc-chat-open="true"] .tc-chat-launcher { transform: scale(0.92); opacity: 0; pointer-events: none; }

.tc-chat-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 392px;
  max-width: calc(100vw - 24px);
  height: 600px;
  max-height: calc(100dvh - 40px);
  background: var(--tc-chat-bg);
  border: 1px solid var(--tc-chat-border);
  border-radius: var(--tc-chat-radius);
  box-shadow: var(--tc-chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(12px) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.18s ease;
}
[data-tc-chat-open="true"] .tc-chat-panel {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.tc-chat-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--tc-chat-border);
  background: linear-gradient(180deg, #ffffff 0%, #f7fafc 100%);
}
.tc-chat-panel__title { display: flex; align-items: center; gap: 12px; }
.tc-chat-panel__title strong { display: block; font-size: 15px; font-weight: 700; color: var(--tc-chat-text); line-height: 1.2; }
.tc-chat-panel__title small { display: block; font-size: 11px; color: var(--tc-chat-muted); margin-top: 2px; }
.tc-chat-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #25c26a;
  box-shadow: 0 0 0 4px rgba(37, 194, 106, 0.18);
  flex: 0 0 auto;
}
.tc-chat-panel__close {
  background: transparent;
  border: 0;
  color: var(--tc-chat-muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 8px;
}
.tc-chat-panel__close:hover { background: var(--tc-chat-surface); color: var(--tc-chat-text); }

.tc-chat-panel__body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  scroll-behavior: smooth;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfd 100%);
}

.tc-msg {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  animation: tc-msg-in 0.18s ease both;
}
@keyframes tc-msg-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
.tc-msg--user {
  align-self: flex-end;
  background: var(--tc-chat-user-bg);
  color: var(--tc-chat-user-fg);
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 6px rgba(16, 47, 63, 0.12);
}
.tc-msg--assistant {
  align-self: flex-start;
  background: var(--tc-chat-surface);
  color: var(--tc-chat-text);
  border-bottom-left-radius: 4px;
}
.tc-msg--error {
  align-self: flex-start;
  background: #fff1f1;
  color: #b21f24;
  border: 1px solid #fbd0d3;
}
.tc-msg__caret::after {
  content: "▍";
  margin-left: 1px;
  animation: tc-blink 1s steps(2) infinite;
  color: var(--tc-chat-muted);
}
@keyframes tc-blink { 50% { opacity: 0; } }

.tc-typing {
  align-self: flex-start;
  background: var(--tc-chat-surface);
  border-radius: 14px;
  padding: 12px 14px;
  display: inline-flex;
  gap: 4px;
}
.tc-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tc-chat-muted);
  animation: tc-bounce 1.2s infinite ease-in-out;
}
.tc-typing span:nth-child(2) { animation-delay: 0.15s; }
.tc-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes tc-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

.tc-cards {
  align-self: stretch;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin: 6px 0 4px;
  width: 100%;
  min-width: 0;
}
.tc-card {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 13px 14px;
  border: 1px solid var(--tc-chat-border);
  border-radius: 14px;
  background: #fff;
  text-decoration: none;
  color: inherit;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.tc-card:hover {
  border-color: var(--tc-chat-accent);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(252, 144, 77, 0.18);
}
.tc-card__main { flex: 1 1 auto; min-width: 0; overflow: hidden; }
.tc-card__event {
  font-weight: 700;
  font-size: 14px;
  color: var(--tc-chat-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.tc-card__meta {
  font-size: 12px;
  color: var(--tc-chat-muted);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
}
.tc-card__price {
  flex: 0 0 auto;
  font-weight: 800;
  font-size: 15px;
  color: var(--tc-chat-accent-dark);
  text-align: right;
  min-width: 68px;
  line-height: 1.1;
}
.tc-card__price small {
  display: block;
  font-weight: 600;
  font-size: 10px;
  color: var(--tc-chat-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}
.tc-card__price--soldout {
  color: var(--tc-chat-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tc-chat-panel__suggestions {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  border-top: 1px solid var(--tc-chat-border);
  background: #fff;
  flex: 0 0 auto;
}
.tc-chat-panel__suggestions::-webkit-scrollbar { display: none; }
.tc-chip {
  flex: 0 0 auto;
  padding: 8px 14px;
  background: #fff;
  border: 1px solid var(--tc-chat-border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--tc-chat-text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.tc-chip:hover { background: var(--tc-chat-primary); border-color: var(--tc-chat-primary); color: #fff; }
.tc-chat-panel__suggestions[hidden] { display: none; }

.tc-chat-panel__form {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--tc-chat-border);
  background: #fff;
  align-items: center;
}
/* When suggestions sit directly above the form, the suggestions border is
   sufficient — drop the duplicate divider. */
.tc-chat-panel__suggestions:not([hidden]) + .tc-chat-panel__form {
  border-top: 0;
}
.tc-chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--tc-chat-border);
  border-radius: 999px;
  font-size: 14px;
  background: var(--tc-chat-surface);
  color: var(--tc-chat-text);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.tc-chat-input::placeholder { color: var(--tc-chat-muted); }
.tc-chat-input:focus {
  border-color: var(--tc-chat-primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(16, 47, 63, 0.08);
}
.tc-chat-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--tc-chat-primary);
  color: #fff;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 12px rgba(16, 47, 63, 0.22);
}
.tc-chat-send:hover { background: var(--tc-chat-primary-dark); transform: translateY(-1px); }
.tc-chat-send:disabled { background: #b8c3d6; cursor: not-allowed; box-shadow: none; transform: none; }
.tc-chat-send svg { transform: translate(-1px, 1px); }

@media (max-width: 540px) {
  #tc-chat-root { right: 12px; bottom: 12px; }
  [data-tc-chat-open="true"] .tc-chat-panel {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    max-width: 100vw;
    border-radius: 0;
    border: 0;
  }
}
