/* Global Page Loader */
#page-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #2d6a4f 0%, #40916c 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  opacity: 1;
  transition: opacity 0.5s ease;
}

#page-loader.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loader-content {
  text-align: center;
  color: white;
}

.loader-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255,255,255,0.3);
  border-top: 4px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

.loader-text {
  font-size: 18px;
  font-weight: 600;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* Global Chat Styles */
#chat-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 65px;
  height: 65px;
  background: linear-gradient(135deg, #2d6a4f 0%, #40916c 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9998;
  color: white;
  font-size: 26px;
  box-shadow: 0 6px 20px rgba(45,106,79,0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 3px solid rgba(255,255,255,0.2);
  animation: chatPulse 3s ease-in-out infinite;
}

#chat-btn:hover {
  transform: scale(1.15) translateY(-3px);
  box-shadow: 0 12px 30px rgba(45,106,79,0.6);
  animation: none;
}

@keyframes chatPulse {
  0%, 100% { box-shadow: 0 6px 20px rgba(45,106,79,0.4); }
  50% { box-shadow: 0 6px 20px rgba(45,106,79,0.4), 0 0 0 10px rgba(45,106,79,0.1); }
}

#chat-window {
  position: fixed;
  bottom: 95px;
  right: 20px;
  width: 400px;
  height: 500px;
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  display: none;
  flex-direction: column;
  z-index: 9999;
  border: 2px solid rgba(45,106,79,0.2);
  backdrop-filter: blur(20px);
  transform: scale(0.8) translateY(20px);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#chat-window.show {
  transform: scale(1) translateY(0);
  opacity: 1;
}

#chat-header {
  background: linear-gradient(135deg, #2d6a4f 0%, #40916c 100%);
  color: white;
  padding: 20px;
  border-radius: 18px 18px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 16px;
  box-shadow: 0 2px 10px rgba(45,106,79,0.2);
}

#chat-close {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  font-size: 22px;
  cursor: pointer;
  width: 35px;
  height: 35px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

#chat-close:hover {
  background: rgba(255,255,255,0.3);
  transform: rotate(90deg) scale(1.1);
}

#chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#chat-messages::-webkit-scrollbar {
  width: 6px;
}

#chat-messages::-webkit-scrollbar-track {
  background: rgba(45,106,79,0.1);
  border-radius: 10px;
}

#chat-messages::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #2d6a4f, #40916c);
  border-radius: 10px;
}

.bot-msg, .user-msg {
  padding: 14px 18px;
  border-radius: 20px;
  max-width: 85%;
  word-wrap: break-word;
  font-size: 14px;
  line-height: 1.5;
  animation: messageSlide 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.bot-msg {
  background: linear-gradient(135deg, #e8f5e8 0%, #f0f8f0 100%);
  color: #2d6a4f;
  align-self: flex-start;
  border-bottom-left-radius: 8px;
  box-shadow: 0 4px 15px rgba(45,106,79,0.1);
  border-left: 4px solid #40916c;
}

.user-msg {
  background: linear-gradient(135deg, #2d6a4f 0%, #40916c 100%);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 8px;
  box-shadow: 0 4px 15px rgba(45,106,79,0.3);
}

#chat-input-area {
  padding: 20px;
  border-top: 1px solid rgba(45,106,79,0.1);
  display: flex;
  gap: 12px;
  align-items: center;
  background: rgba(255,255,255,0.8);
  border-radius: 0 0 18px 18px;
}

#chat-input {
  flex: 1;
  padding: 14px 18px;
  border: 2px solid rgba(45,106,79,0.2);
  border-radius: 25px;
  outline: none;
  font-size: 14px;
  transition: all 0.3s ease;
  background: rgba(255,255,255,0.9);
}

#chat-input:focus {
  border-color: #2d6a4f;
  box-shadow: 0 0 0 4px rgba(45,106,79,0.1);
  transform: translateY(-1px);
}

#chat-send {
  background: linear-gradient(135deg, #2d6a4f 0%, #40916c 100%);
  color: white;
  border: none;
  padding: 14px 20px;
  border-radius: 25px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 15px rgba(45,106,79,0.3);
}

#chat-send:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 8px 25px rgba(45,106,79,0.4);
}

.typing-indicator {
  display: none;
  align-self: flex-start;
  padding: 14px 18px;
  background: linear-gradient(135deg, #f1f3f4 0%, #e8eaed 100%);
  border-radius: 20px;
  border-bottom-left-radius: 8px;
  color: #666;
  font-style: italic;
  animation: typingPulse 1.5s ease-in-out infinite;
}

.typing-indicator.show {
  display: flex;
  align-items: center;
  gap: 8px;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: #666;
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

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

@keyframes messageSlide {
  from {
    opacity: 0;
    transform: translateY(15px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes typingPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-10px); }
}

/* Mobile Responsive */
@media (max-width: 480px) {
  #chat-window {
    width: calc(100vw - 30px);
    height: calc(100vh - 140px);
    bottom: 85px;
    right: 15px;
    left: 15px;
    max-height: calc(100vh - 140px);
  }
  
  #chat-btn {
    bottom: 15px;
    right: 15px;
    width: 55px;
    height: 55px;
    font-size: 22px;
  }
}