/* ---------------------------------------------------------
   Portfolio Chatbot Widget
   Add this file to your site and link it, e.g.:
   <link rel="stylesheet" href="chatbot-widget.css">
--------------------------------------------------------- */

#chatbot-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #37d6c8;
  color: #0a0f1a;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

#chatbot-toggle:hover {
  transform: scale(1.06);
}

#chatbot-window {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 320px;
  max-width: calc(100vw - 32px);
  height: 440px;
  max-height: calc(100vh - 140px);
  background: #0f1420;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  font-family: system-ui, sans-serif;
}

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

#chatbot-header {
  background: #151b2b;
  color: #fff;
  padding: 12px 14px;
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#chatbot-close {
  background: none;
  border: none;
  color: #aaa;
  font-size: 1.1rem;
  cursor: pointer;
}

#chatbot-messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chatbot-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.4;
  white-space: pre-wrap;
}

.chatbot-msg.user {
  align-self: flex-end;
  background: #37d6c8;
  color: #0a0f1a;
  border-bottom-right-radius: 2px;
}

.chatbot-msg.bot {
  align-self: flex-start;
  background: #1c2436;
  color: #eee;
  border-bottom-left-radius: 2px;
}

/* Loading bubbles (three bouncing dots) shown while waiting for a reply */
.chatbot-msg.bot.typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 14px;
  color: #8a94a8; /* dots inherit this via currentColor */
}

.chatbot-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
  animation: chatbot-dot-bounce 1.2s infinite ease-in-out;
}

.chatbot-dot:nth-child(2) { animation-delay: 0.15s; }
.chatbot-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatbot-dot-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chatbot-dot {
    animation: chatbot-dot-fade 1.4s infinite ease-in-out;
  }
  @keyframes chatbot-dot-fade {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
  }
}

#chatbot-input-row {
  display: flex;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px;
  gap: 6px;
}

#chatbot-input {
  flex: 1;
  background: #1c2436;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #fff;
  padding: 8px 10px;
  font-size: 0.85rem;
  resize: none;
}

#chatbot-send {
  background: #37d6c8;
  border: none;
  border-radius: 8px;
  padding: 0 14px;
  color: #0a0f1a;
  font-weight: 600;
  cursor: pointer;
}

#chatbot-send:disabled {
  opacity: 0.5;
  cursor: default;
}

.chatbot-msg.bot a {
  color: #37d6c8;
  text-decoration: underline;
  font-weight: 600;
  word-break: break-word;
}

.chatbot-msg.bot a:hover {
  color: #6be8db;
}
/* ---------------------------------------------------------
   Desktop-only teaser bubble pointing at the chat toggle
--------------------------------------------------------- */

#chatbot-teaser {
  position: fixed;
  bottom: 70px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 9998;
  animation: chatbot-teaser-in 0.4s ease;
}

@keyframes chatbot-teaser-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#chatbot-teaser-close {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #fff;
  color: #333;
  border: none;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.chatbot-teaser-bubble {
  background: #fff;
  color: #111;
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

/* Desktop-only: hide the teaser entirely on mobile/narrow viewports */
@media (max-width: 768px) {
  #chatbot-teaser {
    display: none !important;
  }
}

/* ---------------------------------------------------------
   Mobile: full-screen chat window (like a native chat sheet)
   instead of a small floating box.
--------------------------------------------------------- */

@media (max-width: 768px) {
  #chatbot-window.open {
    position: fixed;
    inset: 0;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
    z-index: 10000;
  }

  #chatbot-header {
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    padding-bottom: 14px;
    flex-shrink: 0;
  }

  #chatbot-header span {
    font-size: 1.05rem;
  }

  #chatbot-close {
    font-size: 1.6rem;
  }

  #chatbot-messages {
    padding: 16px;
  }

  #chatbot-input-row {
    padding: 10px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    flex-shrink: 0;
  }

  #chatbot-input {
    font-size: 1rem;
    padding: 10px 12px;
  }

  /* Hide the floating launcher bubble while the full-screen chat is open,
     so it doesn't float on top of the fullscreen header. */
  body.chatbot-open #chatbot-toggle {
    display: none;
  }
}

/* ---------------------------------------------------------
   Light mode support
   Everything above is styled for the dark theme baked in as
   the default. This follows the same [data-theme="light"]
   attribute the rest of the site toggles on <html>, so the
   widget switches to light surfaces alongside the page.
--------------------------------------------------------- */

:root[data-theme="light"] #chatbot-window {
  background: #ffffff;
  border-color: #DBE1EC;
}

:root[data-theme="light"] #chatbot-header {
  background: #F5F7FB;
  color: #101828;
  border-bottom-color: #DBE1EC;
}

:root[data-theme="light"] #chatbot-close {
  color: #5B6478;
}

:root[data-theme="light"] #chatbot-messages {
  background: #ffffff;
}

:root[data-theme="light"] .chatbot-msg.bot {
  background: #EDF1F7;
  color: #101828;
}

:root[data-theme="light"] .chatbot-msg.bot.typing {
  color: #5B6478;
}

:root[data-theme="light"] #chatbot-input-row {
  border-top-color: #DBE1EC;
}

:root[data-theme="light"] #chatbot-input {
  background: #EDF1F7;
  border-color: #DBE1EC;
  color: #101828;
}

:root[data-theme="light"] #chatbot-input::placeholder {
  color: #5B6478;
}
