:host {
  --primary-gradient: linear-gradient(135deg, #fad32e 0%, #f97316 100%);
  --purple-orb: radial-gradient(circle, #7c3aed 0%, transparent 70%);
  --yellow-orb: radial-gradient(circle, #fad32e 0%, transparent 70%);
  --orange-orb: radial-gradient(circle, #f97316 0%, transparent 70%);
  --glass-bg: rgba(0, 0, 0, 0.6);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-border-hover: rgba(255, 255, 255, 0.2);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.hash-bot {
  font-family: 'DM Sans', sans-serif;
  letter-spacing: -0.02em;
  color-scheme: dark;
  color: white;

  /* Theme Variables - Default (Dark) */
  --bg-color: rgba(13, 13, 13, 0.7);
  --border-color: rgba(255, 255, 255, 0.1);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.6);
  --header-bg: rgba(20, 20, 20, 0.4);
  --input-bg: rgba(255, 255, 255, 0.05);
  --btn-hover: rgba(255, 255, 255, 0.08);
  --bot-msg-bg: rgba(255, 255, 255, 0.08);
  --user-msg-bg: rgba(255, 255, 255, 0.15);
  --orb-opacity: 0.15;
}

.hash-bot.theme-light {
  color-scheme: light;
  color: #1a1a1a;

  /* Theme Variables - Light */
  --bg-color: rgba(255, 255, 255, 0.7);
  --border-color: rgba(0, 0, 0, 0.1);
  --text-primary: #1a1a1a;
  --text-secondary: rgba(0, 0, 0, 0.6);
  --header-bg: rgba(240, 240, 240, 0.4);
  --input-bg: rgba(0, 0, 0, 0.05);
  --btn-hover: rgba(0, 0, 0, 0.08);
  --bot-msg-bg: rgba(0, 0, 0, 0.05);
  --user-msg-bg: rgba(0, 0, 0, 0.08);
  --orb-opacity: 0.1;
}

.hidden {
  display: none;
}

/* Floating Toggle Button */
.floating-toggle {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--bg-color);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}

.floating-toggle:hover {
  width: 160px;
  gap: 12px;
  padding: 0 16px;
  border-radius: 12px;
}

.floating-toggle:active {
  transform: scale(0.95);
}

.toggle-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top right, rgba(250, 211, 46, 0.2), rgba(249, 115, 22, 0.2), rgba(124, 58, 237, 0.2));
  opacity: 0;
  transition: opacity 0.3s;
}

.floating-toggle:hover .toggle-gradient {
  opacity: 1;
}

.toggle-icon {
  width: 24px;
  height: 24px;
  color: var(--text-primary);
  position: relative;
  z-index: 10;
  transition: transform 0.4s;
  flex-shrink: 0;
}

.toggle-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  opacity: 0;
  width: 0;
  overflow: hidden;
  transform: translateX(10px);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.floating-toggle:hover .toggle-label {
  opacity: 1;
  width: 82px;
  /* Approx width for "Chat with us" */
  transform: translateX(0);
}

/* Minimized Bar */
.minimized-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-color);
  backdrop-filter: blur(20px) saturate(180%);
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.minimized-bar:hover {
  border-color: var(--text-secondary);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse 2s infinite;
}

.agent-name-min {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.maximize-icon {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
  transition: color 0.3s;
}

.minimized-bar:hover .maximize-icon {
  color: var(--text-primary);
}

/* Chat Widget Container */
.chat-widget {
  width: 380px;
  height: 520px;
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: var(--bg-color);
  backdrop-filter: blur(20px) saturate(180%);
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2), inset 0 1px 0 0 rgba(255, 255, 255, 0.05);
}

/* Background Orbs */
.orb {
  position: absolute;
  border-radius: 9999px;
  filter: blur(40px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
}

.orb-top-right {
  top: -4rem;
  right: -4rem;
  width: 444px;
  height: 18rem;
  background: var(--yellow-orb);
}

.orb-bottom-left {
  bottom: -4rem;
  left: -4rem;
  width: 444px;
  height: 18rem;
  background: var(--purple-orb);
}

.orb-center {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 444px;
  height: 18rem;
  background: var(--orange-orb);
  filter: blur(60px);
}

/* Header */
.chat-header {
  position: relative;
  z-index: 10;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: var(--header-bg);
  backdrop-filter: blur(10px);
}

.header-agency {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bot-avatar-header {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.2);
}

.bot-avatar-header .icon {
  width: 100%;
  height: 100%;
  color: black;
}

.header-info h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse 2s infinite;
}

.status-text {
  font-size: 10px;
  color: var(--text-secondary);
  font-weight: 500;
}

.header-actions {
  display: flex;
  gap: 4px;
}

.action-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.action-btn:hover {
  background: var(--btn-hover);
  color: var(--text-primary);
}

.action-btn.close:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
}

/* Theme Toggle Button */
.theme-toggle-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  background: transparent;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
  margin-right: 12px;
}

.theme-toggle-btn:hover {
  background: var(--btn-hover);
  transform: translateY(-1px);
}

.theme-toggle-btn .icon {
  width: 18px;
  height: 18px;
}

/* Message Area */
.messages-area {
  position: relative;
  z-index: 10;
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.messages-area::-webkit-scrollbar {
  width: 6px;
}

.messages-area::-webkit-scrollbar-track {
  background: transparent;
}

.messages-area::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: messageSlideIn 0.3s ease-out;
}

.message-row.user {
  justify-content: flex-end;
}

.message-row.bot {
  justify-content: flex-start;
}

.bot-avatar-message {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bot-msg-bg);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  flex-shrink: 0;
}

.bot-avatar-message .icon {
  width: 100%;
  height: 100%;
  color: var(--text-secondary);
}

.message-bubble {
  width: fit-content;
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 16px;
  line-height: 1.5;
  position: relative;
  transition: all 0.2s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.message-row.user .message-bubble {
  background: var(--user-msg-bg);
  color: var(--text-primary);
  border-bottom-right-radius: 4px;
  border: 1px solid var(--border-color);
  margin-left: auto;
}

.message-row.bot .message-bubble {
  background: var(--bot-msg-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
  font-weight: 400;
  line-height: 1.6;
}

.message-bubble.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  width: fit-content;
  min-width: 45px;
  align-items: center;
  justify-content: center;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  background: var(--text-secondary);
  border-radius: 50%;
  display: inline-block;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typingBounce {

  0%,
  80%,
  100% {
    transform: scale(0);
    opacity: 0.3;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.markdown-content {
  display: block;
}

.markdown-content p {
  margin: 0 0 12px 0;
}

.markdown-content p:last-child {
  margin-bottom: 0;
}

.markdown-content ul,
.markdown-content ol {
  margin: 0 0 12px 0;
  padding-left: 28px;
}

.markdown-content li {
  margin-bottom: 4px;
}

.markdown-content strong {
  font-weight: 700;
  color: var(--text-primary);
}

.markdown-content code {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 4px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9em;
}

.markdown-content pre {
  background: rgba(0, 0, 0, 0.3);
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 12px 0;
}

.markdown-content pre code {
  background: transparent;
  padding: 0;
}

/* Word animation for bot response */
.bot-word {
  display: inline-block;
  opacity: 0;
  transform: translateY(5px);
  filter: blur(4px);
  animation: wordFadeIn 0.3s ease-out forwards;
}

.bot-word-static {
  display: inline-block;
  opacity: 1;
  transform: none;
  filter: none;
}

@keyframes wordFadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}


/* Input Area */
.input-area {
  position: relative;
  z-index: 10;
  padding: 16px;
  padding-top: 8px;
}

.input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-container {
  flex: 1;
  background: var(--input-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  padding: 4px 16px;
  transition: border-color 0.2s;
}

.input-container:focus-within {
  border-color: var(--text-secondary);
}

.message-input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  height: 36px;
  outline: none;
}

.message-input::placeholder {
  color: var(--text-secondary);
}

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bot-msg-bg);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
  background: var(--btn-hover);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.send-icon {
  width: 20px;
  height: 20px;
  transform: rotate(-45deg);
  transition: transform 0.2s;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* Animations */
@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* Widget animation */
.chat-widget-enter {
  animation: widgetFadeIn 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
}

@keyframes widgetFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Component Layout */
.widget-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 16px;
}