/* ── Besie Chatbot Widget Styles ─────────────────────────── */
:root {
  --chat-accent: #14b8a6;
  --chat-accent-2: #3b82f6;
  --chat-accent-purple: #8b5cf6;
  --chat-bg: rgba(11, 15, 26, 0.96);
  --chat-surface: #111827;
  --chat-surface-hover: #172136;
  --chat-border: rgba(255, 255, 255, 0.12);
  --chat-border-glow: rgba(20, 184, 166, 0.35);
  --chat-text: #f5f7fb;
  --chat-text-muted: #9aa5be;
  --chat-text-faint: #64708d;
}

/* ── Floating Launcher ────────────────────────────────────── */
.besie-launcher-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
  font-family: var(--font, 'Inter', system-ui, sans-serif);
}

.besie-launcher-wrap * {
  pointer-events: auto;
  box-sizing: border-box;
}

/* Welcoming Speech Tooltip */
.besie-tooltip {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(17, 24, 39, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--chat-border-glow);
  padding: 10px 16px;
  border-radius: 16px;
  box-shadow: 0 12px 36px -8px rgba(0, 0, 0, 0.6), 0 0 20px -6px rgba(20, 184, 166, 0.3);
  margin-bottom: 12px;
  cursor: pointer;
  max-width: 290px;
  transform-origin: bottom right;
  animation: besieTooltipEntrance 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
}

.besie-tooltip:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.7), 0 0 25px -4px rgba(20, 184, 166, 0.45);
}

.besie-tooltip-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--grad);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(20, 184, 166, 0.4);
}

.besie-tooltip-avatar svg {
  width: 18px;
  height: 18px;
  color: #fff;
}

.besie-tooltip-text {
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--chat-text);
  font-weight: 500;
}

.besie-tooltip-close {
  background: transparent;
  border: none;
  color: var(--chat-text-faint);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.besie-tooltip-close:hover {
  color: var(--chat-text);
  background: rgba(255, 255, 255, 0.08);
}

/* Launcher Button */
.besie-launcher {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--grad);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 8px 30px -4px rgba(20, 184, 166, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
  color: #ffffff;
}

.besie-launcher:hover {
  transform: scale(1.08) rotate(3deg);
  box-shadow: 0 12px 36px -4px rgba(59, 130, 246, 0.6), 0 0 20px rgba(20, 184, 166, 0.5);
}

.besie-launcher:active {
  transform: scale(0.95);
}

.besie-launcher-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, opacity 0.2s ease;
}

.besie-launcher .icon-close {
  display: none;
}

.besie-launcher.is-active .icon-open {
  display: none;
}

.besie-launcher.is-active .icon-close {
  display: block;
  transform: rotate(90deg);
}

/* Pulse Badge */
.besie-pulse-badge {
  position: absolute;
  top: 0px;
  right: 0px;
  width: 15px;
  height: 15px;
  background: #10b981;
  border: 2px solid #06080f;
  border-radius: 50%;
}

.besie-pulse-badge::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: #10b981;
  opacity: 0.6;
  animation: besiePing 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

/* Unread Counter */
.besie-unread-count {
  position: absolute;
  top: -4px;
  left: -4px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid #06080f;
  animation: besieBounce 0.4s ease;
}

/* ── Main Chat Modal Container ───────────────────────────── */
.besie-container {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 410px;
  max-width: calc(100vw - 32px);
  height: 640px;
  max-height: calc(100vh - 120px);
  background: var(--chat-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--chat-border);
  border-radius: 20px;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.75), 0 0 35px -10px rgba(20, 184, 166, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  font-family: var(--font, 'Inter', system-ui, sans-serif);
  transform-origin: bottom right;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease;
}

.besie-container.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92) translateY(20px);
}

/* ── Chat Header ─────────────────────────────────────────── */
.besie-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: rgba(17, 24, 39, 0.85);
  border-bottom: 1px solid var(--chat-border);
  position: relative;
  user-select: none;
}

.besie-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.besie-header-avatar {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--grad);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 14px rgba(20, 184, 166, 0.4);
}

.besie-header-avatar svg {
  width: 22px;
  height: 22px;
}

.besie-header-status-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid #111827;
}

.besie-header-title {
  display: flex;
  flex-direction: column;
}

.besie-header-name {
  font-family: var(--font-display, 'Space Grotesk', sans-serif);
  font-size: 16px;
  font-weight: 700;
  color: var(--chat-text);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.besie-badge-spark {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(20, 184, 166, 0.25));
  border: 1px solid rgba(20, 184, 166, 0.4);
  color: #2dd4bf;
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 6px;
  font-weight: 600;
  font-family: var(--font, sans-serif);
}

.besie-header-sub {
  font-size: 12px;
  color: var(--chat-text-muted);
}

.besie-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.besie-icon-btn {
  background: transparent;
  border: none;
  color: var(--chat-text-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.besie-icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--chat-text);
}

.besie-icon-btn:active {
  background: rgba(255, 255, 255, 0.12);
}

/* ── Chat Messages Stream ────────────────────────────────── */
.besie-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.besie-messages::-webkit-scrollbar {
  width: 6px;
}

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

.besie-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}

.besie-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* Message Wrapper */
.besie-msg {
  display: flex;
  gap: 10px;
  max-width: 92%;
  animation: besieFadeInUp 0.28s ease-out;
}

.besie-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.besie-msg.bot {
  align-self: flex-start;
}

.besie-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--grad);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  margin-top: 2px;
}

.besie-msg-avatar svg {
  width: 16px;
  height: 16px;
}

.besie-msg-bubble {
  padding: 12px 15px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--chat-text);
  word-break: break-word;
}

.besie-msg.user .besie-msg-bubble {
  background: linear-gradient(135deg, #2563eb 0%, #0d9488 100%);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.25);
}

.besie-msg.bot .besie-msg-bubble {
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.besie-msg-bubble p {
  margin: 0 0 8px 0;
}

.besie-msg-bubble p:last-child {
  margin-bottom: 0;
}

.besie-msg-bubble strong {
  color: #fff;
  font-weight: 600;
}

.besie-msg-bubble ul, .besie-msg-bubble ol {
  margin: 6px 0 8px 18px;
  padding: 0;
}

.besie-msg-bubble li {
  margin-bottom: 4px;
}

.besie-msg-bubble a {
  color: #2dd4bf;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.besie-msg-bubble a:hover {
  color: #5eead4;
}

.besie-msg-time {
  font-size: 11px;
  color: var(--chat-text-faint);
  margin-top: 4px;
  text-align: right;
}

.besie-msg.bot .besie-msg-time {
  text-align: left;
}

/* ── Interactive UI Elements Inside Chat ─────────────────── */

/* Quick Suggestion Chips */
.besie-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.besie-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #93c5fd;
  font-size: 12.5px;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, color 0.15s;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-align: left;
}

.besie-chip:hover {
  background: rgba(20, 184, 166, 0.15);
  border-color: rgba(20, 184, 166, 0.4);
  color: #f5f7fb;
  transform: translateY(-1px);
}

.besie-chip:active {
  transform: scale(0.97);
}

/* Action Buttons within Bot Messages */
.besie-action-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.besie-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
}

.besie-btn-primary {
  background: var(--grad);
  color: #fff !important;
  box-shadow: 0 4px 14px rgba(20, 184, 166, 0.3);
}

.besie-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(20, 184, 166, 0.45);
}

.besie-btn-outline {
  background: rgba(255, 255, 255, 0.04);
  color: var(--chat-text) !important;
  border: 1px solid var(--chat-border);
}

.besie-btn-outline:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.25);
}

/* Card inside message */
.besie-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  padding: 12px;
  margin: 8px 0;
}

.besie-card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.besie-card-badge {
  font-size: 11px;
  font-weight: 600;
  color: #2dd4bf;
  background: rgba(20, 184, 166, 0.15);
  padding: 2px 7px;
  border-radius: 999px;
}

.besie-card-detail {
  font-size: 12.5px;
  color: var(--chat-text-muted);
  margin-bottom: 6px;
}

/* Plan Quiz / Recommendation Tool */
.besie-quiz-box {
  background: rgba(22, 31, 51, 0.7);
  border: 1px solid rgba(20, 184, 166, 0.25);
  border-radius: 14px;
  padding: 14px;
  margin: 10px 0;
}

.besie-quiz-step-title {
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 10px;
}

.besie-quiz-options {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.besie-quiz-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--chat-text);
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.15s ease;
}

.besie-quiz-btn:hover {
  background: rgba(20, 184, 166, 0.12);
  border-color: rgba(20, 184, 166, 0.35);
  color: #fff;
}

/* Embedded In-Chat Contact / Demo Form */
.besie-chat-form {
  background: rgba(22, 31, 51, 0.85);
  border: 1px solid var(--chat-border-glow);
  border-radius: 14px;
  padding: 14px;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.besie-chat-form label {
  font-size: 12px;
  font-weight: 500;
  color: var(--chat-text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.besie-chat-form input,
.besie-chat-form select,
.besie-chat-form textarea {
  background: rgba(6, 8, 15, 0.8);
  border: 1px solid var(--chat-border);
  color: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.besie-chat-form input:focus,
.besie-chat-form select:focus,
.besie-chat-form textarea:focus {
  border-color: var(--chat-accent);
  box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.2);
}

.besie-chat-form textarea {
  resize: vertical;
  min-height: 55px;
}

.besie-chat-form .besie-form-feedback {
  font-size: 12.5px;
  padding: 8px 10px;
  border-radius: 8px;
  display: none;
}

.besie-chat-form .besie-form-feedback.success {
  display: block;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.besie-chat-form .besie-form-feedback.error {
  display: block;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
}

/* Typing Indicator Animation */
.besie-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  margin-left: 38px;
}

.besie-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chat-accent);
  opacity: 0.4;
  animation: besieBlink 1.4s infinite both;
}

.besie-dot:nth-child(1) { animation-delay: 0s; }
.besie-dot:nth-child(2) { animation-delay: 0.2s; }
.besie-dot:nth-child(3) { animation-delay: 0.4s; }

/* ── Chat Input Footer ───────────────────────────────────── */
.besie-footer {
  padding: 12px 14px;
  background: rgba(17, 24, 39, 0.95);
  border-top: 1px solid var(--chat-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.besie-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(6, 8, 15, 0.7);
  border: 1px solid var(--chat-border);
  border-radius: 14px;
  padding: 4px 6px 4px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.besie-input-row:focus-within {
  border-color: var(--chat-accent);
  box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.2);
}

.besie-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--chat-text);
  font-size: 14px;
  font-family: inherit;
  padding: 8px 0;
}

.besie-input::placeholder {
  color: var(--chat-text-faint);
}

.besie-send-btn {
  background: var(--grad);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
  flex-shrink: 0;
}

.besie-send-btn:hover {
  transform: scale(1.05);
}

.besie-send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.besie-send-btn svg {
  width: 17px;
  height: 17px;
}

.besie-input-hint {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--chat-text-faint);
  padding: 0 4px;
}

.besie-input-hint a {
  color: var(--chat-text-muted);
  text-decoration: none;
}

.besie-input-hint a:hover {
  color: var(--chat-accent);
}

/* ── Keyframe Animations ─────────────────────────────────── */
@keyframes besiePing {
  75%, 100% {
    transform: scale(2.2);
    opacity: 0;
  }
}

@keyframes besieBounce {
  0% { transform: scale(0); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

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

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

@keyframes besieBlink {
  0%, 80%, 100% {
    opacity: 0.3;
    transform: scale(0.85);
  }
  40% {
    opacity: 1;
    transform: scale(1.15);
  }
}

/* ── Responsive Mobile Styles ────────────────────────────── */
@media (max-width: 480px) {
  .besie-launcher-wrap {
    bottom: 16px;
    right: 16px;
  }
  .besie-container {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }
  .besie-tooltip {
    right: 16px;
    bottom: 84px;
  }
}
