/* Sporty/Ventsi Chatbot Widget */
#sporty-chatbot {
  --sporty-primary: #0a7d5e;
  --sporty-primary-hover: #086a50;
  --sporty-primary-light: #C1EE4B;
  --sporty-bg: #ffffff;
  --sporty-text: #1a1a1a;
  --sporty-muted: #6b7280;
  --sporty-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

#sporty-chatbot button,
#sporty-chatbot input,
#sporty-chatbot select,
#sporty-chatbot textarea {
  font-family: inherit;
}

/* ── PILL LAUNCHER (collapsed, default) ─────────────────────────────────── */
#sporty-pill {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--sporty-bg);
  border: 1px solid var(--sporty-primary);
  border-radius: 999px;
  padding: 6px 18px 6px 6px;
  box-shadow: var(--sporty-shadow);
  cursor: pointer;
  animation: sporty-pill-in 0.3s ease, sporty-pill-pulse 1.4s ease-out infinite;
}

#sporty-pill[hidden] {
  display: none !important;
}

#sporty-pill:hover {
  transform: translateY(-2px);
}

#sporty-pill:focus-visible {
  outline: 2px solid var(--sporty-primary);
  outline-offset: 3px;
}

@keyframes sporty-pill-in {
  from { transform: translateY(16px) scale(0.9); }
  to   { transform: translateY(0) scale(1); }
}

/* Pill pulses only while collapsed — it's display:none (via [hidden]) once
   the panel is open, which stops the animation from rendering. */
@keyframes sporty-pill-pulse {
  0%   { box-shadow: var(--sporty-shadow), 0 0 0 0 rgba(34, 197, 94, 0.8); }
  60%  { box-shadow: var(--sporty-shadow), 0 0 0 18px rgba(34, 197, 94, 0); }
  100% { box-shadow: var(--sporty-shadow), 0 0 0 0 rgba(34, 197, 94, 0); }
}

.sporty-pill-avatar-wrap {
  position: relative;
  width: 58px;
  height: 58px;
  flex-shrink: 0;
}

.sporty-pill-avatar,
.sporty-pill-avatar-fallback {
  position: absolute;
  inset: 0;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: cover;
}

.sporty-pill-avatar {
  opacity: 0;
  transition: opacity 0.15s ease;
}

.sporty-pill-avatar.is-loaded {
  opacity: 1;
}

.sporty-pill-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sporty-primary-light);
  border: 1px solid var(--sporty-primary);
  color: var(--sporty-primary);
}

.sporty-pill-avatar-fallback svg {
  width: 60%;
  height: 60%;
  fill: currentColor;
}

.sporty-pill-status {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #fff;
}

.sporty-pill-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
}

.sporty-pill-label {
  font-weight: 700;
  font-size: 13px;
  color: var(--sporty-text);
  line-height: 1.2;
}

.sporty-pill-online {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #16a34a;
  font-weight: 600;
  white-space: nowrap;
}

/* ── PANEL ──────────────────────────────────────────────────────────────── */
#sporty-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 360px;
  height: 520px;
  background: var(--sporty-bg);
  border-radius: 16px;
  box-shadow: var(--sporty-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: sporty-slide-in 0.25s ease;
}

#sporty-panel[hidden] {
  display: none !important;
}

@keyframes sporty-slide-in {
  from { transform: scale(0.92) translateY(12px); }
  to   { transform: scale(1) translateY(0); }
}

/* ── HEADER ─────────────────────────────────────────────────────────────── */
.sporty-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--sporty-primary);
  color: #fff;
  flex-shrink: 0;
}

.sporty-header-avatar-wrap {
  position: relative;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.sporty-header-avatar,
.sporty-header-avatar-fallback {
  position: absolute;
  inset: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  box-sizing: border-box;
}

.sporty-header-avatar {
  opacity: 0;
  transition: opacity 0.15s ease;
}

.sporty-header-avatar.is-loaded {
  opacity: 1;
}

.sporty-header-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sporty-primary-light);
  color: var(--sporty-primary);
}

.sporty-header-avatar-fallback svg {
  width: 60%;
  height: 60%;
  fill: currentColor;
}

.sporty-header-status {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid var(--sporty-primary);
}

.sporty-header-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sporty-header-title {
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sporty-header-online {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  font-size: 11px;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 600;
  white-space: normal;
  overflow-wrap: anywhere;
}

.sporty-new-chat-header {
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.sporty-new-chat-header:hover {
  background: rgba(255,255,255,0.25);
}

.sporty-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  padding: 4px;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 4px;
  transition: background 0.15s ease;
}

.sporty-close:hover {
  background: rgba(255,255,255,0.15);
}

/* ── HISTORY ────────────────────────────────────────────────────────────── */
#sporty-history {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}

.sporty-msg {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.sporty-msg-bot {
  background: #f3f4f6;
  color: var(--sporty-text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.sporty-msg-user {
  background: var(--sporty-primary);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.sporty-msg-system {
  background: #fff3cd;
  color: #856404;
  align-self: center;
  border-radius: 8px;
  font-size: 12px;
  text-align: center;
  padding: 7px 12px;
  max-width: 90%;
}

/* ── TYPING INDICATOR ───────────────────────────────────────────────────── */
.sporty-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 9px 13px;
  background: #f3f4f6;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  width: 52px;
}

.sporty-typing span {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sporty-muted);
  animation: sporty-bounce 1.1s infinite;
}

.sporty-typing span:nth-child(2) { animation-delay: 0.18s; }
.sporty-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes sporty-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-6px); }
}

/* ── OPTIONS ────────────────────────────────────────────────────────────── */
#sporty-options {
  padding: 0 12px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sporty-option-btn {
  background: #fff;
  border: 1.5px solid var(--sporty-primary);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--sporty-primary);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.sporty-option-btn:visited,
.sporty-option-btn:active {
  color: var(--sporty-primary);
}

.sporty-option-btn:hover,
.sporty-option-btn:focus {
  background: var(--sporty-primary);
  color: #fff;
  outline: none;
}

/* ── CTA BUTTON ─────────────────────────────────────────────────────────── */
.sporty-cta-btn {
  display: block;
  margin: 4px 12px 8px;
  padding: 10px 16px;
  background: var(--sporty-primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
  transition: background 0.15s ease;
}

.sporty-cta-btn:hover,
.sporty-cta-btn:focus {
  background: var(--sporty-primary-hover);
  outline: none;
}

/* ── LEAD FORM ──────────────────────────────────────────────────────────── */
#sporty-lead-form {
  padding: 10px 12px;
  border-top: 1px solid #f0f0f0;
  overflow-y: auto;
  max-height: 280px;
}

#sporty-lead-inner {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

#sporty-lead-inner input,
#sporty-lead-inner select {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
  color: var(--sporty-text);
  box-sizing: border-box;
  transition: border-color 0.15s ease;
}

#sporty-lead-inner input:focus,
#sporty-lead-inner select:focus {
  outline: none;
  border-color: var(--sporty-primary);
}

.sporty-lead-submit {
  background: var(--sporty-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}

.sporty-lead-submit:hover {
  background: var(--sporty-primary-hover);
}

/* ── FOOTER ─────────────────────────────────────────────────────────────── */
.sporty-footer {
  text-align: center;
  padding: 4px 12px 8px;
  flex-shrink: 0;
}

.sporty-footer-consent {
  display: block;
  font-size: 9px;
  color: var(--sporty-muted);
}

.sporty-footer-consent a {
  color: var(--sporty-primary);
  text-decoration: underline;
}

/* ── RESPONSIVE ─────────────────────────────────────────────────────────── */
/* Cookie popup sits bottom-left on desktop, so the pill keeps its corner;
   on narrow screens the two would collide, so the pill moves above it. */
@media (max-width: 640px) {
  body.cookie-consent-visible #sporty-pill {
    bottom: var(--cookie-consent-offset, 180px);
  }
}

@media (max-width: 480px) {
  #sporty-pill {
    right: 16px;
    bottom: 16px;
    max-width: calc(100vw - 32px);
  }

  #sporty-panel {
    width: 100vw;
    height: 100dvh;
    bottom: 0;
    right: 0;
    border-radius: 0;
  }
}
