/* ══════════════════════════════════════════════════════════════════════
   Chatbot Widget – Premium Glassmorphic Dark Theme
   Matches portfolio design system: --primary #ff4500, Syne + DM Sans
   ══════════════════════════════════════════════════════════════════════ */

/* --- Floating Toggle Button --- */
.chatbot-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9998;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--primary-gradient);
  color: #fff;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow:
    0 6px 24px rgba(255, 69, 0, 0.35),
    0 0 0 0 rgba(255, 69, 0, 0.4);
  transition: transform 0.3s var(--ease-spring),
    box-shadow 0.4s var(--ease-out);
  animation: chatbot-pulse 2.5s ease-in-out infinite;
}

.chatbot-toggle:hover {
  transform: scale(1.1);
  box-shadow:
    0 10px 36px rgba(255, 69, 0, 0.45),
    0 0 0 8px rgba(255, 69, 0, 0.12);
  animation: none;
}

.chatbot-toggle .toggle-icon {
  transition: transform 0.35s var(--ease-spring), opacity 0.25s ease;
}

.chatbot-toggle.active .toggle-icon {
  transform: rotate(90deg);
}

@keyframes chatbot-pulse {

  0%,
  100% {
    box-shadow: 0 6px 24px rgba(255, 69, 0, 0.35), 0 0 0 0 rgba(255, 69, 0, 0.35);
  }

  50% {
    box-shadow: 0 6px 24px rgba(255, 69, 0, 0.35), 0 0 0 12px rgba(255, 69, 0, 0);
  }
}

/* --- Chat Window --- */
.chatbot-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 9999;
  width: 400px;
  max-height: 580px;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* Glassmorphism */
  background: rgba(18, 18, 26, 0.88);
  backdrop-filter: blur(28px) saturate(1.4);
  -webkit-backdrop-filter: blur(28px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 69, 0, 0.08) inset,
    0 1px 0 rgba(255, 255, 255, 0.06) inset;

  /* Hidden by default */
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition:
    opacity 0.35s var(--ease-out),
    transform 0.4s var(--ease-spring),
    visibility 0.35s;
}

.chatbot-window.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* --- Header --- */
.chatbot-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  background: linear-gradient(135deg, rgba(255, 69, 0, 0.12), rgba(177, 45, 0, 0.08));
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(255, 69, 0, 0.3);
}

.chatbot-header-info {
  flex: 1;
}

.chatbot-header-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--on-surface);
  letter-spacing: -0.01em;
}

.chatbot-header-status {
  font-family: var(--font-body);
  font-size: 0.7rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
}

.chatbot-header-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  display: inline-block;
  animation: status-blink 2s ease-in-out infinite;
}

@keyframes status-blink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

.chatbot-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: var(--on-surface-variant);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.2s;
  flex-shrink: 0;
}

.chatbot-close:hover {
  background: rgba(255, 69, 0, 0.15);
  color: var(--primary);
  transform: rotate(90deg);
}

/* --- Messages Area --- */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 280px;
  max-height: 340px;
  scroll-behavior: smooth;
}

/* Scrollbar */
.chatbot-messages::-webkit-scrollbar {
  width: 4px;
}

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

.chatbot-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 69, 0, 0.25);
  border-radius: 4px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 69, 0, 0.45);
}

/* --- Message Bubbles --- */
.chat-msg {
  display: flex;
  gap: 8px;
  max-width: 92%;
  animation: msg-enter 0.35s var(--ease-out) both;
}

@keyframes msg-enter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

.chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  margin-top: 2px;
}

.chat-msg.bot .chat-msg-avatar {
  background: var(--primary-gradient);
  color: #fff;
  box-shadow: 0 2px 8px rgba(255, 69, 0, 0.2);
}

.chat-msg.user .chat-msg-avatar {
  background: rgba(255, 255, 255, 0.1);
  color: var(--on-surface);
}

.chat-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-family: var(--font-body);
  font-size: 0.84rem;
  line-height: 1.55;
  font-weight: 400;
  color: var(--on-surface);
  position: relative;
}

.chat-msg.bot .chat-msg-bubble {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom-left-radius: 4px;
}

.chat-msg.user .chat-msg-bubble {
  background: linear-gradient(135deg, rgba(255, 69, 0, 0.2), rgba(177, 45, 0, 0.15));
  border: 1px solid rgba(255, 69, 0, 0.2);
  border-bottom-right-radius: 4px;
}

.chat-msg-bubble a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: opacity 0.2s;
}

.chat-msg-bubble a:hover {
  opacity: 0.8;
}

/* --- Typing Indicator --- */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  align-items: center;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0.5;
  animation: typing-bounce 1.2s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing-bounce {

  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }

  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* --- Quick Actions (Suggestion Chips) --- */
.chatbot-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 16px 10px;
  flex-shrink: 0;
}

.suggestion-chip {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 69, 0, 0.2);
  background: rgba(255, 69, 0, 0.06);
  color: var(--on-surface-variant);
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s var(--ease-out);
  white-space: nowrap;
}

.suggestion-chip:hover {
  background: rgba(255, 69, 0, 0.18);
  border-color: var(--primary);
  color: #fff;
  transform: translateY(-1px);
}

/* --- Input Area --- */
.chatbot-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 14px;
  background: rgba(10, 10, 15, 0.5);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.chatbot-input {
  flex: 1;
  padding: 10px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--on-surface);
  font-family: var(--font-body);
  font-size: 0.84rem;
  outline: none;
  transition: border-color 0.25s, background 0.25s;
}

.chatbot-input::placeholder {
  color: rgba(228, 225, 233, 0.35);
}

.chatbot-input:focus {
  border-color: rgba(255, 69, 0, 0.4);
  background: rgba(255, 255, 255, 0.06);
}

.chatbot-send {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: var(--primary-gradient);
  color: #fff;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.2s var(--ease-spring), box-shadow 0.3s;
}

.chatbot-send:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 16px rgba(255, 69, 0, 0.4);
}

.chatbot-send:active {
  transform: scale(0.95);
}

/* --- Notification Badge --- */
.chatbot-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
  font-weight: 700;
  color: #fff;
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.3s, transform 0.3s var(--ease-spring);
}

.chatbot-badge.visible {
  opacity: 1;
  transform: scale(1);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .chatbot-window {
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 100dvh;
    border-radius: 0;
  }

  .chatbot-toggle {
    bottom: 20px;
    right: 20px;
    width: 54px;
    height: 54px;
    font-size: 24px;
  }

  .chatbot-messages {
    max-height: calc(100dvh - 220px);
  }
}

@media (max-width: 480px) {
  .chatbot-window {
    bottom: 0;
    right: 0;
    width: 100%;
    max-height: 100dvh;
    border-radius: 0;
  }
}