/* chat_style_gem.css - Modern, vibrant, non-Tailwind CSS for vector search widget */
:root {
  --chat-gem-primary: #2c3e50;
  /* Flatly Primary (Dark Blue) */
  --chat-gem-secondary: #18bc9c;
  /* Flatly Secondary (Teal) */
  --chat-gem-accent: #3498db;
  /* Flatly Info (Blue) */
  --chat-gem-bg: #ffffff;
  --chat-gem-text: #2c3e50;
  --chat-gem-muted: #7b8a8b;
  --chat-gem-border: #ecf0f1;
  --chat-gem-user-bg: #e0f2fe;
  --chat-gem-bot-bg: #f4f6f8;
  --chat-gem-shadow: 0 12px 28px rgba(0, 0, 0, 0.12), 0 8px 10px rgba(0, 0, 0, 0.08);
  --chat-gem-font: 'Lato', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --chat-gem-code-bg: #1e1e1e;
  --chat-gem-code-text: #d4d4d4;
  --chat-gem-btn-text: #000000;
}

@media (prefers-color-scheme: dark) {
  :root {
    --chat-gem-bg: #1a252f;
    --chat-gem-text: #ecf0f1;
    --chat-gem-muted: #95a5a6;
    --chat-gem-border: #2c3e50;
    --chat-gem-user-bg: #1e3a5f;
    --chat-gem-bot-bg: #121a20;
    --chat-gem-btn-text: #ffffff;
  }
}

#chat-gem-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: var(--chat-gem-font);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

#chat-gem-toggle {
  background: linear-gradient(135deg, var(--chat-gem-primary), var(--chat-gem-secondary));
  color: white;
  border: none;
  border-radius: 50%;
  width: 60px;
  height: 60px;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
}

#chat-gem-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

#chat-gem-toggle svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

#chat-gem-window {
  width: 380px;
  height: 550px;
  background-color: var(--chat-gem-bg);
  border-radius: 16px;
  box-shadow: var(--chat-gem-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-bottom: 16px;
  border: 1px solid var(--chat-gem-border);
  transform-origin: bottom right;
  animation: chatGemPopIn 0.3s cubic-bezier(0.19, 1, 0.22, 1);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), height 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-radius 0.3s ease;
}

#chat-gem-window.expanded {
  width: min(900px, calc(100vw - 48px));
  height: calc(100vh - 120px);
  border-radius: 24px;
}

/* Collapsed state for minimize button */
#chat-gem-window.minimized {
  height: 60px !important;
  border-radius: 16px;
}

#chat-gem-window.minimized #chat-gem-quick-bar,
#chat-gem-window.minimized #chat-gem-messages,
#chat-gem-window.minimized #chat-gem-input-area {
  display: none !important;
}

@keyframes chatGemPopIn {
  0% {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }

  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

#chat-gem-header {
  background: linear-gradient(135deg, var(--chat-gem-primary), var(--chat-gem-secondary));
  padding: 16px 20px;
  color: white;
  font-weight: 600;
  font-size: 1.1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#chat-gem-expand,
#chat-gem-close {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

#chat-gem-expand:hover,
#chat-gem-minimize:hover,
#chat-gem-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

/* Minimize button specific icon size fix if needed */
#chat-gem-minimize svg {
  transform: translateY(1px);
}

#chat-gem-status-dot {
  width: 10px;
  height: 10px;
  background-color: #2ecc71;
  border-radius: 50%;
  box-shadow: 0 0 8px #2ecc71;
  animation: chatGemPulse 2s infinite;
}

@keyframes chatGemPulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.2);
    opacity: 0.7;
  }

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

/* Quick-question chip bar */
#chat-gem-quick-bar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--chat-gem-border);
  background-color: var(--chat-gem-bg);
}

.chat-gem-quick-btn {
  background: transparent;
  border: 1px solid var(--chat-gem-secondary);
  color: var(--chat-gem-btn-text);
  border-radius: 20px;
  padding: 4px 8px;
  font-size: 0.7rem;
  cursor: pointer;
  width: 100%;
  white-space: normal;
  text-align: center;
  transition: background-color 0.2s, color 0.2s;
  animation: chatGemSlideIn 0.3s ease-out;
}

.chat-gem-quick-btn:hover {
  background-color: var(--chat-gem-secondary);
  color: white;
  /* TRIAL: Making text bigger on hover */
  font-size: 0.8rem;
  transform: scale(1.02);
}

/* Inline "More questions" chips — same style as quick-bar */
.chat-gem-suggest-btn-lang {
  background: transparent;
  border: 1px solid var(--chat-gem-secondary);
  color: var(--chat-gem-btn-text);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 1rem;
  cursor: pointer;
  min-height: 75px;
  width: 100%;
  white-space: normal;
  text-align: center;
  transition: background-color 0.2s, color 0.2s;
  animation: chatGemSlideIn 0.3s ease-out;
  display: flexible;
}

.chat-gem-suggest-btn-lang:hover {
  background-color: var(--chat-gem-secondary);
  color: white;
  /* TRIAL: Making text bigger on hover */
  font-size: 1.2rem;
  transform: scale(1.02);
}

.chat-gem-suggest-btn {
  background: transparent;
  border: 1px solid var(--chat-gem-secondary);
  color: var(--chat-gem-btn-text);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 0.75rem;
  cursor: pointer;
  width: 100%;
  white-space: normal;
  text-align: left;
  transition: background-color 0.2s, color 0.2s;
  animation: chatGemSlideIn 0.3s ease-out;
}

.chat-gem-suggest-btn:hover {
  background-color: var(--chat-gem-secondary);
  color: white;
  /* TRIAL: Making text bigger on hover */
  font-size: 0.85rem;
  transform: scale(1.02);
}

.chat-gem-related-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.chat-gem-suggest-cat {
  width: 100%;
  font-size: 0.72rem;
  color: var(--chat-gem-muted);
  margin-bottom: 2px;
}

#chat-gem-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.chat-gem-msg {
  max-width: 95%;
  padding: 12px 12px;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.4;
  word-wrap: break-word;
  animation: chatGemSlideIn 0.2s ease-out;
}

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

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

.chat-gem-msg.user {
  align-self: flex-end;
  background-color: var(--chat-gem-user-bg);
  border-bottom-right-radius: 4px;
  color: var(--chat-gem-text);
}

.chat-gem-msg.bot {
  align-self: flex-start;
  background-color: var(--chat-gem-bot-bg);
  border-bottom-left-radius: 4px;
  color: var(--chat-gem-text);
  border: 1px solid var(--chat-gem-border);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

/* Markdown Rendering Styles */
.chat-gem-msg strong,
.chat-gem-msg b {
  font-weight: 700;
  color: var(--chat-gem-primary);
}

#chat-gem-typing-note {
  color: #888;
  font-style: italic;
  font-size: 9px;
  opacity: 0.8;
  margin-left: 10px;
  margin-top: 4px;
}

.chat-gem-msg code {
  background: rgba(0, 0, 0, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: 'Fira Code', 'Roboto Mono', monospace;
  color: #e74c3c;
  word-break: break-word;
  /* Ensure long code words wrap */
  white-space: pre-wrap;
}

.chat-gem-code-block {
  background-color: var(--chat-gem-code-bg);
  color: var(--chat-gem-code-text);
  padding: 16px;
  border-radius: 12px;
  margin: 12px 0;
  overflow-x: auto;
  border: 1px solid #333;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.chat-gem-code-block code {
  background: transparent !important;
  color: inherit !important;
  padding: 0 !important;
  font-size: 0.9rem !important;
  line-height: 1.5;
}

.chat-gem-msg p {
  margin: 0 0 8px 0;
}

.chat-gem-msg p:last-child {
  margin-bottom: 0;
}

.chat-gem-msg ul,
.chat-gem-msg ol {
  margin: 8px 0;
  padding-left: 20px;
}

.chat-gem-msg a {
  color: var(--chat-gem-accent);
  text-decoration: underline;
}

.chat-gem-msg h1,
.chat-gem-msg h2,
.chat-gem-msg h3,
.chat-gem-msg h4 {
  margin: 12px 0 8px 0;
  color: var(--chat-gem-primary);
  font-weight: 700;
  line-height: 1.2;
}

.chat-gem-msg h4 {
  font-size: 1rem;
  font-style: italic;
  color: var(--chat-gem-secondary);
}

.chat-gem-msg h3 {
  font-size: 1.1rem;
  border-left: 4px solid var(--chat-gem-secondary);
  padding-left: 10px;
  margin-top: 16px;
}

.chat-gem-msg h2 {
  font-size: 1.25rem;
  border-bottom: 2px solid var(--chat-gem-border);
  padding-bottom: 4px;
}

.chat-gem-msg h1 {
  font-size: 1.4rem;
}

.chat-gem-source {
  font-size: 0.75rem;
  color: var(--chat-gem-primary);
  margin-top: 6px;
  border-top: 1px dashed rgba(99, 102, 241, 0.3);
  padding-top: 4px;
  display: block;
}

#chat-gem-input-area {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--chat-gem-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background-color: var(--chat-gem-bg);
}

.chat-gem-privacy-notice {
  font-size: 0.65rem;
  color: var(--chat-gem-muted);
  line-height: 1.3;
  padding: 0 2px;
  opacity: 0.8;
}

.chat-gem-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  width: 100%;
}

#chat-gem-input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--chat-gem-border);
  border-radius: 12px;
  outline: none;
  font-size: 0.75rem;
  background-color: var(--chat-gem-bg);
  color: var(--chat-gem-text);
  transition: border-color 0.2s, box-shadow 0.2s;
  resize: none;
  height: 75px;
  max-height: 150px;
  font-family: inherit;
  line-height: 1.4;
}

#chat-gem-input:focus {
  border-color: var(--chat-gem-primary);
  box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.1);
}

#chat-gem-send {
  background: var(--chat-gem-primary);
  color: white;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.2s;
}

#chat-gem-send:hover {
  background: var(--chat-gem-secondary);
  transform: scale(1.05);
}

#chat-gem-send:active {
  transform: scale(0.95);
}

.chat-gem-typing {
  align-self: flex-start;
  background-color: transparent !important;
  border: none !important;
  display: flex;
  gap: 4px;
  padding: 8px 12px;
}

.chat-gem-dot {
  width: 8px;
  height: 8px;
  background-color: var(--chat-gem-primary);
  border-radius: 50%;
  animation: chatGemBounce 1.4s infinite ease-in-out both;
}

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

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

@keyframes chatGemBounce {

  0%,
  80%,
  100% {
    transform: scale(0);
  }

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

@media (max-width: 480px) {
  #chat-gem-window {
    width: calc(100vw - 32px);
    height: calc(100vh - 120px);
    right: 16px;
  }
}

/* Autocomplete Styles */
#chat-gem-autocomplete {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 100%;
  max-height: 200px;
  background: var(--chat-gem-bg);
  border: 1px solid var(--chat-gem-border);
  border-radius: 12px;
  box-shadow: var(--chat-gem-shadow);
  z-index: 10001;
  overflow-y: auto;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.chat-gem-autocomplete-hidden {
  display: none !important;
}

.chat-gem-autocomplete-item {
  padding: 10px 16px;
  font-size: 0.8rem;
  cursor: pointer;
  border-bottom: 1px solid var(--chat-gem-border);
  transition: background-color 0.2s;
  color: var(--chat-gem-text);
  line-height: 1.4;
  text-align: left;
}

.chat-gem-autocomplete-item:last-child {
  border-bottom: none;
}

.chat-gem-autocomplete-item:hover,
.chat-gem-autocomplete-item.active {
  background-color: var(--chat-gem-user-bg);
  color: var(--chat-gem-primary);
}