/* ========================================================================
   ANCESTORHONOR CHATBOT STYLES
   ======================================================================== */

/* Floating Chatbot Button */
#chatbot-button {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9998;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background-color: #5f8d73;
  color: white;
  box-shadow: 0 10px 25px rgba(95, 141, 115, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

#chatbot-button:hover {
  background-color: #4a705a;
  transform: scale(1.05);
  box-shadow: 0 15px 35px rgba(95, 141, 115, 0.4);
}

#chatbot-button:active {
  transform: scale(0.95);
}

#chatbot-button:focus {
  outline: 2px solid #5f8d73;
  outline-offset: 2px;
}

/* Chat Panel Container */
#chatbot-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
}

/* Chat Panel */
#chatbot-panel {
  width: 20rem;
  height: 24rem;
  background-color: white;
  border-radius: 1rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  border: 1px solid #e5e7eb;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: slideIn 0.3s ease-out;
}

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

#chatbot-panel.hidden {
  display: none;
}

/* Panel Header */
.chatbot-header {
  background-color: #5f8d73;
  color: white;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chatbot-header-info h3 {
  font-size: 0.875rem;
  font-weight: 600;
  margin: 0;
}

.chatbot-header-info p {
  font-size: 0.6875rem;
  opacity: 0.85;
  margin: 0.125rem 0 0 0;
}

#chatbot-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
  outline: none;
}

#chatbot-close:hover {
  color: white;
}

#chatbot-close:focus {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 0.25rem;
}

/* Messages Area */
#chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  background-color: #f9fafb;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Custom Scrollbar for Messages */
#chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

#chatbot-messages::-webkit-scrollbar-track {
  background: #f1f1f1;
}

#chatbot-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

#chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Message Bubbles */
.message-bubble {
  max-width: 85%;
  padding: 0.625rem 0.75rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.4;
  word-wrap: break-word;
  animation: fadeIn 0.2s ease-out;
}

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

.message-bubble.bot {
  background-color: white;
  color: #1f2937;
  align-self: flex-start;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.message-bubble.user {
  background-color: #5f8d73;
  color: white;
  align-self: flex-end;
  margin-left: auto;
}

/* Loading Indicator */
.loading-bubble {
  background-color: white;
  color: #1f2937;
  padding: 0.625rem 0.75rem;
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  max-width: 4rem;
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.loading-dot {
  width: 0.5rem;
  height: 0.5rem;
  background-color: #9ca3af;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

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

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

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

/* Input Area */
.chatbot-input-area {
  border-top: 1px solid #e5e7eb;
  padding: 0.5rem;
  background-color: white;
  flex-shrink: 0;
}

#chatbot-input {
  width: 100%;
  font-size: 0.875rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  padding: 0.5rem;
  resize: none;
  font-family: inherit;
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

#chatbot-input:focus {
  border-color: #5f8d73;
  box-shadow: 0 0 0 3px rgba(95, 141, 115, 0.1);
}

#chatbot-input:disabled {
  background-color: #f3f4f6;
  cursor: not-allowed;
}

#chatbot-send {
  margin-top: 0.5rem;
  width: 100%;
  background-color: #5f8d73;
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.5rem;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  transition:
    background-color 0.2s,
    transform 0.1s;
  outline: none;
}

#chatbot-send:hover:not(:disabled) {
  background-color: #4a705a;
}

#chatbot-send:active:not(:disabled) {
  transform: scale(0.98);
}

#chatbot-send:disabled {
  background-color: #9ca3af;
  cursor: not-allowed;
}

#chatbot-send:focus {
  outline: 2px solid #5f8d73;
  outline-offset: 2px;
}

/* Error Message Styling */
.message-bubble.error {
  background-color: #fef2f2;
  color: #991b1b;
  border-left: 3px solid #ef4444;
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
  #chatbot-container {
    bottom: 1rem;
    right: 1rem;
  }

  #chatbot-button {
    width: 3rem;
    height: 3rem;
  }

  #chatbot-panel {
    width: calc(100vw - 2rem);
    max-width: 20rem;
    height: 22rem;
  }
}

/* Very Small Screens */
@media (max-width: 380px) {
  #chatbot-panel {
    width: calc(100vw - 1.5rem);
    height: 20rem;
  }

  #chatbot-container {
    bottom: 0.75rem;
    right: 0.75rem;
  }

  #chatbot-button {
    width: 2.75rem;
    height: 2.75rem;
  }
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  #chatbot-button,
  #chatbot-panel,
  .message-bubble {
    animation: none;
    transition: none;
  }

  .loading-dot {
    animation: none;
  }
}

/* Print Styles - Hide Chatbot */
@media print {
  #chatbot-container,
  #chatbot-button {
    display: none !important;
  }
}
