/* static/css/chatbot.css — KinJo Elite Multi-Role AI Assistant / FAQ Chatbot Styles */

:root {
  --chatbot-primary: #002f6c; /* KinJo Navy */
  --chatbot-primary-hover: #001f48;
  --chatbot-primary-light: #eef3ff;
  --chatbot-accent: #c5a059; /* Soft Gold */
  --chatbot-accent-light: #fef8e6;
  --chatbot-bg: #ffffff;
  --chatbot-surface: #f8f9fc;
  --chatbot-border: #e2e8f0;
  --chatbot-text-main: #0f172a;
  --chatbot-text-muted: #64748b;
  --chatbot-user-msg-bg: #002f6c;
  --chatbot-user-msg-text: #ffffff;
  --chatbot-bot-msg-bg: #ffffff;
  --chatbot-bot-msg-text: #1e293b;
  --chatbot-shadow: 0 20px 30px -8px rgba(0, 47, 108, 0.18), 0 8px 12px -4px rgba(0, 47, 108, 0.1);
  --chatbot-radius: 20px;
  --chatbot-zindex: 1060;
}

/* Container */
.kinjo-chatbot-widget {
  position: fixed;
  bottom: 24px;
  inset-inline-end: 24px;
  z-index: var(--chatbot-zindex);
  font-family: inherit;
}

/* Floating Launcher Button */
.kinjo-chatbot-launcher {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, #00419d 100%);
  color: #ffffff;
  border: 2px solid rgba(197, 160, 89, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 20px -3px rgba(0, 47, 108, 0.4), 0 4px 6px -4px rgba(0, 47, 108, 0.2);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s ease;
  outline: none;
}

.kinjo-chatbot-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 16px 24px -3px rgba(0, 47, 108, 0.5), 0 6px 10px -4px rgba(0, 47, 108, 0.3);
  border-color: var(--chatbot-accent);
}

.kinjo-chatbot-launcher:focus-visible {
  outline: 3px solid var(--chatbot-accent);
  outline-offset: 3px;
}

.chatbot-launcher-icon {
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

.chatbot-icon-open {
  display: none;
}

.kinjo-chatbot-widget.is-open .chatbot-icon-closed {
  display: none;
}

.kinjo-chatbot-widget.is-open .chatbot-icon-open {
  display: inline-block;
}

/* Glowing Pulse Ring */
.chatbot-pulse-ring {
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  border: 2px solid var(--chatbot-accent);
  opacity: 0.8;
  animation: chatbot-pulse 2.5s cubic-bezier(0.24, 0, 0.38, 1) infinite;
  pointer-events: none;
}

.kinjo-chatbot-widget.is-open .chatbot-pulse-ring {
  display: none;
}

@keyframes chatbot-pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.22); opacity: 0; }
  100% { transform: scale(0.95); opacity: 0; }
}

.chatbot-unread-badge {
  position: absolute;
  top: -2px;
  inset-inline-end: -2px;
  background-color: #dc2626;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
}

/* Chatbot Dialog Window */
.kinjo-chatbot-window {
  position: absolute;
  bottom: 76px;
  inset-inline-end: 0;
  width: 420px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 110px);
  background: var(--chatbot-bg);
  border-radius: var(--chatbot-radius);
  border: 1px solid var(--chatbot-border);
  box-shadow: var(--chatbot-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.96);
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.25s;
}

.kinjo-chatbot-widget.is-open .kinjo-chatbot-window {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Header */
.chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, #00419d 100%);
  color: #ffffff;
  border-bottom: 2px solid var(--chatbot-accent);
}

.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chatbot-avatar-wrap {
  position: relative;
  width: 40px;
  height: 40px;
}

.chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border: 1.5px solid rgba(255, 255, 255, 0.3);
}

.chatbot-status-dot {
  position: absolute;
  bottom: 0;
  inset-inline-end: 0;
  width: 11px;
  height: 11px;
  background: #10b981;
  border-radius: 50%;
  border: 2px solid var(--chatbot-primary);
}

.chatbot-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chatbot-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  color: #ffffff;
}

.chatbot-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(197, 160, 89, 0.25);
  border: 1px solid var(--chatbot-accent);
  color: #fce7b2;
  font-size: 12px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
}

.chatbot-subtitle {
  font-size: 12px;
  opacity: 0.9;
  color: #e2e8f0;
  display: block;
  margin-top: 2px;
}

.chatbot-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chatbot-header-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s ease, transform 0.2s ease;
}

.chatbot-header-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.chatbot-header-btn:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

/* Role Selector Strip (User Persona Switcher) */
.chatbot-role-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--chatbot-surface);
  border-bottom: 1px solid var(--chatbot-border);
  overflow-x: auto;
  scrollbar-width: none;
}

.chatbot-role-selector::-webkit-scrollbar {
  display: none;
}

.chatbot-role-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--chatbot-text-muted);
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.chatbot-role-pills {
  display: flex;
  align-items: center;
  gap: 5px;
}

.chatbot-role-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--chatbot-text-muted);
  background: #ffffff;
  border: 1px solid var(--chatbot-border);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.chatbot-role-pill:hover {
  border-color: var(--chatbot-accent);
  color: var(--chatbot-primary);
}

.chatbot-role-pill.is-active {
  background: var(--chatbot-primary);
  color: #ffffff;
  border-color: var(--chatbot-primary);
  box-shadow: 0 2px 4px rgba(0, 47, 108, 0.18);
}

.chatbot-role-icon {
  font-size: 13px;
}

/* Messages Stream */
.chatbot-messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--chatbot-surface);
  scroll-behavior: smooth;
}

.chatbot-messages-container:focus-visible {
  outline: none;
}

/* Message Row & Avatar System */
.chatbot-msg-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 90%;
  animation: chatbot-msg-fade 0.25s ease forwards;
}

@keyframes chatbot-msg-fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.chatbot-msg-row.is-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chatbot-msg-row.is-bot {
  align-self: flex-start;
  flex-direction: row;
}

.chatbot-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.chatbot-bot-msg-avatar {
  background: #ffffff;
  color: var(--chatbot-primary);
  border: 1.5px solid var(--chatbot-accent);
}

.chatbot-user-msg-avatar {
  background: #ffffff;
  border: 1.5px solid var(--chatbot-primary);
}

.chatbot-msg-content-wrap {
  display: flex;
  flex-direction: column;
}

.chatbot-bubble {
  padding: 11px 15px;
  font-size: 13.5px;
  line-height: 1.55;
  border-radius: 16px;
  word-break: break-word;
}

.chatbot-bubble.user-bubble {
  background: var(--chatbot-user-msg-bg);
  color: var(--chatbot-user-msg-text);
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 47, 108, 0.15);
}

[dir="rtl"] .chatbot-bubble.user-bubble {
  border-bottom-right-radius: 16px;
  border-bottom-left-radius: 4px;
}

.chatbot-bubble.bot-bubble {
  background: var(--chatbot-bot-msg-bg);
  color: var(--chatbot-bot-msg-text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--chatbot-border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

[dir="rtl"] .chatbot-bubble.bot-bubble {
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 4px;
}

.chatbot-bubble strong {
  color: var(--chatbot-primary);
  font-weight: 700;
}

.chatbot-msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding-inline: 4px;
}

.chatbot-msg-row.is-user .chatbot-msg-meta {
  justify-content: flex-end;
}

.chatbot-time {
  font-size: 12px;
  color: var(--chatbot-text-muted);
}

.chatbot-copy-btn {
  background: none;
  border: none;
  color: var(--chatbot-text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 0 4px;
  opacity: 0.7;
  transition: opacity 0.2s ease, color 0.2s ease;
}

.chatbot-copy-btn:hover {
  opacity: 1;
  color: var(--chatbot-primary);
}

/* Action Links inside Bot Message */
.chatbot-actions-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--chatbot-border);
}

.chatbot-action-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--chatbot-primary);
  background: var(--chatbot-primary-light);
  border: 1px solid rgba(0, 47, 108, 0.15);
  border-radius: 8px;
  padding: 6px 12px;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
}

.chatbot-action-link:hover {
  background: var(--chatbot-primary);
  color: #ffffff;
  border-color: var(--chatbot-primary);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 47, 108, 0.15);
}

/* Typing Indicator with Avatar */
.chatbot-typing-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-inline-start: 16px;
  margin-bottom: 8px;
}

.chatbot-typing-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid var(--chatbot-border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.chatbot-typing-dot {
  width: 6px;
  height: 6px;
  background: var(--chatbot-text-muted);
  border-radius: 50%;
  animation: chatbot-dot-blink 1.4s infinite both;
}

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

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

@keyframes chatbot-dot-blink {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.1); }
}

/* Quick Prompt Chips */
.chatbot-quick-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 16px;
  background: #ffffff;
  border-top: 1px solid var(--chatbot-border);
  scrollbar-width: none;
}

.chatbot-quick-chips::-webkit-scrollbar {
  display: none;
}

.chatbot-chip-btn {
  white-space: nowrap;
  font-size: 12px;
  font-weight: 500;
  color: var(--chatbot-primary);
  background: var(--chatbot-primary-light);
  border: 1px solid rgba(0, 47, 108, 0.15);
  border-radius: 14px;
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chatbot-chip-btn:hover {
  background: var(--chatbot-primary);
  color: #ffffff;
  border-color: var(--chatbot-primary);
}

.chatbot-chip-btn:focus-visible {
  outline: 2px solid var(--chatbot-primary);
  outline-offset: 1px;
}

/* Input Footer */
.chatbot-footer {
  padding: 10px 14px;
  background: #ffffff;
  border-top: 1px solid var(--chatbot-border);
}

.chatbot-input-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chatbot-active-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--chatbot-primary-light);
  border: 1.5px solid var(--chatbot-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.chatbot-input-field {
  flex: 1;
  padding: 10px 14px;
  font-size: 13px;
  border: 1px solid var(--chatbot-border);
  border-radius: 12px;
  background: var(--chatbot-surface);
  color: var(--chatbot-text-main);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chatbot-input-field:focus {
  border-color: var(--chatbot-primary);
  box-shadow: 0 0 0 3px rgba(0, 47, 108, 0.12);
}

.chatbot-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, #00419d 100%);
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.chatbot-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 10px rgba(0, 47, 108, 0.25);
}

.chatbot-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.chatbot-send-btn:focus-visible {
  outline: 2px solid var(--chatbot-accent);
  outline-offset: 2px;
}

/* Responsive Mobile Bottom Sheet */
@media (max-width: 576px) {
  .kinjo-chatbot-widget {
    bottom: 16px;
    inset-inline-end: 16px;
  }

  .kinjo-chatbot-launcher {
    width: 52px;
    height: 52px;
  }

  .chatbot-launcher-icon {
    font-size: 22px;
  }

  .kinjo-chatbot-window {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 88vh;
    max-height: 88vh;
    border-radius: 22px 22px 0 0;
    transform: translateY(100%);
  }

  .kinjo-chatbot-widget.is-open .kinjo-chatbot-window {
    transform: translateY(0);
  }
}
