:root {
  --retrix-chat-primary: #9b5de5;
  --retrix-chat-secondary: #7b2ff7;
  --retrix-chat-panel-bg: rgba(11, 7, 26, 0.85); /* Premium glass background */
  --retrix-chat-panel-border: rgba(200, 170, 255, 0.15);
  --retrix-chat-surface: rgba(255, 255, 255, 0.04);
  --retrix-chat-surface-hover: rgba(255, 255, 255, 0.08);
  --retrix-chat-text: #ffffff;
  --retrix-chat-muted: rgba(255, 255, 255, 0.65);
  --retrix-chat-shadow: 0 40px 80px rgba(0, 0, 0, 0.6);
  --retrix-chat-font-head: 'Playfair Display', serif;
  --retrix-chat-font-body: 'Inter', sans-serif;
}

/* Chat Container Reset */
.retrix-ai-shell {
  position: fixed;
  right: clamp(16px, 2vw, 32px);
  bottom: clamp(16px, 2vw, 32px);
  z-index: 9500;
  font-family: var(--retrix-chat-font-body);
  color: var(--retrix-chat-text);
}

.retrix-ai-shell *,
.retrix-ai-shell *::before,
.retrix-ai-shell *::after {
  box-sizing: border-box;
}

.retrix-ai-shell button,
.retrix-ai-shell textarea,
.retrix-ai-shell svg {
  font-family: inherit;
}

/* Launcher Button */
.retrix-ai-shell button.retrix-ai-launcher {
  position: relative !important;
  width: 64px;
  height: 64px;
  border: 1px solid rgba(255,255,255,0.1) !important;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--retrix-chat-primary), var(--retrix-chat-secondary)) !important;
  color: #fff !important;
  box-shadow: 0 16px 32px rgba(155, 93, 229, 0.3) !important;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  visibility: visible !important;
  opacity: 1 !important;
}

.retrix-ai-launcher:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 20px 40px rgba(155, 93, 229, 0.45) !important;
}

.retrix-ai-launcher svg {
  width: 28px;
  height: 28px;
  stroke: #fff !important;
  stroke-width: 2 !important;
  display: block;
}

.retrix-ai-launcher-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  color: var(--retrix-chat-primary);
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Chat Panel */
.retrix-ai-panel {
  position: absolute;
  right: 0;
  bottom: 84px;
  width: min(420px, calc(100vw - 32px));
  height: min(78vh, 720px);
  min-width: 360px;
  min-height: 520px;
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  border: 1px solid var(--retrix-chat-panel-border) !important;
  background: var(--retrix-chat-panel-bg);
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  box-shadow: var(--retrix-chat-shadow);
  overflow: hidden;
  transform-origin: bottom right;
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.retrix-ai-shell.is-expanded .retrix-ai-panel {
  width: min(720px, calc(100vw - 36px));
  height: min(84vh, 860px);
}

.retrix-ai-shell.is-open .retrix-ai-panel {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* Header */
.retrix-ai-header {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
}

.retrix-ai-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.retrix-ai-brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(155, 93, 229, 0.15);
  border: 1px solid rgba(155, 93, 229, 0.3);
}

.retrix-ai-brand-mark svg {
  width: 22px;
  height: 22px;
  stroke: var(--retrix-chat-primary) !important;
}

.retrix-ai-brand-copy strong {
  display: block;
  font-family: var(--retrix-chat-font-head);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--retrix-chat-text);
  letter-spacing: -0.01em;
}

.retrix-ai-brand-copy span {
  display: block;
  font-family: var(--retrix-chat-font-body);
  margin-top: 3px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--retrix-chat-muted);
}

.retrix-ai-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.retrix-ai-clear,
.retrix-ai-expand,
.retrix-ai-close {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05) !important;
  color: #ffffff !important;
  cursor: pointer;
  transition: all 0.2s ease;
}

.retrix-ai-clear:hover,
.retrix-ai-expand:hover,
.retrix-ai-close:hover {
  background: var(--retrix-chat-primary) !important;
  border-color: var(--retrix-chat-primary) !important;
  transform: translateY(-2px);
}

.retrix-ai-close:hover {
  transform: rotate(90deg);
}

.retrix-ai-clear svg,
.retrix-ai-expand svg,
.retrix-ai-close svg {
  width: 16px;
  height: 16px;
  stroke: #ffffff !important;
  stroke-width: 2 !important;
}

/* Quick Prompts */
.retrix-ai-quickprompts {
  padding: 16px 20px 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.retrix-ai-quickprompts[hidden] {
  display: none;
}

.retrix-ai-prompt {
  border: 1px solid rgba(155, 93, 229, 0.3) !important;
  background: rgba(155, 93, 229, 0.08) !important;
  color: var(--retrix-chat-text) !important;
  border-radius: 30px;
  padding: 8px 14px;
  font-family: var(--retrix-chat-font-body);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  opacity: 1 !important;
}

.retrix-ai-prompt:hover {
  background: var(--retrix-chat-primary) !important;
  border-color: var(--retrix-chat-primary) !important;
  color: #fff !important;
  transform: translateY(-2px);
}

/* Chat Feed */
.retrix-ai-feed {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1 1 auto;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.retrix-ai-feed::-webkit-scrollbar { width: 6px; }
.retrix-ai-feed::-webkit-scrollbar-track { background: transparent; }
.retrix-ai-feed::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }

/* Empty state / Welcome message */
.retrix-ai-empty {
  padding: 16px;
  border-radius: 16px;
  background: var(--retrix-chat-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--retrix-chat-muted);
  font-family: var(--retrix-chat-font-body);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* Message Bubbles */
.retrix-ai-message {
  display: flex;
}

.retrix-ai-message--user {
  justify-content: flex-end;
}

.retrix-ai-message--assistant {
  justify-content: flex-start;
}

.retrix-ai-bubble {
  max-width: 85%;
  padding: 14px 18px;
  border-radius: 16px;
  font-family: var(--retrix-chat-font-body);
  font-size: 0.94rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.retrix-ai-message--assistant .retrix-ai-bubble {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--retrix-chat-text);
  border-top-left-radius: 4px;
}

.retrix-ai-message--user .retrix-ai-bubble {
  background: linear-gradient(135deg, var(--retrix-chat-primary), var(--retrix-chat-secondary));
  color: #fff;
  border-top-right-radius: 4px;
}

.retrix-ai-bubble p,
.retrix-ai-bubble ul {
  margin: 0;
}

.retrix-ai-bubble p + p,
.retrix-ai-bubble p + ul,
.retrix-ai-bubble ul + p,
.retrix-ai-bubble ul + ul {
  margin-top: 12px;
}

.retrix-ai-bubble ul {
  padding-left: 20px;
}

.retrix-ai-bubble strong {
  font-weight: 700;
  color: #fff;
}

.retrix-ai-rich-heading {
  font-family: var(--retrix-chat-font-head);
  font-weight: 700;
  font-size: 1.05em;
  color: #c8aaff;
  letter-spacing: 0.01em;
  display: block;
  margin-bottom: 6px;
}

/* Chat Input Bar */
.retrix-ai-form {
  padding: 16px 20px 20px;
  position: relative;
  width: 100%;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: transparent;
  border: none;
  box-shadow: none;
}

.retrix-ai-input {
  flex: 1;
  min-height: 54px;
  max-height: 140px;
  resize: none;
  padding: 16px 20px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  background: rgba(0, 0, 0, 0.4) !important;
  color: #ffffff !important;
  font-family: var(--retrix-chat-font-body);
  font-size: 0.95rem;
  line-height: 1.5;
  outline: none;
  transition: all 0.3s ease;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.retrix-ai-input::-webkit-scrollbar {
  display: none;
}

.retrix-ai-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.retrix-ai-input:focus {
  border-color: var(--retrix-chat-primary) !important;
  background: rgba(0, 0, 0, 0.6) !important;
  box-shadow: 0 0 0 4px rgba(155, 93, 229, 0.15) !important;
}

.retrix-ai-send {
  flex-shrink: 0;
  width: 50px;
  height: 50px;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--retrix-chat-primary) !important;
  color: #ffffff !important;
  cursor: pointer;
  transition: all 0.3s ease;
  opacity: 1 !important;
  margin-bottom: 2px;
}

.retrix-ai-send svg {
  width: 20px !important;
  height: 20px !important;
  stroke: #ffffff !important;
  stroke-width: 2.2 !important;
}

.retrix-ai-send:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(155, 93, 229, 0.4) !important;
  background: var(--retrix-chat-secondary) !important;
}

.retrix-ai-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(1);
}

/* Suggestion Chips in Chat */
.retrix-ai-suggestions {
  padding: 0 20px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.retrix-ai-suggestion-chip {
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  font-family: var(--retrix-chat-font-body);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--retrix-chat-muted);
  cursor: pointer;
  transition: all 0.25s ease;
}

.retrix-ai-suggestion-chip:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

/* Typing Indicator */
.retrix-ai-typing {
  padding: 0 20px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--retrix-chat-muted);
  font-size: 13px;
}

.retrix-ai-typing[hidden] {
  display: none;
}

.retrix-ai-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--retrix-chat-primary);
  opacity: 0.6;
  animation: retrix-chat-dot 1.2s ease-in-out infinite;
}

.retrix-ai-dot:nth-child(2) { animation-delay: 0.16s; }
.retrix-ai-dot:nth-child(3) { animation-delay: 0.32s; }

@keyframes retrix-chat-dot {
  0%, 100% { transform: translateY(0); opacity: 0.4; }
  50% { transform: translateY(-4px); opacity: 1; background: var(--retrix-chat-secondary); }
}

/* File UI (If needed) */
.retrix-ai-bubble-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(155, 93, 229, 0.15);
  border: 1px solid rgba(155, 93, 229, 0.3);
  color: #c8aaff;
  font-size: 12px;
  margin-top: 8px;
}

.retrix-ai-bubble-file strong {
  background: var(--retrix-chat-primary);
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
}

/* Responsiveness */
@media (max-width: 640px) {
  .retrix-ai-shell {
    right: 16px;
    bottom: 16px;
  }
  .retrix-ai-panel {
    width: min(100vw - 32px, 380px);
    bottom: 74px;
    height: min(80vh, 680px);
  }
}
/* Resize Handles */
.retrix-ai-resize-handle {
  position: absolute;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  outline: none;
}
.retrix-ai-resize-handle--n { top: 0; left: 0; right: 0; height: 10px; cursor: ns-resize; }
.retrix-ai-resize-handle--s { bottom: 0; left: 0; right: 0; height: 10px; cursor: ns-resize; }
.retrix-ai-resize-handle--e { top: 0; bottom: 0; right: 0; width: 10px; cursor: ew-resize; }
.retrix-ai-resize-handle--w { top: 0; bottom: 0; left: 0; width: 10px; cursor: ew-resize; }
.retrix-ai-resize-handle--ne { top: 0; right: 0; width: 12px; height: 12px; cursor: nesw-resize; z-index: 2; }
.retrix-ai-resize-handle--nw { top: 0; left: 0; width: 12px; height: 12px; cursor: nwse-resize; z-index: 2; }
.retrix-ai-resize-handle--se { bottom: 0; right: 0; width: 12px; height: 12px; cursor: nwse-resize; z-index: 2; }
.retrix-ai-resize-handle--sw { bottom: 0; left: 0; width: 12px; height: 12px; cursor: nesw-resize; z-index: 2; }

@keyframes retrixFadeInUp {
  0% { transform: translateY(12px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}