/* ============================================================
   AI PORTFOLIO CHATBOT
   ============================================================ */

#portfolio-chatbot {
  position: fixed;
  right: 25px;
  bottom: 25px;
  z-index: 9999;
  font-family: inherit;
}

/* ============================================================
   FLOATING TOGGLE BUTTON
   ============================================================ */

#chatbot-toggle {
  width: 62px;
  height: 62px;

  border: none;
  border-radius: 50%;

  background: linear-gradient(135deg, #111827 0%, #1e1b4b 100%);
  color: #ffffff;

  display: flex;
  align-items: center;
  justify-content: center;

  cursor: pointer;

  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(255, 255, 255, 0.1);

  transition:
    transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.25s ease,
    background 0.3s ease;
}

#chatbot-toggle:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow:
    0 15px 35px rgba(99, 102, 241, 0.35),
    0 0 0 1px rgba(168, 85, 247, 0.4);
}

#chatbot-toggle:active {
  transform: translateY(0) scale(0.98);
}

.chatbot-icon {
  font-size: 26px;
  background: linear-gradient(135deg, #ffffff 0%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
  animation: floatSparkle 3s ease-in-out infinite;
}

@keyframes floatSparkle {
  0%,
  100% {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(15deg) scale(1.1);
  }
}

/* ============================================================
   CHAT WINDOW
   ============================================================ */

#chatbot-window {
  position: absolute;

  right: 0;
  bottom: 78px;

  width: 380px;
  height: 600px;

  background: #ffffff;

  border-radius: 20px;

  overflow: hidden;

  display: none;
  flex-direction: column;

  border: 1px solid rgba(229, 231, 235, 0.8);

  box-shadow:
    0 25px 65px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(0, 0, 0, 0.05);

  animation: chatbotEntrance 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes chatbotEntrance {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

#chatbot-window.active {
  display: flex;
}

/* ============================================================
   HEADER
   ============================================================ */

.chatbot-header {
  height: 72px;

  padding: 0 18px;

  background: linear-gradient(135deg, #0b0f19 0%, #1e1b4b 100%);
  color: #ffffff;

  display: flex;
  align-items: center;
  justify-content: space-between;

  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

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

.chatbot-avatar {
  width: 40px;
  height: 40px;

  border-radius: 50%;

  background: rgba(255, 255, 255, 0.1);
  border: 1.5px solid rgba(168, 85, 247, 0.4);
  color: #ffffff;

  display: flex;
  align-items: center;
  justify-content: center;

  overflow: hidden;
  padding: 6px;
  box-sizing: border-box;
}

.chatbot-avatar .site-logo-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.chatbot-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.chatbot-status {
  margin-top: 3px;

  font-size: 12px;

  color: #d1d5db;

  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;

  border-radius: 50%;

  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
}

.status-dot.thinking-pulse {
  background: #a855f7;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.8);
  animation: dotPulsing 1s infinite alternate ease-in-out;
}

@keyframes dotPulsing {
  0% {
    transform: scale(0.9);
    opacity: 0.7;
  }
  100% {
    transform: scale(1.3);
    opacity: 1;
  }
}

#chatbot-close {
  border: none;

  background: transparent;

  color: #ffffff;

  font-size: 26px;

  cursor: pointer;

  width: 36px;
  height: 36px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;

  transition:
    background 0.2s ease,
    transform 0.2s ease;
}

#chatbot-close:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.1);
}

/* ============================================================
   MESSAGES CONTAINER
   ============================================================ */

#chatbot-messages {
  flex: 1;

  overflow-y: auto;

  padding: 18px 14px;

  background: #f8fafc;

  scroll-behavior: smooth;
}

.chatbot-message {
  display: flex;

  gap: 10px;

  margin-bottom: 14px;

  max-width: 92%;

  animation: messageFadeIn 0.25s ease-out forwards;
}

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

.bot-message {
  align-items: flex-start;
  margin-right: auto;
}

.user-message {
  margin-left: auto;
  flex-direction: row-reverse;
}

.message-avatar {
  width: 32px;
  height: 32px;

  flex-shrink: 0;

  border-radius: 50%;

  background: #111827;
  color: #ffffff;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 11px;
  font-weight: 700;

  overflow: hidden;
  padding: 5px;
  box-sizing: border-box;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  position: relative;
}

.message-avatar .site-logo-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.user-message .message-avatar {
  background: #e2e8f0;
  color: #1e293b;
}

.message-content {
  padding: 10px 14px;

  border-radius: 16px;

  background: #ffffff;

  color: #1e293b;

  font-size: 13.5px;

  line-height: 1.55;

  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.04),
    0 1px 2px rgba(0, 0, 0, 0.02);

  border: 1px solid #e2e8f0;

  word-break: break-word;
}

.bot-message .message-content {
  border-top-left-radius: 4px;
}

.user-message .message-content {
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
  color: #ffffff;
  border-top-right-radius: 4px;
  border: none;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
}

.message-content p {
  margin: 0 0 8px;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content strong {
  font-weight: 600;
  color: #0f172a;
}

.user-message .message-content strong {
  color: #ffffff;
}

.chatbot-link {
  color: #6366f1;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
}

.chatbot-link:hover {
  color: #4f46e5;
}

.chatbot-inline-code {
  background: #f1f5f9;
  color: #6366f1;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 12px;
  font-family: monospace;
}

.chatbot-code-block {
  background: #0f172a;
  color: #e2e8f0;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-family: monospace;
  overflow-x: auto;
  margin: 6px 0;
}

.chatbot-list {
  margin: 6px 0;
  padding-left: 20px;
}

.chatbot-list li {
  margin-bottom: 4px;
}

/* ============================================================
   ANIMATED THINKING & LOOKUP STATE
   ============================================================ */

.thinking-state {
  position: relative;
}

.thinking-avatar {
  position: relative;
  background: linear-gradient(135deg, #3b0764 0%, #1e1b4b 100%);
  border: 1px solid rgba(168, 85, 247, 0.5);
}

.avatar-pulse-ring {
  position: absolute;
  top: -3px;
  left: -3px;
  right: -3px;
  bottom: -3px;
  border-radius: 50%;
  border: 2px solid #a855f7;
  opacity: 0.8;
  animation: ringPulse 1.8s cubic-bezier(0.24, 0, 0.38, 1) infinite;
}

@keyframes ringPulse {
  0% {
    transform: scale(0.9);
    opacity: 0.9;
  }
  70% {
    transform: scale(1.35);
    opacity: 0;
  }
  100% {
    transform: scale(1.4);
    opacity: 0;
  }
}

.thinking-content {
  background: #ffffff;
  border: 1px solid #e0e7ff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.08);
  min-width: 170px;
  padding: 10px 14px;
}

.thinking-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.thinking-sparkle {
  color: #8b5cf6;
  font-size: 13px;
  animation: sparkleSpin 3s linear infinite;
  display: inline-block;
}

@keyframes sparkleSpin {
  0% {
    transform: rotate(0deg) scale(1);
    color: #8b5cf6;
  }
  50% {
    transform: rotate(180deg) scale(1.2);
    color: #ec4899;
  }
  100% {
    transform: rotate(360deg) scale(1);
    color: #8b5cf6;
  }
}

.thinking-text {
  font-size: 12px;
  font-weight: 600;
  color: #6366f1;
  transition: opacity 0.2s ease;
  letter-spacing: -0.01em;
}

.typing-indicator {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 2px 0 6px;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a855f7, #6366f1);
  display: inline-block;
  animation: dotWave 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
  animation-delay: -0.16s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0s;
}

@keyframes dotWave {
  0%,
  80%,
  100% {
    transform: translateY(0) scale(0.85);
    opacity: 0.4;
  }
  40% {
    transform: translateY(-6px) scale(1.15);
    opacity: 1;
    box-shadow: 0 0 8px rgba(168, 85, 247, 0.6);
  }
}

.thinking-shimmer-track {
  width: 100%;
  height: 3px;
  background: #f1f5f9;
  border-radius: 3px;
  overflow: hidden;
  position: relative;
  margin-top: 4px;
}

.thinking-shimmer-bar {
  width: 45%;
  height: 100%;
  background: linear-gradient(90deg, transparent, #8b5cf6, transparent);
  border-radius: 3px;
  position: absolute;
  left: -45%;
  animation: shimmerFlow 1.6s ease-in-out infinite;
}

@keyframes shimmerFlow {
  0% {
    left: -45%;
  }
  100% {
    left: 100%;
  }
}

/* ============================================================
   SUGGESTIONS
   ============================================================ */

#chatbot-suggestions {
  display: flex;

  gap: 7px;

  padding: 10px 12px;

  overflow-x: auto;

  border-top: 1px solid #e5e7eb;

  background: #ffffff;

  scrollbar-width: none;
}

#chatbot-suggestions::-webkit-scrollbar {
  display: none;
}

.suggestion-btn {
  flex-shrink: 0;

  padding: 7px 12px;

  border-radius: 20px;

  border: 1px solid #e2e8f0;

  background: #f8fafc;

  color: #475569;

  font-size: 12px;
  font-weight: 500;

  cursor: pointer;

  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    transform 0.15s ease;
}

.suggestion-btn:hover {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #4338ca;
  transform: translateY(-1px);
}

/* ============================================================
   INPUT AREA
   ============================================================ */

.chatbot-input-area {
  display: flex;

  align-items: flex-end;

  gap: 8px;

  padding: 10px 12px;

  border-top: 1px solid #e5e7eb;

  background: #ffffff;
}

#chatbot-input {
  flex: 1;

  resize: none;

  min-height: 40px;
  max-height: 100px;

  padding: 9px 12px;

  border: 1px solid #d1d5db;

  border-radius: 12px;

  outline: none;

  font-family: inherit;

  font-size: 13.5px;

  line-height: 1.4;

  box-sizing: border-box;

  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

#chatbot-input:focus {
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

#chatbot-send {
  width: 40px;
  height: 40px;

  flex-shrink: 0;

  border: none;

  border-radius: 12px;

  background: linear-gradient(135deg, #111827 0%, #312e81 100%);

  color: #ffffff;

  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    opacity 0.2s ease;
}

#chatbot-send:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(49, 46, 129, 0.35);
}

#chatbot-send:active {
  transform: translateY(0);
}

#chatbot-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ============================================================
   FOOTER
   ============================================================ */

.chatbot-footer {
  text-align: center;

  padding: 6px;

  font-size: 11px;

  color: #94a3b8;

  background: #ffffff;
}

/* ============================================================
   MOBILE RESPONSIVENESS
   ============================================================ */

@media (max-width: 600px) {
  #portfolio-chatbot {
    right: 15px;
    bottom: 15px;
  }

  #chatbot-window {
    right: 0;
    bottom: 72px;

    width: calc(100vw - 30px);

    height: min(560px, calc(100vh - 100px));

    border-radius: 16px;
  }

  #chatbot-toggle {
    width: 56px;
    height: 56px;
  }
}
