*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  font-family: 'Outfit', sans-serif;
}

.brain-module {
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.brain-module:hover {
  transform: scale(1.08);
}

.brain-module.active {
  transform: scale(1.1);
}

.brain-module.active .brain-glow {
  opacity: 1;
}

.brain-module.active .brain-icon {
  filter: brightness(1.3);
}

.brain-glow {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.4s ease;
  filter: blur(12px);
}

.pulse-ring {
  animation: pulse-expand 2s ease-out infinite;
}

@keyframes pulse-expand {
  0% {
    transform: scale(0.95);
    opacity: 0.5;
  }
  50% {
    transform: scale(1);
    opacity: 0.3;
  }
  100% {
    transform: scale(0.95);
    opacity: 0.5;
  }
}

.start-button {
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.start-button::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.start-button:hover::before {
  opacity: 1;
}

.start-button:hover {
  transform: scale(1.05);
  box-shadow: 0 0 40px rgba(139, 92, 246, 0.5);
}

.connection-line {
  /* Lines are always dotted */
}

.connection-line.active {
  stroke-dasharray: none;
}

.floating {
  animation: float 6s ease-in-out infinite;
}

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

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.5);
  animation: particle-float 8s ease-in-out infinite;
}

@keyframes particle-float {
  0%, 100% { 
    transform: translate(0, 0);
    opacity: 0.3;
  }
  50% { 
    transform: translate(20px, -30px);
    opacity: 0.8;
  }
}

/* Chat overlay mobile fixes */
#chat-overlay {
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for iOS */
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
}

.chat-interface {
  animation: slide-up 0.5s ease-out;
  height: 100%;
  max-height: 100vh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  width: 100%;
}

/* Ensure chat messages area is scrollable and takes available space */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  min-height: 0; /* Important for flex child scrolling */
  word-break: break-word;
}

/* Keep input fixed at bottom on mobile */
@media (max-width: 768px) {
  #chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100%;
    height: -webkit-fill-available;
    overflow: hidden;
  }

  .chat-interface {
    height: 100%;
    height: -webkit-fill-available;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  /* Prevent message bubbles from overflowing on iOS */
  .message-bubble > div {
    max-width: 85% !important;
    overflow-wrap: break-word;
    word-break: break-word;
  }
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-bubble {
  animation: fade-in 0.3s ease-out;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.typing-indicator span {
  animation: typing-bounce 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

.typing-cursor {
  animation: cursor-blink 0.8s ease-in-out infinite;
  color: #a78bfa;
  font-weight: normal;
}

@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Product Carousel */
.product-carousel {
  scrollbar-width: thin;
  scrollbar-color: rgba(139, 92, 246, 0.3) transparent;
}

.product-carousel::-webkit-scrollbar {
  height: 6px;
}

.product-carousel::-webkit-scrollbar-track {
  background: transparent;
}

.product-carousel::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.3);
  border-radius: 3px;
}

.product-carousel::-webkit-scrollbar-thumb:hover {
  background: rgba(139, 92, 246, 0.5);
}

.product-card {
  animation: card-appear 0.4s ease-out backwards;
}

.product-card:nth-child(1) { animation-delay: 0.1s; }
.product-card:nth-child(2) { animation-delay: 0.2s; }
.product-card:nth-child(3) { animation-delay: 0.3s; }
.product-card:nth-child(4) { animation-delay: 0.4s; }

@keyframes card-appear {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}