/* CSS Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
}

/* DSL Color Scheme - Based on Daffodil Software Ltd Logo */
:root {
  --dsl-blue: #2563eb;
  /* Primary Blue from logo */
  --dsl-red: #dc2626;
  /* Red from logo */
  --dsl-green: #16a34a;
  /* Green from logo */
  --dsl-dark: #1f2937;
  /* Dark gray/black */
  --dsl-dark-alt: #111827;
  /* Darker shade */
  --dsl-light-bg: #f9fafb;
  --dsl-border: #e5e7eb;
  --dsl-text: #374151;
  --dsl-text-light: #6b7280;
  --dsl-white: #ffffff;
  --dsl-yellow: #eab308;
  /* Accent color */
}

/* Chatbot Toggle Button */
.chatbot-toggle {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 4rem;
  height: 4rem;
  background: linear-gradient(135deg, var(--dsl-blue) 0%, var(--dsl-dark) 100%);
  color: var(--dsl-white);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 1000;
}

.chatbot-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
}

.chatbot-toggle .icon-comments {
  width: 1.75rem;
  height: 1.75rem;
}

/* Chatbot Window */
.chatbot-window {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  width: calc(100vw - 2rem);
  max-width: 28rem;
  height: calc(100vh - 2rem);
  max-height: 700px;
  background: var(--dsl-white);
  border-radius: 1rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  border: 1px solid var(--dsl-border);
  animation: slideIn 0.3s ease-out;
}

.chatbot-window.hidden {
  display: none;
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Header */
.chatbot-header {
  background: linear-gradient(135deg, var(--dsl-dark) 0%, var(--dsl-blue) 100%);
  color: var(--dsl-white);
  padding: 1rem 1.25rem;
  border-radius: 1rem 1rem 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-icon {
  width: 2rem;
  height: 2rem;
  background: var(--dsl-white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-icon svg {
  width: 1.25rem;
  height: 1.25rem;
  stroke: var(--dsl-blue);
}

.header-title {
  font-size: 1.125rem;
  font-weight: 700;
}

.header-actions {
  display: flex;
  gap: 0.25rem;
}

.header-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  padding: 0.25rem;
  transition: color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-btn:hover {
  color: var(--dsl-white);
}

.header-btn svg {
  width: 1.25rem;
  height: 1.25rem;
}

.header-btn.hidden {
  display: none;
}

/* Content Area */
.chatbot-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  background: var(--dsl-light-bg);
}

.chatbot-content::-webkit-scrollbar {
  width: 6px;
}

.chatbot-content::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-content::-webkit-scrollbar-thumb {
  background: var(--dsl-border);
  border-radius: 3px;
}

.chatbot-content::-webkit-scrollbar-thumb:hover {
  background: var(--dsl-text-light);
}

/* Authentication Form */
.auth-form {
  background: var(--dsl-white);
  padding: 1.5rem;
  border-radius: 0.75rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  border: 1px solid var(--dsl-border);
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--dsl-dark);
  margin-bottom: 0.5rem;
}

.auth-subtitle {
  color: var(--dsl-text-light);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--dsl-text);
  margin-bottom: 0.375rem;
}

.form-group input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--dsl-border);
  border-radius: 0.5rem;
  font-size: 0.95rem;
  transition: all 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--dsl-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn-submit {
  width: 100%;
  padding: 0.75rem;
  background: linear-gradient(135deg, var(--dsl-blue) 0%, var(--dsl-dark) 100%);
  color: var(--dsl-white);
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  margin-top: 0.5rem;
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(37, 99, 235, 0.3);
}

/* Chat Messages */
.chat-messages {
  flex-direction: column;
  gap: 1rem;
}

.message {
  display: flex;
  animation: fadeIn 0.3s ease-out;
  margin-bottom: 0;
  padding: 0;
}

.message.user {
  justify-content: flex-end;
}

.message.ai {
  justify-content: flex-start;
}

.message-bubble {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  font-size: 0.95rem;
  line-height: 1.5;
  word-wrap: break-word;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}

.message.user .message-bubble {
  background: linear-gradient(135deg, var(--dsl-blue) 0%, var(--dsl-dark) 100%);
  color: var(--dsl-white);
  border-top-right-radius: 0.25rem;
}

.message.ai .message-bubble {
  background: var(--dsl-white);
  color: var(--dsl-text);
  border-top-left-radius: 0.25rem;
  border: 1px solid var(--dsl-border);
}

.message-bubble strong {
  font-weight: 600;
}

.related-links {
  margin-top: 0.75rem;
  font-size: 0.875rem;
}

.related-links p {
  font-weight: 600;
  color: var(--dsl-dark);
  margin-bottom: 0.375rem;
}

.related-links ul {
  list-style: none;
  margin-top: 0.375rem;
  padding-left: 0;
}

.related-links li {
  display: flex;
  align-items: flex-start;
  margin-bottom: 0.375rem;
}

.related-links li span {
  margin-right: 0.5rem;
  color: var(--dsl-text-light);
}

.related-links a {
  color: var(--dsl-blue);
  text-decoration: none;
  word-break: break-all;
  transition: color 0.2s;
}

.related-links a:hover {
  color: var(--dsl-red);
  text-decoration: underline;
}

/* Loading Indicator */
.loading-message {
  display: flex;
  justify-content: flex-start;
  margin-top: 0.5rem;
}

.loading-bubble {
  background: var(--dsl-white);
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  border-top-left-radius: 0.25rem;
  border: 1px solid var(--dsl-border);
  display: flex;
  gap: 0.375rem;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}

.loading-dot {
  width: 0.5rem;
  height: 0.5rem;
  background: var(--dsl-text-light);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
  margin: 0;
  padding: 0;
}

.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);
    opacity: 0.5;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Error Message */
.error-message {
  background: #fef2f2;
  color: var(--dsl-red);
  padding: 0.75rem;
  border-radius: 0.5rem;
  text-align: center;
  font-size: 0.875rem;
  border: 1px solid #fecaca;
  margin-top: 1rem;
}

/* Input Area */
.chat-input-area {
  border-top: 1px solid var(--dsl-border);
  padding: 1rem;
  background: var(--dsl-white);
  border-radius: 0 0 1rem 1rem;
  flex-shrink: 0;
}

/* Common Questions */
.common-questions {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
  scrollbar-width: thin;
}

.common-questions::-webkit-scrollbar {
  height: 4px;
}

.common-questions::-webkit-scrollbar-track {
  background: transparent;
}

.common-questions::-webkit-scrollbar-thumb {
  background: var(--dsl-border);
  border-radius: 2px;
}

.question-btn {
  padding: 0.5rem 0.75rem;
  background: var(--dsl-light-bg);
  border: 1px solid var(--dsl-border);
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--dsl-text);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}

.question-btn:hover {
  background: var(--dsl-blue);
  color: var(--dsl-white);
  border-color: var(--dsl-blue);
}

/* Message Form */
.message-form {
  display: flex;
  gap: 0.5rem;
  position: relative;
}

.message-form input {
  flex: 1;
  padding: 0.75rem 3rem 0.75rem 1rem;
  border: 1px solid var(--dsl-border);
  border-radius: 0.5rem;
  font-size: 0.95rem;
  transition: all 0.2s;
}

.message-form input:focus {
  outline: none;
  border-color: var(--dsl-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.message-form input:disabled {
  background: var(--dsl-light-bg);
  cursor: not-allowed;
}

.send-btn {
  position: absolute;
  right: 0.375rem;
  top: 50%;
  transform: translateY(-50%);
  background: var(--dsl-blue);
  color: var(--dsl-white);
  border: none;
  border-radius: 0.5rem;
  width: 2.5rem;
  height: 2.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.send-btn:hover:not(:disabled) {
  background: var(--dsl-dark);
}

.send-btn:disabled {
  background: var(--dsl-border);
  cursor: not-allowed;
}

.send-btn .icon-send {
  width: 1.25rem;
  height: 1.25rem;
}

/* Loading Spinner */
.spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--dsl-white);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Responsive Design */
@media (max-width: 640px) {
  .chatbot-toggle {
    width: 3.5rem;
    height: 3.5rem;
    bottom: 1rem;
    right: 1rem;
  }

  .chatbot-toggle .icon-comments {
    width: 1.5rem;
    height: 1.5rem;
  }

  .chatbot-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    margin: 0;
  }

  .chatbot-header {
    border-radius: 0;
  }

  .chat-input-area {
    border-radius: 0;
  }

  .header-title {
    font-size: 1rem;
  }

  .question-btn {
    font-size: 0.75rem;
    padding: 0.375rem 0.625rem;
  }
}

/* Icon Utilities */
.icon-small {
  width: 1.25rem;
  height: 1.25rem;
}

svg {
  display: block;
}