/* ==========================================================================
   Evexia Sports AI Assistant — Chatbot Widget Stylesheet
   Premium glassmorphic design matching the Evexia XSports brand system.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Floating Action Button (FAB)
   -------------------------------------------------------------------------- */
.chatbot-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9998;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primary) 0%, #c9142e 100%);
  color: #FFFFFF;
  font-size: 1.55rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 28px rgba(230, 28, 57, 0.45), 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: none;
}

.chatbot-fab:hover {
  transform: scale(1.1) translateY(-3px);
  box-shadow: 0 10px 36px rgba(230, 28, 57, 0.55), 0 4px 12px rgba(0, 0, 0, 0.2);
}

.chatbot-fab:active {
  transform: scale(0.95);
}

.chatbot-fab.open {
  transform: rotate(90deg) scale(0.9);
  background: var(--charcoal);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.chatbot-fab.open:hover {
  transform: rotate(90deg) scale(1);
}

/* FAB Pulse Ring */
.chatbot-fab::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(230, 28, 57, 0.4);
  animation: chatFabPulse 2.5s ease-out infinite;
  pointer-events: none;
}

.chatbot-fab.open::before {
  animation: none;
  opacity: 0;
}

@keyframes chatFabPulse {
  0% { transform: scale(1); opacity: 0.7; }
  70% { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* FAB Icon Switch */
.chatbot-fab .fab-icon-chat,
.chatbot-fab .fab-icon-close {
  position: absolute;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chatbot-fab .fab-icon-chat {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.chatbot-fab .fab-icon-close {
  opacity: 0;
  transform: scale(0.5) rotate(-90deg);
}

.chatbot-fab.open .fab-icon-chat {
  opacity: 0;
  transform: scale(0.5) rotate(90deg);
}

.chatbot-fab.open .fab-icon-close {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

/* Notification Badge */
.chatbot-fab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--secondary);
  border: 2.5px solid #FFFFFF;
  box-shadow: 0 2px 6px rgba(140, 198, 63, 0.5);
  animation: badgeBounce 1.5s ease infinite;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.chatbot-fab.open .chatbot-fab-badge {
  opacity: 0;
}

@keyframes badgeBounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.25); }
}

/* --------------------------------------------------------------------------
   2. Chat Panel Container
   -------------------------------------------------------------------------- */
.chatbot-panel {
  position: fixed;
  bottom: 104px;
  right: 28px;
  z-index: 9999;
  width: 400px;
  max-height: 600px;
  height: 75vh;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(255, 255, 255, 0.1);

  /* Hidden state */
  opacity: 0;
  visibility: hidden;
  transform: translateY(24px) scale(0.95);
  transform-origin: bottom right;
  transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
              visibility 0.35s;
  pointer-events: none;
}

.chatbot-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* --------------------------------------------------------------------------
   3. Chat Panel Header
   -------------------------------------------------------------------------- */
.chatbot-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--charcoal);
  color: #FFFFFF;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

/* Decorative accent line */
.chatbot-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 50%, var(--accent) 100%);
}

.chatbot-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(230, 28, 57, 0.3);
}

.chatbot-header-info {
  flex: 1;
  min-width: 0;
}

.chatbot-header-name {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.chatbot-header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
}

.chatbot-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--secondary);
  box-shadow: 0 0 6px var(--secondary);
  animation: pulseAnimation 2s infinite;
}

.chatbot-header-close {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: rgba(255, 255, 255, 0.8);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.chatbot-header-close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
  transform: rotate(90deg);
}

/* --------------------------------------------------------------------------
   4. Messages Area
   -------------------------------------------------------------------------- */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(180deg, #f8f9fa 0%, #ffffff 50%, #f8f9fa 100%);
  scroll-behavior: smooth;
}

/* Custom scrollbar */
.chatbot-messages::-webkit-scrollbar {
  width: 5px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 10px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.2);
}

/* --------------------------------------------------------------------------
   5. Message Bubbles
   -------------------------------------------------------------------------- */
.chatbot-msg {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: msgFadeIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  opacity: 0;
}

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

/* Bot message (left) */
.chatbot-msg.bot {
  align-self: flex-start;
}

.chatbot-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: #FFFFFF;
  flex-shrink: 0;
  margin-top: 2px;
}

.chatbot-msg-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.9rem;
  line-height: 1.55;
  word-break: break-word;
}

.chatbot-msg.bot .chatbot-msg-bubble {
  background: #FFFFFF;
  color: var(--text-dark);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* User message (right) */
.chatbot-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chatbot-msg.user .chatbot-msg-bubble {
  background: linear-gradient(135deg, var(--primary) 0%, #c9142e 100%);
  color: #FFFFFF;
  border-bottom-right-radius: 6px;
  box-shadow: 0 4px 14px rgba(230, 28, 57, 0.2);
}

/* Rich message formatting */
.chatbot-msg-bubble strong {
  font-weight: 700;
}

.chatbot-msg-bubble ul {
  margin: 8px 0 4px 0;
  padding-left: 18px;
  list-style-type: none;
}

.chatbot-msg-bubble ul li {
  position: relative;
  padding-left: 4px;
  margin-bottom: 5px;
  font-size: 0.875rem;
  line-height: 1.5;
}

.chatbot-msg-bubble ul li::before {
  content: '▸';
  position: absolute;
  left: -14px;
  color: var(--primary);
  font-weight: 700;
}

.chatbot-msg.user .chatbot-msg-bubble ul li::before {
  color: rgba(255, 255, 255, 0.7);
}

.chatbot-msg-bubble a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chatbot-msg.user .chatbot-msg-bubble a {
  color: rgba(255, 255, 255, 0.95);
}

/* Message timestamp */
.chatbot-msg-time {
  font-size: 0.675rem;
  color: var(--text-dim);
  margin-top: 4px;
  padding: 0 4px;
}

.chatbot-msg.user .chatbot-msg-time {
  text-align: right;
}

/* --------------------------------------------------------------------------
   6. Typing Indicator
   -------------------------------------------------------------------------- */
.chatbot-typing {
  display: none;
  align-self: flex-start;
  gap: 10px;
  max-width: 88%;
  animation: msgFadeIn 0.3s ease forwards;
}

.chatbot-typing.active {
  display: flex;
}

.chatbot-typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 20px;
  background: #FFFFFF;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.chatbot-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: typingBounce 1.4s infinite ease-in-out;
}

.chatbot-typing-dots span:nth-child(1) { animation-delay: 0s; }
.chatbot-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chatbot-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); background: var(--text-dim); }
  30% { transform: translateY(-8px); background: var(--primary); }
}

/* --------------------------------------------------------------------------
   7. Suggestion Chips
   -------------------------------------------------------------------------- */
.chatbot-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0 2px 40px;
  animation: msgFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  opacity: 0;
  animation-delay: 0.15s;
}

.chatbot-chip {
  padding: 7px 14px;
  border-radius: 20px;
  border: 1.5px solid rgba(230, 28, 57, 0.2);
  background: rgba(230, 28, 57, 0.04);
  color: var(--primary);
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  user-select: none;
}

.chatbot-chip:hover {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(230, 28, 57, 0.25);
}

.chatbot-chip:active {
  transform: scale(0.96);
}

/* --------------------------------------------------------------------------
   8. Input Area
   -------------------------------------------------------------------------- */
.chatbot-input-area {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: #FFFFFF;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}

.chatbot-input {
  flex: 1;
  border: 1.5px solid rgba(0, 0, 0, 0.1);
  border-radius: 24px;
  padding: 11px 18px;
  font-size: 0.9rem;
  font-family: var(--font-body);
  color: var(--text-dark);
  background: var(--bg-light);
  outline: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
  min-width: 0;
}

.chatbot-input::placeholder {
  color: var(--text-dim);
  font-weight: 400;
}

.chatbot-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(230, 28, 57, 0.1);
  background: #FFFFFF;
}

.chatbot-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--primary) 0%, #c9142e 100%);
  color: #FFFFFF;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 3px 12px rgba(230, 28, 57, 0.3);
}

.chatbot-send-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 5px 18px rgba(230, 28, 57, 0.4);
}

.chatbot-send-btn:active {
  transform: scale(0.92);
}

.chatbot-send-btn:disabled {
  background: var(--text-dim);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* --------------------------------------------------------------------------
   9. Welcome / Quick Start Area
   -------------------------------------------------------------------------- */
.chatbot-welcome {
  text-align: center;
  padding: 24px 20px 12px;
}

.chatbot-welcome-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(230, 28, 57, 0.1) 0%, rgba(0, 174, 238, 0.1) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: 1.5rem;
}

.chatbot-welcome h4 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--charcoal);
  margin-bottom: 6px;
}

.chatbot-welcome p {
  font-size: 0.825rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   10. Powered-by Footer
   -------------------------------------------------------------------------- */
.chatbot-powered {
  text-align: center;
  padding: 6px 16px 10px;
  font-size: 0.68rem;
  color: var(--text-dim);
  background: #FFFFFF;
  letter-spacing: 0.03em;
}

.chatbot-powered strong {
  color: var(--primary);
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   11. Responsive Design
   -------------------------------------------------------------------------- */

/* Tablet */
@media (max-width: 1024px) {
  .chatbot-panel {
    width: 380px;
  }
}

/* Mobile — full-width bottom sheet */
@media (max-width: 600px) {
  .chatbot-fab {
    bottom: 20px;
    right: 20px;
    width: 58px;
    height: 58px;
    font-size: 1.4rem;
  }

  .chatbot-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 92vh;
    height: 92vh;
    border-radius: 20px 20px 0 0;
    transform-origin: bottom center;
  }

  .chatbot-panel.open {
    transform: translateY(0) scale(1);
  }

  .chatbot-header {
    padding: 14px 16px;
  }

  .chatbot-messages {
    padding: 16px 12px;
  }

  .chatbot-chips {
    padding-left: 36px;
  }

  .chatbot-input-area {
    padding: 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}

/* Back-to-top offset to avoid overlapping FAB */
.back-to-top {
  right: 28px;
  bottom: 100px;
}

@media (max-width: 600px) {
  .back-to-top {
    bottom: 90px;
    right: 20px;
  }
}

/* --------------------------------------------------------------------------
   12. Accessibility — Reduced Motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .chatbot-fab,
  .chatbot-panel,
  .chatbot-msg,
  .chatbot-chip,
  .chatbot-typing-dots span,
  .chatbot-fab::before,
  .chatbot-fab-badge {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}
