/* AI Chat Widget Styles — adapted for Bergmann.Consulting */

.aichat-widget {
  font-family: 'Inter var', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  line-height: 1.5;
}

/* ── Chat bubble (minimized) ── */
.aichat-bubble {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981, #059669);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
  transition: transform 0.25s cubic-bezier(.4,0,.2,1), box-shadow 0.25s cubic-bezier(.4,0,.2,1);
  color: white;
}

.aichat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.aichat-bubble:active {
  transform: scale(0.97);
}

/* ── Chat window (expanded) ── */
.aichat-window {
  width: 380px;
  height: 580px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.04),
    0 12px 40px rgba(0, 0, 0, 0.12),
    0 4px 12px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: aichat-slide-up 0.3s cubic-bezier(.4,0,.2,1);
}

@keyframes aichat-slide-up {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ── */
.aichat-header {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.aichat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.aichat-logo {
  display: flex;
  align-items: center;
}

.aichat-header-status {
  display: flex;
  flex-direction: column;
}

.aichat-header-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: white;
  margin: 0;
}

.aichat-header-subtitle {
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  gap: 4px;
}

.aichat-header-subtitle::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #a7f3d0;
  display: inline-block;
}

.aichat-close {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.aichat-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ── Messages container ── */
.aichat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f9fafb;
}

/* Subtle scrollbar */
.aichat-messages::-webkit-scrollbar {
  width: 5px;
}
.aichat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.aichat-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 10px;
}
.aichat-messages::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* ── Message bubbles ── */
.aichat-message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

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

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

.aichat-message-content {
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.55;
  font-size: 14px;
}

.aichat-message-content p {
  margin: 0;
}

.aichat-message-user .aichat-message-content {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border-bottom-right-radius: 4px;
}

.aichat-message-bot .aichat-message-content {
  background-color: #ffffff;
  color: #1f2937;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* ── Citations ── */
.aichat-citations {
  margin-top: 8px;
  padding: 10px;
  background: #f3f4f6;
  border-radius: 10px;
  font-size: 12px;
}

.aichat-citations-summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  user-select: none;
}

.aichat-citations-summary:hover {
  color: #374151;
}

.aichat-citation {
  padding: 8px;
  margin-top: 6px;
  background: white;
  border-radius: 6px;
  border-left: 3px solid #10b981;
}

.aichat-citation a {
  color: #059669;
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
}

.aichat-citation a:hover {
  text-decoration: underline;
}

.aichat-citation-snippet {
  font-size: 12px;
  margin-top: 4px;
  color: #6b7280;
}

/* ── Fallback contact ── */
.aichat-fallback {
  margin-top: 8px;
  padding: 12px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 10px;
  font-size: 13px;
  color: #065f46;
}

.aichat-fallback .aichat-fallback-label {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}

.aichat-fallback-button {
  display: inline-block;
  padding: 6px 14px;
  background: #10b981;
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.2s;
}

.aichat-fallback-button:hover {
  background: #059669;
}

/* ── Loading animation ── */
.aichat-loading {
  display: flex;
  gap: 5px;
  padding: 4px 0;
}

.aichat-loading span {
  width: 7px;
  height: 7px;
  background-color: #10b981;
  border-radius: 50%;
  animation: aichat-bounce 1.4s infinite ease-in-out both;
  opacity: 0.6;
}

.aichat-loading span:nth-child(1) { animation-delay: -0.32s; }
.aichat-loading span:nth-child(2) { animation-delay: -0.16s; }

@keyframes aichat-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* ── Error message ── */
.aichat-error {
  padding: 10px 14px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  color: #991b1b;
  font-size: 13px;
}

/* ── Input form ── */
.aichat-input-form {
  display: flex;
  padding: 14px 16px;
  background: #ffffff;
  border-top: 1px solid #f3f4f6;
  gap: 8px;
}

.aichat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #f9fafb;
  color: #1f2937;
}

.aichat-input::placeholder {
  color: #9ca3af;
}

.aichat-input:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
  background: #ffffff;
}

.aichat-input:disabled {
  background: #f3f4f6;
  cursor: not-allowed;
}

.aichat-send-button {
  padding: 10px 12px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, opacity 0.2s;
}

.aichat-send-button:hover:not(:disabled) {
  transform: scale(1.04);
}

.aichat-send-button:active:not(:disabled) {
  transform: scale(0.96);
}

.aichat-send-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Utility classes (scoped for widget HTML) ── */
.aichat-widget .flex       { display: flex; }
.aichat-widget .items-center { align-items: center; }
.aichat-widget .gap-2      { gap: 8px; }
.aichat-widget .font-semibold { font-weight: 600; }
.aichat-widget .font-medium   { font-weight: 500; }
.aichat-widget .text-white { color: white; }
.aichat-widget .text-xs    { font-size: 12px; }
.aichat-widget .text-sm    { font-size: 14px; }
.aichat-widget .mb-2       { margin-bottom: 8px; }
.aichat-widget .mt-1       { margin-top: 4px; }
.aichat-widget .h-6        { height: 24px; }
.aichat-widget .w-6        { width: 24px; }
.aichat-widget .w-5        { height: 20px; }
.aichat-widget .h-5        { width: 20px; }
.aichat-widget .rounded    { border-radius: 4px; }

/* ── Responsive ── */
@media (max-width: 480px) {
  .aichat-widget {
    bottom: 16px;
    right: 16px;
  }

  .aichat-window {
    width: calc(100vw - 32px);
    height: calc(100vh - 100px);
    border-radius: 14px;
  }

  .aichat-bubble {
    width: 52px;
    height: 52px;
  }
}
