/* ========================================
   CHATBOT STYLES
   ======================================== */

/* Chat Button - Floating */
.chat-button {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--accent-color), #4a7bc8);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1), 0 4px 16px rgba(87, 143, 202, 0.3);
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.5rem;
}

.chat-button:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15),
    0 6px 20px rgba(87, 143, 202, 0.4);
}

.chat-button.active {
  background: linear-gradient(135deg, #ec5228, #ff6b47);
  transform: rotate(45deg);
}

/* Chat Modal Overlay */
.chat-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  z-index: 1001;
  display: none;
  transition: all 0.3s ease;
}

.chat-overlay.active {
  display: block;
  opacity: 1;
}

/* Chat Modal */
.chat-modal {
  position: fixed;
  bottom: 100px;
  right: 30px;
  width: 400px;
  height: 600px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1), 0 10px 30px rgba(0, 0, 0, 0.05);
  backdrop-filter: blur(20px);
  display: none;
  flex-direction: column;
  transform: translateY(30px) scale(0.95);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  z-index: 1002;
}

[data-theme="dark"] .chat-modal {
  background: rgba(26, 28, 34, 0.95);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.2);
}

.chat-modal.active {
  display: flex;
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* Chat Header */
.chat-header {
  padding: 20px 25px;
  background: linear-gradient(135deg, var(--accent-color), #4a7bc8);
  color: white;
  border-radius: 20px 20px 0 0;
  position: relative;
}

.chat-header h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.chat-header p {
  margin: 5px 0 0 0;
  font-size: 0.9rem;
  opacity: 0.9;
}

.chat-close {
  position: absolute;
  top: 15px;
  right: 20px;
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.chat-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Chat Messages Container */
.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
  scroll-behavior: smooth;
}

/* Custom Scrollbar */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.2);
}

/* Message Bubbles */
.message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.4;
  animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* User Messages */
.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #ec5228, #ff6b47);
  color: white;
  margin-left: auto;
}

/* Bot Messages */
.message.bot {
  align-self: flex-start;
  background: rgba(87, 143, 202, 0.1);
  color: var(--text-color);
  border: 1px solid rgba(87, 143, 202, 0.2);
}

[data-theme="dark"] .message.bot {
  background: rgba(87, 143, 202, 0.15);
  border-color: rgba(87, 143, 202, 0.3);
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(87, 143, 202, 0.1);
  border: 1px solid rgba(87, 143, 202, 0.2);
  border-radius: 18px;
  max-width: 85%;
  align-self: flex-start;
}

[data-theme="dark"] .typing-indicator {
  background: rgba(87, 143, 202, 0.15);
  border-color: rgba(87, 143, 202, 0.3);
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--accent-color);
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Chat Input Area */
.chat-input-area {
  padding: 20px;
  border-top: 1px solid var(--border-color);
  background: var(--card-bg);
  backdrop-filter: blur(10px);
}

[data-theme="dark"] .chat-input-area {
  background: rgba(26, 28, 34, 0.9);
}

.chat-input-container {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  font-size: 0.95rem;
  background: var(--bg-color);
  color: var(--text-color);
  backdrop-filter: blur(10px);
  resize: none;
  max-height: 100px;
  min-height: 44px;
  transition: all 0.2s ease;
}

.chat-input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(87, 143, 202, 0.1);
}

.chat-input::placeholder {
  color: var(--text-color);
  opacity: 0.6;
}

/* Send Button */
.chat-send {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--accent-color), #4a7bc8);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.chat-send:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(87, 143, 202, 0.3);
}

.chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Quick Actions */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding: 0;
}

.quick-action {
  padding: 6px 10px;
  background: rgba(87, 143, 202, 0.1);
  border: 1px solid rgba(87, 143, 202, 0.2);
  border-radius: 15px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--accent-color);
  white-space: nowrap;
  flex-shrink: 0;
}

[data-theme="dark"] .quick-action {
  background: rgba(87, 143, 202, 0.15);
  border-color: rgba(87, 143, 202, 0.3);
}

.quick-action:hover {
  background: rgba(87, 143, 202, 0.2);
  transform: translateY(-1px);
}

[data-theme="dark"] .quick-action:hover {
  background: rgba(87, 143, 202, 0.25);
}

/* Status Messages */
.status-message {
  text-align: center;
  padding: 10px;
  font-size: 0.85rem;
  color: var(--text-color);
  opacity: 0.7;
  font-style: italic;
}

.status-message.error {
  color: #ec5228;
  opacity: 1;
}

.status-message.success {
  color: var(--accent-color);
  opacity: 1;
}

/* Mobile Responsiveness */
@media (max-width: 767px) {
  .chat-button {
    bottom: 20px;
    right: 20px;
    width: 55px;
    height: 55px;
    font-size: 1.3rem;
  }

  .chat-modal {
    bottom: 85px;
    right: 15px;
    left: 15px;
    width: auto;
    height: 70vh;
    max-height: 500px;
    /* Keyboard-aware positioning */
    height: 70dvh; /* Dynamic viewport height for mobile keyboards */
    max-height: min(500px, 70dvh);
  }

  .chat-header {
    padding: 15px 20px;
  }

  .chat-header h3 {
    font-size: 1.1rem;
  }

  .chat-messages {
    padding: 15px;
  }

  .message {
    font-size: 0.9rem;
    max-width: 90%;
  }

  .chat-input-area {
    padding: 15px;
  }
}

@media (max-width: 480px) {
  .chat-modal {
    height: 75vh;
    height: 75dvh; /* Dynamic viewport height for keyboards */
    bottom: 75px;
    min-height: 300px;
    max-height: calc(100dvh - 150px);
  }

  /* Keyboard-specific adjustments */
  .chat-modal.active {
    height: calc(100dvh - 150px);
  }

  .chat-input-area {
    position: sticky;
    bottom: 0;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    z-index: 10;
  }

  .quick-actions {
    gap: 6px;
  }

  .quick-action {
    font-size: 0.8rem;
    padding: 6px 10px;
  }
}

/* Keyboard support for all mobile devices */
@media (max-height: 500px) {
  .chat-modal {
    height: 90vh !important;
    height: 90dvh !important;
    bottom: 10px !important;
    top: auto !important;
  }

  .chat-messages {
    max-height: 200px;
    overflow-y: auto;
  }
}

/* Additional dark theme enhancements */
[data-theme="dark"] .chat-button {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(87, 143, 202, 0.4);
}

[data-theme="dark"] .chat-button:hover {
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(87, 143, 202, 0.5);
}

[data-theme="dark"] .chat-overlay {
  background: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}
