/* TrackSure Chat — floating widget */
:root { --tsc-accent: #10b981; }

.tsc-wrap {
  position: fixed;
  bottom: 20px;
  z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: #111827;
}
.tsc-wrap.tsc-right { right: 20px; }
.tsc-wrap.tsc-left  { left:  20px; }

/* Bubble — built to override aggressive theme button styling */
.tsc-wrap .tsc-bubble {
  width: 62px !important;
  height: 62px !important;
  min-width: 62px !important;
  min-height: 62px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 50% !important;
  background:
    radial-gradient(circle at 30% 25%, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0) 55%),
    var(--tsc-accent) !important;
  color: #fff !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  position: relative;
  text-decoration: none !important;
  box-shadow:
    0 12px 28px -8px rgba(16,185,129,0.5),
    0 6px 14px -4px rgba(0,0,0,0.25),
    inset 0 -2px 6px rgba(0,0,0,0.12) !important;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.tsc-wrap .tsc-bubble:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow:
    0 16px 32px -8px rgba(16,185,129,0.55),
    0 8px 18px -4px rgba(0,0,0,0.3),
    inset 0 -2px 6px rgba(0,0,0,0.12) !important;
}
.tsc-wrap .tsc-bubble:focus {
  outline: 3px solid rgba(16,185,129,0.4);
  outline-offset: 3px;
}
.tsc-wrap .tsc-bubble svg {
  width: 28px !important;
  height: 28px !important;
  color: #fff !important;
  display: block;
}

/* Pulse ring around the bubble — subtle "live" feel */
.tsc-bubble-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 0 0 rgba(16,185,129,0.55);
  animation: tscBubblePulse 2.4s cubic-bezier(0.4,0,0.2,1) infinite;
}
@keyframes tscBubblePulse {
  0%   { box-shadow: 0 0 0 0   rgba(16,185,129,0.55); }
  70%  { box-shadow: 0 0 0 14px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0   rgba(16,185,129,0); }
}

/* Panel */
.tsc-panel {
  position: absolute;
  bottom: 76px;
  width: 360px;
  max-width: calc(100vw - 40px);
  height: 540px;
  max-height: calc(100vh - 100px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25), 0 10px 20px -6px rgba(0,0,0,0.1);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.05);
}
.tsc-wrap.tsc-right .tsc-panel { right: 0; }
.tsc-wrap.tsc-left  .tsc-panel { left:  0; }
.tsc-panel.tsc-open { display: flex; animation: tscFadeUp 0.2s ease; }

@keyframes tscFadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Header */
.tsc-header {
  padding: 14px 16px;
  background: var(--tsc-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.tsc-header-info { display: flex; align-items: center; gap: 10px; min-width: 0; }

/* Avatar — generic */
.tsc-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  display: block;
}
img.tsc-avatar { background: rgba(255,255,255,0.15); }
.tsc-avatar-initials {
  background: rgba(255,255,255,0.2);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0;
}
.tsc-avatar-initials span { line-height: 1; }
/* Header avatar styling matches generic; message-row avatar overrides below */

/* Message-row avatar (smaller, separate background) */
.tsc-msg .tsc-avatar-msg {
  width: 28px;
  height: 28px;
  background: var(--tsc-accent);
  color: #fff;
  font-size: 13px;
  align-self: flex-end;
  margin-right: 6px;
  margin-bottom: 18px; /* aligns above timestamp */
}
.tsc-msg img.tsc-avatar-msg { background: #f1f5f9; }

.tsc-name   { font-weight: 600; font-size: 14px; line-height: 1.1; }
.tsc-online {
  font-size: 11px;
  opacity: 0.85;
  display: flex; align-items: center; gap: 4px;
}
.tsc-online::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #34d399;
  animation: tscPulse 2s infinite;
}
@keyframes tscPulse {
  0%   { box-shadow: 0 0 0 0 rgba(255,255,255,0.6); }
  70%  { box-shadow: 0 0 0 6px rgba(255,255,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
}
.tsc-panel .tsc-close {
  background: rgba(255,255,255,0.18) !important;
  border: 0 !important;
  color: #fff !important;
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  padding: 0 !important;
  border-radius: 10px !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: background 0.15s ease;
}
.tsc-panel .tsc-close:hover { background: rgba(255,255,255,0.30) !important; }
.tsc-panel .tsc-close svg {
  width: 18px !important;
  height: 18px !important;
  color: #fff !important;
  display: block;
}

/* Messages list */
.tsc-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

/* Each message row */
.tsc-msg {
  display: flex;
  max-width: 88%;
  align-items: flex-end;
  gap: 6px;
}
.tsc-msg.tsc-user      { align-self: flex-end;   flex-direction: row-reverse; }
.tsc-msg.tsc-assistant { align-self: flex-start; }

.tsc-msg-group { display: flex; flex-direction: column; max-width: 100%; }

/* Bubble */
.tsc-bubble-msg {
  padding: 9px 13px;
  border-radius: 14px;
  word-wrap: break-word;
  white-space: normal;
  max-width: 100%;
}
.tsc-msg.tsc-user .tsc-bubble-msg {
  background: var(--tsc-accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.tsc-msg.tsc-assistant .tsc-bubble-msg {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
}
.tsc-bubble-msg a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.tsc-msg.tsc-user .tsc-bubble-msg a { color: #fff; }
.tsc-msg.tsc-assistant .tsc-bubble-msg a { color: var(--tsc-accent); }

/* Time meta */
.tsc-meta {
  font-size: 10.5px;
  color: #94a3b8;
  margin-top: 3px;
  padding: 0 4px;
}
.tsc-msg.tsc-user .tsc-meta { text-align: right; }

/* Typing dots */
.tsc-typing { display: flex; gap: 4px; padding: 0; }
.tsc-typing-bubble { padding: 12px 14px; }
.tsc-typing span {
  width: 7px; height: 7px;
  background: #94a3b8;
  border-radius: 50%;
  animation: tscBlink 1.2s infinite ease-in-out;
}
.tsc-typing span:nth-child(2) { animation-delay: 0.15s; }
.tsc-typing span:nth-child(3) { animation-delay: 0.30s; }
@keyframes tscBlink {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
  40%           { opacity: 1;   transform: scale(1);    }
}

/* Input row */
.tsc-input-row {
  padding: 10px 12px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.tsc-input {
  flex: 1;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 100px;
  min-height: 38px;
  outline: none;
}
.tsc-input:focus { border-color: var(--tsc-accent); box-shadow: 0 0 0 3px rgba(16,185,129,0.15); }
.tsc-panel .tsc-send {
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  padding: 0 !important;
  background: var(--tsc-accent) !important;
  color: #fff !important;
  border: 0 !important;
  border-radius: 10px !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0;
  box-shadow: 0 4px 10px -2px rgba(16,185,129,0.4);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}
.tsc-panel .tsc-send:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px -2px rgba(16,185,129,0.5);
}
.tsc-panel .tsc-send:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.tsc-panel .tsc-send svg {
  width: 20px !important;
  height: 20px !important;
  color: #fff !important;
  display: block;
}

/* Footer */
.tsc-footer {
  padding: 6px 12px 8px;
  background: #fff;
  text-align: center;
  font-size: 10px;
  color: #94a3b8;
  border-top: 1px solid #f1f5f9;
}
.tsc-footer button {
  background: transparent;
  border: 0;
  color: #64748b;
  font-size: 11px;
  cursor: pointer;
  padding: 2px 6px;
  text-decoration: underline;
}

/* Mobile tweaks */
@media (max-width: 480px) {
  .tsc-wrap { bottom: 12px; }
  .tsc-wrap.tsc-right { right: 12px; }
  .tsc-wrap.tsc-left  { left:  12px; }
  .tsc-panel {
    width: calc(100vw - 24px);
    height: calc(100vh - 90px);
    bottom: 70px;
  }
}
