/**
 * NACD Chatbot Styles
 */

.nacd-chatbot-modal {
  display: none;
  position: fixed;
  top: 100px;
  bottom: 88px;
  right: 20px;
  left: auto;
  z-index: 1050;
  width: 380px;
  max-width: 90vw;
  height: auto;
  max-height: none;
  background: white;
  border-radius: 15px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.nacd-chatbot-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.nacd-chatbot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  background-color: #8cabba;
  color: white;
  border-top-left-radius: 15px;
  border-top-right-radius: 15px;
  flex-shrink: 0;
}

.nacd-chatbot-header h5 {
  margin: 0;
  font-size: 1.25rem;
}

.nacd-close-btn {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.nacd-chatbot-body {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
  overflow-x: hidden;
  background-color: #f8f9fa;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nacd-chat-message {
  display: flex;
  max-width: 92%;
  width: fit-content;
}

.nacd-bot-message {
  align-self: flex-start;
}

.nacd-user-message {
  align-self: flex-end;
}

.nacd-message-bubble {
  width: 100%;
  padding: 12px 15px;
  border-radius: 18px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  line-height: 1.6;
  font-size: 0.95rem;
}

.nacd-bot-message .nacd-message-bubble {
  background-color: #e3d1b0;
  color: var(--color-ink);
}

.nacd-user-message .nacd-message-bubble {
  background-color: #91b094;
  color: white;
}

.nacd-message-content {
  display: block;
  background: transparent;
  padding: 0;
  border-radius: 0;
}

.nacd-user-message .nacd-message-content {
  white-space: pre-wrap;
}

.nacd-chatbot-footer {
  padding: 10px 15px;
  border-top: 1px solid #dee2e6;
  flex-shrink: 0;
  background: white;
}

.nacd-chat-input-group {
  display: flex;
  align-items: stretch;
  gap: 0;
  border: 1px solid #ced4da;
  border-radius: 24px;
  overflow: hidden;
  background: #fff;
  min-height: 46px;
}

.nacd-chat-input {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  border: none;
  border-radius: 0;
  outline: none;
  background: transparent;
  font-size: 0.95rem;
  line-height: 1.4;
}

html[dir="ltr"] .nacd-chat-input-group {
  flex-direction: row;
}

html[dir="ltr"] .nacd-chat-input {
  text-align: left;
  direction: ltr;
}

html[dir="rtl"] .nacd-chat-input-group {
  flex-direction: row-reverse;
}

html[dir="rtl"] .nacd-chat-input {
  text-align: right;
  direction: rtl;
}

.nacd-chat-send-btn {
  position: static;
  flex-shrink: 0;
  width: 46px;
  min-width: 46px;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: #8cabba;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}

.nacd-chat-send-btn:hover {
  background: transparent;
  color: #6a8fa1;
}

.nacd-chat-send-btn i {
  font-size: 1rem;
  line-height: 1;
}

html[dir="rtl"] .nacd-chat-send-btn i {
  transform: scaleX(-1);
}

.nacd-typing-indicator {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 15px;
  background-color: #e3d1b0;
  border-radius: 18px;
}

.nacd-typing-indicator span {
  height: 8px;
  width: 8px;
  background-color: #8cabba;
  border-radius: 50%;
  opacity: 0.4;
}

.nacd-typing-indicator span:nth-of-type(1) {
  animation: nacd-typing 1s infinite;
}

.nacd-typing-indicator span:nth-of-type(2) {
  animation: nacd-typing 1s 0.33s infinite;
}

.nacd-typing-indicator span:nth-of-type(3) {
  animation: nacd-typing 1s 0.66s infinite;
}

@keyframes nacd-typing {
  0% { opacity: 0.4; }
  50% { opacity: 1; }
  100% { opacity: 0.4; }
}

/* Bot message typography */
.nacd-bot-message .nacd-message-content p {
  margin: 0 0 10px;
}

.nacd-bot-message .nacd-message-content p:last-child {
  margin-bottom: 0;
}

.nacd-bot-message .nacd-message-content ul,
.nacd-bot-message .nacd-message-content ol {
  margin: 8px 0 10px;
  padding-left: 20px;
}

.nacd-bot-message .nacd-message-content li {
  margin-bottom: 4px;
}

.nacd-bot-message .nacd-message-content a {
  color: #4f7381;
  font-weight: 600;
  text-decoration: underline;
  word-break: break-word;
}

.nacd-bot-message .nacd-message-content a:hover {
  color: #35515d;
}

.nacd-bot-message .nacd-message-content code {
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 4px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.9em;
}

.nacd-bot-message .nacd-message-content pre {
  background: rgba(0, 0, 0, 0.06);
  padding: 10px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 10px 0;
}

.nacd-bot-message .nacd-message-content pre code {
  background: transparent;
  padding: 0;
}

.nacd-bot-message .nacd-message-content h1,
.nacd-bot-message .nacd-message-content h2,
.nacd-bot-message .nacd-message-content h3,
.nacd-bot-message .nacd-message-content h4,
.nacd-bot-message .nacd-message-content h5,
.nacd-bot-message .nacd-message-content h6 {
  margin: 10px 0 6px;
  font-weight: 700;
  line-height: 1.3;
}

.nacd-bot-message .nacd-message-content blockquote {
  border-left: 3px solid #8cabba;
  margin: 10px 0;
  padding-left: 10px;
  color: #555;
}

.nacd-bot-message .nacd-message-content hr {
  border: none;
  border-top: 1px solid rgba(79, 115, 129, 0.25);
  margin: 12px 0;
}

/* Related pages — inside the bubble */
.nacd-chat-sources {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(79, 115, 129, 0.22);
}

.nacd-chat-sources-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #4f7381;
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}

.nacd-chat-source-link {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  padding: 8px 10px;
  background-color: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(79, 115, 129, 0.15);
  border-radius: 10px;
  color: #4f7381;
  text-decoration: none;
  font-size: 0.88rem;
  line-height: 1.4;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.nacd-chat-source-link:last-child {
  margin-bottom: 0;
}

.nacd-chat-source-link::before {
  content: "↗";
  flex-shrink: 0;
  font-size: 0.85rem;
  opacity: 0.75;
}

.nacd-chat-source-link:hover {
  background-color: rgba(255, 255, 255, 0.85);
  border-color: rgba(79, 115, 129, 0.35);
  color: #35515d;
}

html[dir="ltr"] .nacd-bot-message .nacd-message-content {
  text-align: left;
  direction: ltr;
}

html[dir="rtl"] .nacd-bot-message .nacd-message-content {
  text-align: right;
  direction: rtl;
}

html[dir="rtl"] .nacd-bot-message .nacd-message-content ul,
html[dir="rtl"] .nacd-bot-message .nacd-message-content ol {
  padding-right: 20px;
  padding-left: 0;
}

html[dir="rtl"] .nacd-bot-message .nacd-message-content blockquote {
  border-left: none;
  border-right: 3px solid #8cabba;
  padding-left: 0;
  padding-right: 10px;
}

html[dir="rtl"] .nacd-chat-sources-title {
  text-align: right;
}

html[dir="rtl"] .nacd-chat-source-link {
  flex-direction: row-reverse;
  text-align: right;
}

html[dir="rtl"] .nacd-chat-source-link::before {
  content: "↖";
}

@media (max-width: 576px) {
  .nacd-chatbot-modal {
    top: 80px;
    bottom: 82px;
    right: 4vw;
    left: 4vw;
    width: auto;
    max-width: none;
  }

  .nacd-chat-message {
    max-width: 95%;
  }
}
