/* ==========================================================================
   The Battle for Better Air — Chatbot UI Shell
   ========================================================================== */

:root {
  --chat-primary: #7dd3fc;
  --chat-bg: #0a0e1a;
  --chat-surface: #1e293b;
  --chat-header: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  --chat-text: #f8fafc;
  --chat-text-dim: #94a3b8;
  --chat-shadow: 0 12px 24px -8px rgba(0, 0, 0, 0.5), 0 0 20px rgba(125, 211, 252, 0.15);
  --chat-glow: 0 0 15px rgba(125, 211, 252, 0.3);
}

/* Free-Floating Mascot */
.mascot-container {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: auto;
  height: 240px;
  z-index: 9999;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease, opacity 0.25s ease;
}

@media (max-width: 640px) {
  .mascot-container {
    bottom: 16px;
    right: 16px;
    height: 140px;
  }
}

.mascot-container:hover {
  transform: scale(1.04);
  filter: drop-shadow(0 0 24px rgba(125, 211, 252, 0.4));
}

.mascot-pose {
  position: absolute;
  bottom: 0;
  right: 0;
  height: 100%;
  width: auto;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none; /* Let container handle clicks */
}

/* Make the first pose relative so the container has natural width */
.mascot-pose.pose-icon {
  position: relative;
}

.mascot-pose.is-active {
  opacity: 1;
}

.mascot-bubble {
  position: absolute;
  top: -40px;
  right: 50%;
  transform: translateX(50%);
  background: #1e293b;
  border: 1px solid rgba(125, 211, 252, 0.3);
  color: var(--chat-text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  white-space: nowrap;
  box-shadow: 0 0 15px rgba(125, 211, 252, 0.3);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.mascot-bubble::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px 6px 0;
  border-style: solid;
  border-color: #1e293b transparent transparent transparent;
}
.mascot-bubble.show-bubble {
  opacity: 1;
}

.mascot-walk-in {
  animation: mascot-walk 1.2s ease-out forwards;
}

@keyframes mascot-walk {
  0% { transform: translateX(120%); }
  80% { transform: translateX(-5%); }
  100% { transform: translateX(0); }
}

.mascot-idle {
  animation: mascot-float 3.5s ease-in-out infinite;
}

@keyframes mascot-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* Fallback Link */
.chatbot-link {
  color: #7dd3fc;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color 0.2s, text-shadow 0.2s;
}

.chatbot-link:hover {
  color: #bae6fd;
  text-shadow: 0 0 8px rgba(125, 211, 252, 0.6);
}

@keyframes chat-pulse {
  0%, 100% { box-shadow: 0 0 10px rgba(125, 211, 252, 0.2); }
  50% { box-shadow: 0 0 25px rgba(125, 211, 252, 0.5); }
}

/* Chat Panel */
.chat-panel {
  position: fixed;
  bottom: 104px;
  right: 24px;
  width: 380px;
  height: 600px;
  max-height: calc(80vh);
  background: var(--chat-bg);
  border-radius: 16px;
  box-shadow: var(--chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9998;
  border: 1px solid rgba(125, 211, 252, 0.1);
  transform: translateY(20px);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.25s ease, opacity 0.25s ease, visibility 0.25s;
}

.chat-panel.is-active {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
}

/* Header */
.chat-header {
  background: var(--chat-header);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(125, 211, 252, 0.1);
}

.chat-header__title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--chat-text);
}

.chat-header__title svg {
  width: 20px;
  height: 20px;
  color: var(--chat-primary);
}

.chat-close {
  background: none;
  border: none;
  color: var(--chat-text-dim);
  cursor: pointer;
  padding: 4px;
  display: flex;
  transition: color 0.2s;
}

.chat-close:hover {
  color: var(--chat-text);
}

/* Body / Messages */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--chat-surface) transparent;
}

.chat-body::-webkit-scrollbar {
  width: 6px;
}

.chat-body::-webkit-scrollbar-thumb {
  background-color: var(--chat-surface);
  border-radius: 10px;
}

.chat-msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 0.95rem;
  line-height: 1.5;
  position: relative;
  font-family: 'Inter', sans-serif;
}

.chat-msg--bot {
  align-self: flex-start;
  background: var(--chat-surface);
  color: var(--chat-text);
  border-bottom-left-radius: 4px;
  margin-left: 32px;
}

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

.chat-msg__avatar {
  position: absolute;
  left: -40px;
  bottom: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--chat-primary);
}

.bot-avatar {
  background-image: url('images/mascot-icon.png?v=2');
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  border: 1px solid rgba(125, 211, 252, 0.2);
}

.typing-avatar {
  width: 36px;
  height: 36px;
  left: -44px;
  background-image: url('images/mascot-thinking.png?v=2');
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  border: 1px solid rgba(125, 211, 252, 0.2);
  animation: thinking-pulse 1.5s infinite ease-in-out;
}

@keyframes thinking-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.05);
    opacity: 1;
  }
}

.chat-msg__avatar svg {
  width: 14px;
  height: 14px;
}

.chat-msg__time {
  display: block;
  font-size: 0.75rem;
  margin-top: 6px;
  opacity: 0.7;
}

/* Footer / Input */
.chat-footer {
  padding: 16px 20px;
  background: #0f172a;
  border-top: 1px solid rgba(125, 211, 252, 0.1);
  display: flex;
  gap: 12px;
}

.chat-input {
  flex: 1;
  background: var(--chat-surface);
  border: 1px solid rgba(125, 211, 252, 0.2);
  border-radius: 20px;
  padding: 10px 16px;
  color: var(--chat-text);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

.chat-input:focus {
  outline: none;
  border-color: var(--chat-primary);
}

.chat-send {
  background: var(--chat-primary);
  color: #0f172a;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, background 0.2s;
}

.chat-send:hover {
  background: #38bdf8;
  transform: scale(1.05);
}

.chat-send:active {
  transform: scale(0.95);
}

.chat-msg--typing {
  padding: 12px 16px;
  background: var(--chat-surface);
  color: var(--chat-text);
  border-bottom-left-radius: 4px;
  margin-left: 32px;
  width: fit-content;
}

.chat-msg--typing .chat-msg__text {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 20px;
}

.dot {
  width: 6px;
  height: 6px;
  background-color: var(--chat-primary);
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out both;
  opacity: 0.7;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

.chat-disclosure {
  font-size: 0.8rem;
  color: var(--chat-text-dim);
  font-style: italic;
  margin-bottom: 12px;
  line-height: 1.4;
}

.chatbot-product-card {
  background: #0f172a;
  border-left: 3px solid var(--chat-primary);
  border-radius: 6px;
  padding: 12px;
  margin-top: 12px;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.chatbot-product-card:hover {
  box-shadow: var(--chat-glow);
  transform: translateY(-2px);
}

.chatbot-product-card__name {
  font-family: 'Fraunces', serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--chat-text);
  margin: 0 0 4px 0;
}

.chatbot-product-card__stats {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--chat-text-dim);
  margin-bottom: 8px;
}

.chatbot-product-card__desc {
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  color: var(--chat-text);
  margin-bottom: 8px;
  line-height: 1.4;
}

.chatbot-product-card__fit {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: var(--chat-text-dim);
  margin-bottom: 12px;
  line-height: 1.4;
  border-top: 1px solid rgba(125, 211, 252, 0.1);
  padding-top: 8px;
}

.chatbot-product-card__btn {
  display: inline-block;
  background-color: #f59e0b;
  color: #111827;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 8px 12px;
  border-radius: 4px;
  text-decoration: none;
  text-align: center;
  width: 100%;
  transition: background-color 0.2s ease;
}

.chatbot-product-card__btn:hover {
  background-color: #fbbf24;
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .chat-panel {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
    z-index: 10000;
  }
  
  .chat-panel.is-active {
    transform: none;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .chat-panel, .chat-send, .chat-input, .chatbot-product-card {
    transition: none !important;
    animation: none !important;
  }
  .typing-avatar {
    animation: none !important;
  }
  .mascot-container {
    transition: opacity 0.3s ease !important;
  }
  .mascot-container:hover {
    transform: none;
  }
  .mascot-walk-in {
    animation: mascot-fade-in 0.3s ease-in forwards !important;
  }
  .mascot-idle {
    animation: none !important;
  }
}
@keyframes mascot-fade-in {
  0% { opacity: 0; transform: translateX(0); }
  100% { opacity: 1; transform: translateX(0); }
}
