/* ============================================================
   Chatbot widget — "Tumi" AI directory assistant
   Modern Intercom/Fin-style with gradient-orb avatar
   ============================================================ */

.tdc-root {
  --tdc-brand: #700523;
  --tdc-brand-dark: #500117;
  --tdc-brand-light: #8a1c3a;
  --tdc-accent: #f5b400;
  --tdc-text: #1a1d27;
  --tdc-muted: #6b7186;
  --tdc-soft: #9aa0b3;
  --tdc-line: #ebedf3;
  --tdc-bg: #ffffff;
  --tdc-bg-soft: #f7f8fc;
  --tdc-bot-bubble: #f1f2f8;
  --tdc-user-grad: linear-gradient(135deg, #700523 0%, #a32650 100%);
  --tdc-shadow: 0 24px 60px rgba(20, 24, 40, 0.24), 0 6px 18px rgba(20,24,40,0.10);

  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9999;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--tdc-text);
}

/* ---------- Floating launcher ---------- */
.tdc-fab {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  background: linear-gradient(135deg, #1a1d27 0%, #2d3142 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(20,24,40,0.30), 0 4px 12px rgba(20,24,40,0.16);
  position: relative;
  transition: transform .25s cubic-bezier(.4,1.4,.5,1), box-shadow .25s ease;
  /* hidden until the entrance animation fires */
  opacity: 0;
  transform: scale(0.3) translateY(30px);
}
.tdc-root.tdc-entered .tdc-fab {
  animation: tdc-fab-enter 0.8s cubic-bezier(.2, 1.6, .4, 1) forwards,
             tdc-fab-wave 6s ease-in-out 2.5s infinite;
}
.tdc-root.is-open .tdc-fab {
  /* keep the entered state but stop the wave once chat is open */
  animation: tdc-fab-enter 0s forwards !important;
  opacity: 1;
  transform: scale(1);
}
.tdc-fab:hover { transform: translateY(-3px) scale(1.05) !important; box-shadow: 0 16px 40px rgba(20,24,40,0.36); animation-play-state: paused; }
.tdc-fab:active { transform: translateY(-1px) scale(1.02) !important; }
@keyframes tdc-fab-enter {
  0%   { opacity: 0; transform: scale(0.3) translateY(30px); }
  60%  { opacity: 1; transform: scale(1.12) translateY(-4px); }
  80%  { transform: scale(0.96) translateY(2px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes tdc-fab-wave {
  0%, 88%, 100% { transform: scale(1) rotate(0); }
  90%           { transform: scale(1.08) rotate(-8deg); }
  92%           { transform: scale(1.08) rotate(8deg); }
  94%           { transform: scale(1.08) rotate(-6deg); }
  96%           { transform: scale(1.06) rotate(4deg); }
  98%           { transform: scale(1.02) rotate(0); }
}

/* Gradient orb inside FAB */
.tdc-fab-orb {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: conic-gradient(from 0deg at 50% 50%,
    #700523 0%, #f5b400 25%, #a32650 50%, #ffd062 75%, #700523 100%);
  box-shadow: inset 0 0 12px rgba(255,255,255,0.45), 0 0 16px rgba(245,180,0,0.5);
  position: relative;
  animation: tdc-orb-spin 6s linear infinite;
}
.tdc-fab-orb::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,0.7) 0%, transparent 40%),
    linear-gradient(135deg, #700523, #a32650);
}
@keyframes tdc-orb-spin {
  to { transform: rotate(360deg); }
}

/* breathing glow ring */
.tdc-fab::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(112,5,35,0.4), rgba(245,180,0,0.3), rgba(112,5,35,0.4));
  filter: blur(6px);
  z-index: -1;
  animation: tdc-glow-spin 4s linear infinite;
}
@keyframes tdc-glow-spin {
  to { transform: rotate(360deg); }
}

/* notification dot */
.tdc-fab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--tdc-accent);
  color: #1a1d27;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2.5px solid #fff;
  padding: 0 5px;
  box-shadow: 0 2px 8px rgba(245,180,0,0.55);
  animation: tdc-bounce 1.8s ease-in-out infinite;
}
@keyframes tdc-bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-3px) scale(1.05); }
}

/* peek bubble next to FAB */
.tdc-peek {
  position: absolute;
  bottom: 6px;
  right: 78px;
  background: #fff;
  color: var(--tdc-text);
  padding: 12px 16px;
  border-radius: 16px 16px 4px 16px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 12px 28px rgba(20,24,40,0.16), 0 2px 6px rgba(20,24,40,0.06);
  opacity: 0;
  transform: translateX(14px) scale(0.92);
  transform-origin: bottom right;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tdc-root.tdc-entered .tdc-peek {
  animation: tdc-peek-in 0.55s cubic-bezier(.2,1.4,.4,1) 1.1s forwards;
}
@keyframes tdc-peek-in {
  0%   { opacity: 0; transform: translateX(14px) scale(0.92); }
  60%  { opacity: 1; transform: translateX(-3px) scale(1.04); }
  100% { opacity: 1; transform: translateX(0) scale(1); pointer-events: auto; }
}
.tdc-peek::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: 10px;
  width: 10px;
  height: 10px;
  background: #fff;
  transform: rotate(45deg);
  border-radius: 2px;
}
.tdc-peek-text { cursor: pointer; }
.tdc-peek-close {
  color: var(--tdc-soft);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
}
.tdc-peek-close:hover { color: var(--tdc-text); }
.tdc-root.is-open .tdc-peek,
.tdc-root.peek-dismissed .tdc-peek { display: none; }

/* ---------- Chat window ---------- */
.tdc-window {
  position: absolute;
  right: 0;
  bottom: 76px;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 620px;
  max-height: calc(100vh - 120px);
  background: var(--tdc-bg);
  border-radius: 20px;
  box-shadow: var(--tdc-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(0.85) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform .4s cubic-bezier(.2,1.2,.4,1), opacity .25s ease;
}
.tdc-root.is-open .tdc-window {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.tdc-root.is-open .tdc-fab-badge { display: none; }

/* ---------- Header (mesh gradient) ---------- */
.tdc-header {
  background: linear-gradient(135deg, #500117 0%, #700523 50%, #8a1c3a 100%);
  color: #fff;
  padding: 22px 18px 26px;
  position: relative;
  overflow: hidden;
}
.tdc-header::before,
.tdc-header::after {
  content: "";
  position: absolute;
  pointer-events: none;
  border-radius: 50%;
  filter: blur(40px);
}
.tdc-header::before {
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(245,180,0,0.45), transparent 65%);
  top: -80px;
  right: -60px;
}
.tdc-header::after {
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(163,38,80,0.5), transparent 65%);
  bottom: -90px;
  left: -40px;
}

.tdc-head-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 1;
  margin-bottom: 14px;
}
.tdc-head-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  opacity: 0.92;
}
.tdc-sparkle {
  width: 14px;
  height: 14px;
  color: var(--tdc-accent);
  animation: tdc-sparkle 2.4s ease-in-out infinite;
}
@keyframes tdc-sparkle {
  0%, 100% { transform: scale(1) rotate(0); opacity: 0.85; }
  50%      { transform: scale(1.2) rotate(15deg); opacity: 1; }
}

.tdc-close {
  background: rgba(255,255,255,0.14);
  border: 0;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s ease, transform .25s ease;
}
.tdc-close:hover { background: rgba(255,255,255,0.28); transform: rotate(90deg); }
.tdc-close svg { width: 14px; height: 14px; }

.tdc-hero {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  gap: 12px;
}
.tdc-hero-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}
.tdc-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, #fff1a0 0%, #f5b400 25%, #a32650 60%, #500117 100%);
  position: relative;
  box-shadow: 0 6px 20px rgba(0,0,0,0.30), inset 0 -6px 12px rgba(0,0,0,0.18), inset 0 4px 10px rgba(255,255,255,0.35);
  animation: tdc-avatar-breathe 3.5s ease-in-out infinite;
}
.tdc-avatar::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: conic-gradient(from 180deg at 50% 50%,
    rgba(245,180,0,0.4) 0deg,
    rgba(163,38,80,0.0) 90deg,
    rgba(112,5,35,0.5) 180deg,
    rgba(245,180,0,0.0) 270deg,
    rgba(245,180,0,0.4) 360deg);
  animation: tdc-avatar-rotate 8s linear infinite;
  mix-blend-mode: screen;
}
.tdc-avatar::after {
  content: "";
  position: absolute;
  top: 12%;
  left: 22%;
  width: 38%;
  height: 30%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255,255,255,0.7) 0%, transparent 65%);
  filter: blur(1px);
}
@keyframes tdc-avatar-breathe {
  0%, 100% { transform: scale(1); box-shadow: 0 6px 20px rgba(0,0,0,0.30), 0 0 0 0 rgba(245,180,0,0.0), inset 0 -6px 12px rgba(0,0,0,0.18), inset 0 4px 10px rgba(255,255,255,0.35); }
  50%      { transform: scale(1.04); box-shadow: 0 6px 20px rgba(0,0,0,0.30), 0 0 24px 4px rgba(245,180,0,0.35), inset 0 -6px 12px rgba(0,0,0,0.18), inset 0 4px 10px rgba(255,255,255,0.45); }
}
@keyframes tdc-avatar-rotate {
  to { transform: rotate(360deg); }
}

.tdc-online {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 14px;
  height: 14px;
  background: #21c466;
  border-radius: 50%;
  border: 3px solid #500117;
  box-shadow: 0 0 0 0 rgba(33,196,102,0.7);
  animation: tdc-pulse-online 2s ease-out infinite;
}
@keyframes tdc-pulse-online {
  0%   { box-shadow: 0 0 0 0 rgba(33,196,102,0.7); }
  70%  { box-shadow: 0 0 0 8px rgba(33,196,102,0); }
  100% { box-shadow: 0 0 0 0 rgba(33,196,102,0); }
}

.tdc-hero-text { padding-bottom: 2px; }
.tdc-hero-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
.tdc-hero-sub {
  font-size: 12.5px;
  opacity: 0.85;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tdc-hero-sub::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #21c466;
  box-shadow: 0 0 6px rgba(33,196,102,0.8);
}

/* ---------- Welcome card ---------- */
.tdc-welcome {
  margin: -16px 14px 0;
  background: #fff;
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 8px 24px rgba(20,24,40,0.10), 0 1px 3px rgba(20,24,40,0.06);
  position: relative;
  z-index: 2;
  animation: tdc-welcome-in .55s cubic-bezier(.2,1.1,.4,1) both;
}
@keyframes tdc-welcome-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.tdc-welcome-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}
.tdc-welcome-body {
  font-size: 13px;
  color: var(--tdc-muted);
  line-height: 1.45;
}

/* ---------- Body ---------- */
.tdc-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px 8px;
  background: var(--tdc-bg-soft);
  scroll-behavior: smooth;
}
.tdc-body::-webkit-scrollbar { width: 6px; }
.tdc-body::-webkit-scrollbar-thumb { background: rgba(20,24,40,0.15); border-radius: 999px; }
.tdc-body::-webkit-scrollbar-track { background: transparent; }

.tdc-day-divider {
  text-align: center;
  font-size: 11px;
  color: var(--tdc-soft);
  font-weight: 600;
  margin: 8px 0 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---------- Messages ---------- */
.tdc-msg-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 6px;
  animation: tdc-msg-in .42s cubic-bezier(.2,1.1,.4,1) both;
}
@keyframes tdc-msg-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.tdc-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.tdc-msg-bot   { justify-content: flex-start; }
.tdc-msg-user  { justify-content: flex-end; }

.tdc-msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff1a0 0%, #f5b400 25%, #a32650 60%, #500117 100%);
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(20,24,40,0.15), inset 0 -2px 4px rgba(0,0,0,0.15);
  position: relative;
}
.tdc-msg-avatar::after {
  content: "";
  position: absolute;
  top: 18%;
  left: 22%;
  width: 36%;
  height: 28%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255,255,255,0.65) 0%, transparent 70%);
}
.tdc-msg-user .tdc-msg-avatar { display: none; }

.tdc-bubble {
  max-width: 76%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}
.tdc-msg-bot .tdc-bubble {
  background: var(--tdc-bot-bubble);
  color: var(--tdc-text);
  border-bottom-left-radius: 6px;
}
.tdc-msg-user .tdc-bubble {
  background: var(--tdc-user-grad);
  color: #fff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 4px 14px rgba(112,5,35,0.22);
}
.tdc-bubble a { color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.tdc-msg-bot  .tdc-bubble a { color: var(--tdc-brand); }
.tdc-bubble strong { font-weight: 700; }

.tdc-meta {
  font-size: 10.5px;
  color: var(--tdc-soft);
  margin-top: 3px;
  padding: 0 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.tdc-msg-row.tdc-msg-row-bot  .tdc-meta { padding-left: 38px; }
.tdc-msg-row.tdc-msg-row-user .tdc-meta { justify-content: flex-end; }
.tdc-meta svg { width: 12px; height: 12px; }

/* typing indicator */
.tdc-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px !important;
  min-height: 38px;
}
.tdc-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tdc-brand);
  opacity: 0.45;
  animation: tdc-typing-bounce 1.25s ease-in-out infinite;
}
.tdc-typing span:nth-child(2) { animation-delay: 0.18s; }
.tdc-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes tdc-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-6px); opacity: 1; }
}

/* ---------- Quick replies ---------- */
.tdc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0 12px 38px;
  margin-top: 4px;
  animation: tdc-msg-in .42s cubic-bezier(.2,1.1,.4,1) both;
  animation-delay: .08s;
}
.tdc-chip {
  background: #fff;
  border: 1.5px solid var(--tdc-brand);
  color: var(--tdc-brand);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.tdc-chip:hover {
  background: var(--tdc-brand);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(112,5,35,0.25);
}

/* ---------- Composer ---------- */
.tdc-composer-wrap {
  border-top: 1px solid var(--tdc-line);
  background: #fff;
}
.tdc-composer {
  padding: 12px 12px 6px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.tdc-input {
  flex: 1;
  border: 1.5px solid var(--tdc-line);
  border-radius: 999px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  color: var(--tdc-text);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
  background: var(--tdc-bg-soft);
}
.tdc-input::placeholder { color: var(--tdc-soft); }
.tdc-input:focus {
  border-color: var(--tdc-brand);
  box-shadow: 0 0 0 4px rgba(112,5,35,0.10);
  background: #fff;
}
.tdc-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 0;
  background: var(--tdc-user-grad);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .15s ease, box-shadow .15s ease;
  box-shadow: 0 4px 12px rgba(112,5,35,0.30);
}
.tdc-send:hover { transform: translateX(1px) scale(1.06); box-shadow: 0 6px 18px rgba(112,5,35,0.40); }
.tdc-send:disabled { background: var(--tdc-line); cursor: default; transform: none; box-shadow: none; color: var(--tdc-soft); }
.tdc-send svg { width: 15px; height: 15px; }

.tdc-foot {
  text-align: center;
  font-size: 10.5px;
  color: var(--tdc-soft);
  padding: 0 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.tdc-foot strong { color: var(--tdc-text); font-weight: 700; }
.tdc-foot svg { width: 10px; height: 10px; color: var(--tdc-accent); }

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
  .tdc-root { right: 12px; bottom: 12px; }
  .tdc-window {
    width: calc(100vw - 24px);
    height: calc(100vh - 100px);
    bottom: 66px;
  }
  .tdc-peek { display: none; }
  /* Smaller orb on phones — the 60px FAB covered listing-card text on the
     2-column mobile grid. 48px still comfortably exceeds the 44px tap target. */
  .tdc-fab { width: 48px; height: 48px; }
  .tdc-fab-orb { width: 26px; height: 26px; }
  .tdc-fab-badge { min-width: 17px; height: 17px; font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .tdc-fab::before, .tdc-fab-orb,
  .tdc-fab-badge, .tdc-online,
  .tdc-sparkle, .tdc-typing span,
  .tdc-avatar, .tdc-avatar::before,
  .tdc-peek { animation: none !important; }
  .tdc-msg-row, .tdc-chips, .tdc-window, .tdc-welcome { transition: none !important; animation: none !important; }
}
