/* HED Chat Widget Styles */

/* Floating toggle button */
.hed-chat-toggle {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.hed-chat-toggle.closed {
  background: #055c9d;
  color: #ffffff;
}

.hed-chat-toggle.closed:hover {
  transform: scale(1.1);
  background: #044a7d;
}

.hed-chat-toggle.open {
  background: #055c9d;
  color: #ffffff;
  transform: rotate(90deg);
}

.hed-chat-toggle svg {
  width: 24px;
  height: 24px;
}

/* Chat window */
.hed-chat-window {
  position: fixed;
  bottom: 6rem;
  right: 1rem;
  left: auto;
  width: 380px;
  max-width: calc(100vw - 2rem);
  height: 550px;
  max-height: 70vh;
  background: #f5f5f5;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid #d0d0d0;
  border-radius: 1rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: hed-chat-fade-in 0.3s ease;
}

.hed-chat-window.hidden {
  display: none;
}

@keyframes hed-chat-fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Header */
.hed-chat-header {
  padding: 1rem;
  border-bottom: 1px solid #d0d0d0;
  background: #055c9d;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.hed-chat-avatar {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hed-chat-avatar svg {
  width: 24px;
  height: 24px;
  color: #ffffff;
}

.hed-chat-title {
  flex: 1;
}

/* Reset button */
.hed-chat-reset {
  background: transparent;
  border: none;
  padding: 0.5rem;
  border-radius: 0.5rem;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.7);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hed-chat-reset:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.hed-chat-reset:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.hed-chat-reset svg {
  width: 16px;
  height: 16px;
}

.hed-chat-title-text {
  font-weight: 600;
  color: #ffffff;
  font-size: 0.9rem;
  display: block;
}

.hed-chat-status {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.hed-chat-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
}

.hed-chat-status-dot.offline {
  background: #ef4444;
}

.hed-chat-status-dot.checking {
  background: #f59e0b;
}

/* Messages area */
.hed-chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.hed-chat-message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  min-width: 0;
}

.hed-chat-message.user {
  align-self: flex-end;
  align-items: flex-end;
}

.hed-chat-message.assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.hed-chat-message-label {
  font-size: 0.625rem;
  color: #525252;
  margin-bottom: 0.25rem;
  padding: 0 0.25rem;
}

.hed-chat-message-content {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  min-width: 0;
  max-width: 100%;
  overflow: visible;
}

.hed-chat-message.user .hed-chat-message-content {
  background: #055c9d;
  color: #ffffff;
  border-radius: 1rem 0.25rem 1rem 1rem;
}

.hed-chat-message.assistant .hed-chat-message-content {
  background: #ffffff;
  color: #333333;
  border-radius: 0.25rem 1rem 1rem 1rem;
  border: 1px solid #e0e0e0;
}

/* Markdown styling in assistant messages */
.hed-chat-message.assistant .hed-chat-message-content code {
  background: #f0f0f0;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-family: ui-monospace, monospace;
  font-size: 0.8em;
  color: #055c9d;
}

.hed-chat-message.assistant .hed-chat-message-content pre {
  background: #2d3748;
  padding: 0.75rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 0.5rem 0;
}

.hed-chat-message.assistant .hed-chat-message-content pre code {
  background: transparent;
  padding: 0;
  color: #e2e8f0;
}

.hed-chat-message.assistant .hed-chat-message-content a {
  color: #055c9d;
  text-decoration: underline;
}

.hed-chat-message.assistant .hed-chat-message-content ul,
.hed-chat-message.assistant .hed-chat-message-content ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.hed-chat-message.assistant .hed-chat-message-content p {
  margin: 0.5rem 0;
}

.hed-chat-message.assistant .hed-chat-message-content p:first-child {
  margin-top: 0;
}

.hed-chat-message.assistant .hed-chat-message-content p:last-child {
  margin-bottom: 0;
}

/* Loading indicator */
.hed-chat-loading {
  display: flex;
  flex-direction: column;
  align-self: flex-start;
  align-items: flex-start;
}

.hed-chat-loading-label {
  font-size: 0.625rem;
  color: #525252;
  margin-bottom: 0.25rem;
  padding: 0 0.25rem;
}

.hed-chat-loading-dots {
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 0.25rem 1rem 1rem 1rem;
  padding: 0.75rem 1rem;
  display: flex;
  gap: 0.25rem;
}

.hed-chat-loading-dot {
  width: 6px;
  height: 6px;
  background: #055c9d;
  border-radius: 50%;
  animation: hed-chat-bounce 1.4s infinite ease-in-out;
}

.hed-chat-loading-dot:nth-child(1) {
  animation-delay: 0s;
}

.hed-chat-loading-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.hed-chat-loading-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes hed-chat-bounce {
  0%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-6px);
  }
}

/* Input area */
.hed-chat-input-area {
  padding: 1rem;
  border-top: 1px solid #d0d0d0;
  background: #ffffff;
}

.hed-chat-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.hed-chat-input {
  width: 100%;
  background: #f5f5f5;
  border: 1px solid #d0d0d0;
  border-radius: 0.75rem;
  padding: 0.75rem 3rem 0.75rem 1rem;
  color: #333333;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.hed-chat-input::placeholder {
  color: #888888;
}

.hed-chat-input:focus {
  border-color: #055c9d;
}

.hed-chat-send {
  position: absolute;
  right: 0.5rem;
  background: #055c9d;
  border: none;
  border-radius: 0.5rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
}

.hed-chat-send:hover {
  background: #044a7d;
}

.hed-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hed-chat-send svg {
  width: 14px;
  height: 14px;
  color: #ffffff;
}

/* Footer with credit */
.hed-chat-footer {
  padding: 0.5rem 1rem;
  text-align: center;
  border-top: 1px solid #e0e0e0;
  background: #f0f0f0;
}

.hed-chat-footer a {
  color: #666666;
  font-size: 0.625rem;
  text-decoration: none;
  transition: color 0.2s ease;
}

.hed-chat-footer a:hover {
  color: #055c9d;
}

/* Mobile adjustments */
@media (max-width: 640px) {
  .hed-chat-toggle {
    bottom: 1rem;
    right: 1rem;
    width: 48px;
    height: 48px;
  }

  .hed-chat-toggle svg {
    width: 20px;
    height: 20px;
  }

  .hed-chat-window {
    position: fixed;
    bottom: 4rem;
    right: 0.5rem;
    left: auto;
    top: auto;
    width: 300px;
    max-width: calc(100vw - 1rem);
    min-width: 260px;
    height: 45vh;
    max-height: 50vh;
  }

  /* Make resize handle more visible on mobile */
  .hed-chat-resize-handle {
    width: 20px;
    height: 20px;
  }

  .hed-chat-resize-handle::before {
    width: 10px;
    height: 10px;
    border-width: 3px;
  }

  .hed-chat-header {
    padding: 0.75rem;
  }

  .hed-chat-messages {
    padding: 0.75rem;
  }

  .hed-chat-input-area {
    padding: 0.75rem;
  }

  .hed-chat-table {
    font-size: 0.65rem;
  }

  .hed-chat-table th,
  .hed-chat-table td {
    padding: 0.25rem 0.375rem;
  }
}

/* Suggested questions */
.hed-chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.hed-chat-suggestions-label {
  font-size: 0.625rem;
  color: #666666;
  padding: 0 0.25rem;
}

.hed-chat-suggestion {
  text-align: left;
  font-size: 0.875rem;
  padding: 0.625rem 0.875rem;
  background: #ffffff;
  border: 1px solid #d0d0d0;
  border-radius: 0.75rem;
  color: #555555;
  cursor: pointer;
  transition: all 0.2s ease;
}

.hed-chat-suggestion:hover {
  background: #f0f0f0;
  border-color: #055c9d;
  color: #055c9d;
}

/* Bullet list styling */
.hed-chat-list {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
  list-style-type: disc;
}

.hed-chat-list li {
  margin: 0.25rem 0;
}

/* Paragraph styling */
.hed-chat-p {
  margin: 0.25rem 0;
}

/* Horizontal rule */
.hed-chat-hr {
  border: none;
  border-top: 1px solid #d0d0d0;
  margin: 0.75rem 0;
}

/* Header styling */
.hed-chat-h1, .hed-chat-h2, .hed-chat-h3,
.hed-chat-h4, .hed-chat-h5, .hed-chat-h6 {
  margin: 0.75rem 0 0.5rem 0;
  font-weight: 600;
  color: #055c9d;
}

.hed-chat-h1 { font-size: 1.25rem; }
.hed-chat-h2 { font-size: 1.125rem; }
.hed-chat-h3 { font-size: 1rem; }
.hed-chat-h4, .hed-chat-h5, .hed-chat-h6 { font-size: 0.9rem; }

/* Table styling */
.hed-chat-table-wrapper {
  display: block;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 0.5rem 0;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.hed-chat-table {
  border-collapse: collapse;
  font-size: 0.75rem;
  width: max-content;
  min-width: 100%;
  max-width: none;
  table-layout: auto;
}

.hed-chat-table th,
.hed-chat-table td {
  border: 1px solid #d0d0d0;
  padding: 0.375rem 0.5rem;
  text-align: left;
  word-break: break-word;
}

.hed-chat-table th {
  background: #f0f0f0;
  font-weight: 600;
  color: #333;
}

.hed-chat-table td {
  background: #fff;
}

.hed-chat-table tr:nth-child(even) td {
  background: #fafafa;
}

/* Code block styling */
.hed-chat-code-block {
  display: block;
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 0.75rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 0.5rem 0 1rem 0;
  font-family: ui-monospace, 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 0.8rem;
  line-height: 1.4;
  max-width: 100%;
  white-space: pre;
  word-break: normal;
  -webkit-overflow-scrolling: touch;
}

.hed-chat-code-block code {
  background: transparent;
  padding: 0;
  color: inherit;
  white-space: inherit;
}

/* Inline code styling */
.hed-chat-inline-code {
  background: #f0f0f0;
  color: #055c9d;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-family: ui-monospace, 'SF Mono', Monaco, monospace;
  font-size: 0.85em;
  word-break: break-all;
}

/* Resize handle */
.hed-chat-resize-handle {
  position: absolute;
  top: 0;
  left: 0;
  width: 16px;
  height: 16px;
  cursor: nw-resize;
  z-index: 10;
}

.hed-chat-resize-handle::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: 8px;
  height: 8px;
  border-left: 2px solid #aaaaaa;
  border-top: 2px solid #aaaaaa;
  border-radius: 2px 0 0 0;
}

.hed-chat-resize-handle:hover::before {
  border-color: #055c9d;
}

/* Scrollbar styling */
.hed-chat-messages::-webkit-scrollbar {
  width: 6px;
}

.hed-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.hed-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(5, 92, 157, 0.2);
  border-radius: 3px;
}

.hed-chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(5, 92, 157, 0.4);
}

/* Dark mode styles - matches website's data-bs-theme="dark" */
[data-bs-theme="dark"] .hed-chat-window {
  background: #1e293b;
  border-color: #334155;
}

[data-bs-theme="dark"] .hed-chat-header {
  background: #0f172a;
  border-color: #334155;
}

[data-bs-theme="dark"] .hed-chat-messages {
  background: #1e293b;
}

[data-bs-theme="dark"] .hed-chat-message.assistant .hed-chat-message-content {
  background: #334155;
  color: #e2e8f0;
  border-color: #475569;
}

[data-bs-theme="dark"] .hed-chat-message.user .hed-chat-message-content {
  background: #3b82f6;
}

[data-bs-theme="dark"] .hed-chat-input-area {
  background: #0f172a;
  border-color: #334155;
}

[data-bs-theme="dark"] .hed-chat-input {
  background: #1e293b;
  border-color: #475569;
  color: #e2e8f0;
}

[data-bs-theme="dark"] .hed-chat-input::placeholder {
  color: #94a3b8;
}

[data-bs-theme="dark"] .hed-chat-footer {
  background: #0f172a;
  border-color: #334155;
}

[data-bs-theme="dark"] .hed-chat-footer a {
  color: #94a3b8;
}

[data-bs-theme="dark"] .hed-chat-suggestion {
  background: #334155;
  border-color: #475569;
  color: #e2e8f0;
}

[data-bs-theme="dark"] .hed-chat-suggestion:hover {
  background: #475569;
  border-color: #3b82f6;
  color: #3b82f6;
}

[data-bs-theme="dark"] .hed-chat-suggestions-label {
  color: #94a3b8;
}

[data-bs-theme="dark"] .hed-chat-message-label {
  color: #94a3b8;
}

[data-bs-theme="dark"] .hed-chat-loading-dots {
  background: #334155;
  border-color: #475569;
}

[data-bs-theme="dark"] .hed-chat-inline-code {
  background: #334155;
  color: #3b82f6;
}

[data-bs-theme="dark"] .hed-chat-table th {
  background: #334155;
  color: #e2e8f0;
}

[data-bs-theme="dark"] .hed-chat-table td {
  background: #1e293b;
  color: #e2e8f0;
}

[data-bs-theme="dark"] .hed-chat-table tr:nth-child(even) td {
  background: #273449;
}

[data-bs-theme="dark"] .hed-chat-table th,
[data-bs-theme="dark"] .hed-chat-table td {
  border-color: #475569;
}

[data-bs-theme="dark"] .hed-chat-h1,
[data-bs-theme="dark"] .hed-chat-h2,
[data-bs-theme="dark"] .hed-chat-h3,
[data-bs-theme="dark"] .hed-chat-h4,
[data-bs-theme="dark"] .hed-chat-h5,
[data-bs-theme="dark"] .hed-chat-h6 {
  color: #3b82f6;
}

[data-bs-theme="dark"] .hed-chat-hr {
  border-color: #475569;
}

[data-bs-theme="dark"] .hed-chat-resize-handle::before {
  border-color: #64748b;
}

[data-bs-theme="dark"] .hed-chat-resize-handle:hover::before {
  border-color: #3b82f6;
}
