:root {
  --primary-color: #667eea;
  --primary-color-dark: #5a67d8;
  --secondary-color: #f8fafc;
  --user-message-color: #667eea;
  --bot-message-color: #ffffff;
  --text-color: #2d3748;
  --text-light: #718096;
  --border-color: #e2e8f0;
  --shadow-light: rgba(0, 0, 0, 0.05);
  --shadow-medium: rgba(0, 0, 0, 0.1);
  --shadow-heavy: rgba(0, 0, 0, 0.25);
  --success-color: #48bb78;
  --error-color: #f56565;
  --warning-color: #ed8936;

  --button-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --user-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --bot-gradient: linear-gradient(135deg, #ffffff 0%, #f7fafc 100%);

  --header-height: 56px;
  --radius-sm: 8px;
  --radius: 16px;
  --radius-lg: 20px;
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  
  --chat-width: 600px;
  --chat-max-height: 600px;
  
  /* Account for sticky header */
  --site-header-height: 90px;
}


body {
  margin: 0;
  font-family: 'Open Sans', sans-serif;
  background: var(--secondary-color);
  color: var(--text-color);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.chat-wrapper {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: var(--chat-width);
}
#chat-form svg,
.chat-wrapper svg {
	display: block;
}
#chat-label {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  color: #1a202c;
  padding: 14px 20px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.95rem;
  font-weight: 700;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.9);
  transition: all var(--transition);
  pointer-events: none;
  box-shadow: 0 8px 35px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(20px);
  white-space: nowrap;
  border: 2px solid rgba(102, 126, 234, 0.8);
  animation: label-glow 2s ease-in-out infinite alternate;
}

#chat-label.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}
@keyframes label-glow {
  0% { 
    box-shadow: 0 8px 35px rgba(0, 0, 0, 0.25);
    border-color: rgba(102, 126, 234, 0.8);
  }
  100% { 
    box-shadow: 0 12px 45px rgba(0, 0, 0, 0.35);
    border-color: rgba(102, 126, 234, 1);
  }
}
#chat-label.shake {
  animation: shake-label 0.6s ease-in-out;
}

@keyframes shake-label {
  0%, 100% { transform: translateY(0) scale(1); }
  25%, 75% { transform: translateY(0) translateX(-2px) scale(1.01); }
  50% { transform: translateY(0) translateX(2px) scale(1.01); }
}
#chat-button {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--button-gradient);
  box-shadow: 0 8px 25px var(--shadow-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  outline: none;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  animation: gentle-pulse 3s ease-in-out infinite;
}

@keyframes gentle-pulse {
  0%, 100% { 
    transform: scale(1);
    box-shadow: 0 8px 25px var(--shadow-medium);
  }
  50% { 
    transform: scale(1.02);
    box-shadow: 0 12px 35px var(--shadow-heavy);
  }
}

#chat-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%);
  border-radius: 50%;
  transition: opacity var(--transition-fast);
  opacity: 0;
}

#chat-button:hover, #chat-button:focus {
  transform: scale(1.08);
  box-shadow: 0 15px 40px var(--shadow-heavy);
}

#chat-button:hover::before {
  opacity: 1;
}

#chat-button:active {
  transform: scale(0.95);
  transition: transform var(--transition-fast);
}
.chat-header svg {
	width: 30px;
	color: #fafafa;
}
.chat-icon-wrapper svg {
	width: 30px;
}
.chat-icon-wrapper {
  z-index: 2;
  color: #fafafa;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transition: transform var(--transition);
}

.chat-icon-wrapper.animate {
  animation: icon-bounce 0.6s ease-out;
}

@keyframes icon-bounce {
  0% { transform: scale(1); }
  30% { transform: scale(1.15); }
  50% { transform: scale(0.9); }
  70% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

#chat-button box-icon {
  width: 28px;
  height: 28px;
  color: #ffffff;
  fill: #ffffff;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.1));
}

.chat-loading-placeholder {
  padding: 16px 20px;
  margin: 12px 16px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, #f0f2f5 25%, #e4e6ea 50%, #f0f2f5 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  min-height: 20px;
  position: relative;
  overflow: hidden;
}

.chat-loading-placeholder::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 20px;
  right: 20px;
  height: 8px;
  background: #e4e6ea;
  border-radius: 4px;
  transform: translateY(-50%);
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

#chat-window {
  position: fixed;
  bottom: calc(24px + 64px + 16px);
  right: 24px;
  width: var(--chat-width);
  /* Instead of max-height, use both top and bottom positioning */
  top: calc(var(--site-header-height) + 24px); /* Minimum distance from sticky header */
  max-height: none; /* Remove max-height since we're using top/bottom positioning */
  background: var(--bot-message-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px var(--shadow-heavy);
  display: flex;
  flex-direction: column;
  transform: translateY(30px) scale(0.9);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-slow);
  z-index: 9000;
  overflow: hidden;
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
}

#chat-window.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  visibility: visible;
}

.chat-header {
  height: var(--header-height);
  background: var(--button-gradient);
  color: #ffffff;
  font-weight: 600;
  font-size: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  flex-shrink: 0;
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  letter-spacing: 0.025em;
  position: relative;
  overflow: hidden;
}

.chat-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transform: translateX(-100%);
  animation: header-shine 3s ease-in-out infinite;
}

@keyframes header-shine {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(100%); }
  100% { transform: translateX(100%); }
}

#close-chat {
  cursor: pointer;
  color: #fafafa;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #ffffff;
  border-radius: 50%;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
}

#close-chat:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(90deg) scale(1.1);
}

.chat-messages {
  flex: 1;
  padding: 20px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--secondary-color);
  scroll-behavior: smooth;
  min-height: 300px;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
  transition: background var(--transition);
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--text-light);
}

.message {
  font-size: 0.95rem;
  line-height: 1.5;
  padding: 14px 18px;
  border-radius: var(--radius);
  max-width: 85%;
  word-wrap: break-word;
  position: relative;
  animation: message-appear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  backdrop-filter: blur(10px);
}

@keyframes message-appear {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.9);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.message.user {
  align-self: flex-end;
  background: var(--user-gradient);
  color: #ffffff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.25);
  position: relative;
}

.message.user::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: -8px;
  width: 0;
  height: 0;
  border: 8px solid transparent;
  border-bottom-color: var(--user-message-color);
  border-right: 0;
  border-bottom-right-radius: 4px;
}

.message.bot {
  align-self: flex-start;
  background: var(--bot-gradient);
  color: var(--text-color);
  border-bottom-left-radius: 6px;
  box-shadow: 0 4px 15px var(--shadow-light);
  border: 1px solid var(--border-color);
  position: relative;
}

.message.bot::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: -8px;
  width: 0;
  height: 0;
  border: 8px solid transparent;
  border-bottom-color: var(--bot-message-color);
  border-left: 0;
  border-bottom-left-radius: 4px;
}

@media (prefers-color-scheme: dark) {
  .message.bot::after {
    border-bottom-color: #2d3748;
  }
}

#chat-window li {
  display: list-item;
  margin: 4px 0;
}

#chat-window ul {
  margin: 8px 0;
  padding-left: 20px;
}

#chat-window p {
  line-height: 1.5;
  margin: 8px 0;
}

#chat-window p:first-child {
  margin-top: 0;
}

#chat-window p:last-child {
  margin-bottom: 0;
}

.chat-instruction {
  text-align: center;
  padding: 20px 24px;
  margin: 16px;
  background: linear-gradient(135deg, #e6f3ff 0%, #f0f8ff 100%);
  color: var(--primary-color);
  border: 2px solid rgba(102, 126, 234, 0.1);
  border-radius: var(--radius);
  font-weight: 500;
  animation: instruction-glow 2s ease-in-out infinite alternate;
}

@keyframes instruction-glow {
  0% { box-shadow: 0 0 20px rgba(102, 126, 234, 0.1); }
  100% { box-shadow: 0 0 30px rgba(102, 126, 234, 0.2); }
}

.chat-instruction.error {
  background: linear-gradient(135deg, #ffe6e6 0%, #fff0f0 100%);
  color: var(--error-color);
  border-color: rgba(245, 101, 101, 0.2);
}

.chat-input {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--border-color);
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(20px);
  flex-shrink: 0;
  gap: 12px;
}

.chat-input input {
  flex: 1;
  border: 2px solid var(--border-color);
  padding: 12px 16px;
  font-size: 0.95rem;
  border-radius: 25px;
  background: var(--bot-message-color);
  outline: none;
  transition: all var(--transition);
  color: var(--text-color);
}

.chat-input input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  transform: scale(1.02);
}

.chat-input input::placeholder {
  color: var(--text-light);
}

.chat-input button {
  border: none;
  background: var(--button-gradient);
  color: #ffffff;
  padding: 12px;
  border-radius: 50%;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
  cursor: pointer;
  width: 48px;
  height: 48px;
  position: relative;
  overflow: hidden;
}

.chat-input button::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.3) 0%, transparent 50%);
  border-radius: 50%;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.chat-input button:hover, .chat-input button:focus {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.chat-input button:hover::before {
  opacity: 1;
}

.chat-input button:active {
  transform: scale(0.95);
}

.chat-input button box-icon {
  width: 20px;
  height: 20px;
  color: #ffffff;
  fill: #ffffff;
  z-index: 1;
}

.typing-indicator {
  background: var(--bot-gradient);
  padding: 16px 20px;
  border-radius: var(--radius);
  max-width: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  align-self: flex-start;
  box-shadow: 0 4px 15px var(--shadow-light);
  border: 1px solid var(--border-color);
  position: relative;
}

.typing-indicator::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: -8px;
  width: 0;
  height: 0;
  border: 8px solid transparent;
  border-bottom-color: var(--bot-message-color);
  border-left: 0;
  border-bottom-left-radius: 4px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--primary-color);
  border-radius: 50%;
  display: inline-block;
  animation: typing-pulse 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
.typing-indicator span:nth-child(3) { animation-delay: 0s; }

@keyframes typing-pulse {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1.2);
    opacity: 1;
  }
}

@media (max-width: 768px) {
.chat-wrapper {
    left: 0;
    right: 0;
    bottom: 16px;
    max-width: calc(100vw - 32px);
    margin: 0 auto;
  }
  
  #chat-window {
  width: calc(100vw - 32px);
  max-width: none;
  right: 16px;
  bottom: calc(16px + 56px + 16px);
  /* Updated max-height for mobile to account for sticky header */
  max-height: calc(100vh - var(--site-header-height) - 16px - 56px - 16px - 24px);
  border-radius: var(--radius);
}
  
  .chat-header {
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 0 16px;
  }
  
  .chat-messages {
    padding: 16px 12px;
    gap: 12px;
    min-height: 250px;
  }
  
  .chat-input {
    padding: 12px 16px;
  }
  
  .chat-input input {
    font-size: 16px;
  }
  
  #chat-button {
    width: 56px;
    height: 56px;
  }
  
  #chat-button box-icon {
    width: 24px;
    height: 24px;
  }
}

@media (max-width: 480px) {
#chat-window {
  width: calc(100vw - 16px);
  right: 8px;
  bottom: calc(8px + 56px + 12px);
  /* Updated max-height for small mobile to account for sticky header */
  max-height: calc(100vh - var(--site-header-height) - 8px - 56px - 12px - 16px);
  border-radius: var(--radius-sm);
}
  
  .chat-header {
    height: 48px;
    font-size: 0.9rem;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  }
  
  .message {
    font-size: 0.9rem;
    padding: 12px 16px;
    max-width: 90%;
  }
  
  .chat-instruction {
    padding: 16px 20px;
    margin: 12px;
    font-size: 0.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}