/* =========================
   CHATBOT CONTAINER
========================= */

.chatbot {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 9999;
}


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

.chatbot-toggle {
  width: 64px;
  height: 64px;

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

  padding: 0;

  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: 50%;

  background: linear-gradient(
    145deg,
    #2563eb,
    #1d4ed8
  );

  color: white;

  cursor: pointer;

  box-shadow:
    0 8px 25px rgba(37, 99, 235, 0.28),
    0 2px 8px rgba(0, 0, 0, 0.08);

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

.chatbot-toggle:hover {
  transform: translateY(-3px);

  box-shadow:
    0 12px 30px rgba(37, 99, 235, 0.35),
    0 4px 10px rgba(0, 0, 0, 0.08);
}

.chatbot-toggle svg {
  width: 42px;
  height: 42px;
}


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

.chatbot-window {
  position: absolute;

  right: 0;
  bottom: 78px;

  width: 430px;

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

  display: none;
  flex-direction: column;

  overflow: hidden;

  background: #ffffff;

  border: 1px solid rgba(0, 0, 0, 0.10);
  border-radius: 26px;

  box-shadow:
    0 25px 60px rgba(0, 0, 0, 0.16),
    0 8px 20px rgba(0, 0, 0, 0.08);

  animation: chatbotOpen 0.22s ease;
}

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

@keyframes chatbotOpen {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }

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


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

.chatbot-header {
  position: relative;

  display: flex;
  align-items: center;

  gap: 14px;

  min-height: 110px;

  padding: 20px 22px;

  color: white;

  background:
    radial-gradient(
      circle at 85% 20%,
      rgba(255, 255, 255, 0.12),
      transparent 35%
    ),
    linear-gradient(
      135deg,
      #2563eb,
      #1d4ed8
    );

  overflow: hidden;
}

.chatbot-header::after {
  content: "";

  position: absolute;

  width: 220px;
  height: 220px;

  right: -80px;
  top: -120px;

  border-radius: 50%;

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


/* Header Avatar */

.chatbot-avatar {
  position: relative;

  width: 62px;
  height: 62px;

  flex-shrink: 0;

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

  border-radius: 50%;

  background: rgba(255, 255, 255, 0.14);

  border: 1px solid rgba(255, 255, 255, 0.28);

  backdrop-filter: blur(8px);
}

.chatbot-avatar svg {
  width: 52px;
  height: 52px;
}


/* Header text */

.chatbot-header-info {
  position: relative;
  z-index: 2;

  display: flex;
  flex-direction: column;

  gap: 4px;
}

.chatbot-header-info strong {
  font-size: 22px;
  font-weight: 700;

  line-height: 1.1;
}

.chatbot-header-info span {
  font-size: 14px;

  color: rgba(255, 255, 255, 0.78);
}


/* Close */

.chatbot-close {
  position: absolute;

  top: 20px;
  right: 20px;

  z-index: 5;

  width: 34px;
  height: 34px;

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

  padding: 0;

  border: none;
  border-radius: 10px;

  background: transparent;

  color: white;

  font-size: 27px;
  line-height: 1;

  cursor: pointer;

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

.chatbot-close:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: rotate(4deg);
}


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

.chatbot-messages {
  flex: 1;

  display: flex;
  flex-direction: column;

  gap: 16px;

  padding: 22px 18px;

  overflow-y: auto;

  background: #fbfcff;
}

.chatbot-messages::-webkit-scrollbar {
  width: 5px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 10px;
}


/* Message row */

.chat-message-row {
  display: flex;

  align-items: flex-end;

  gap: 9px;

  width: 100%;
}

.chat-message-row.user {
  justify-content: flex-end;
}

.chat-message-row.bot {
  justify-content: flex-start;
}


/* Small AI avatar */

.chat-message-avatar {
  width: 34px;
  height: 34px;

  flex-shrink: 0;

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

  border-radius: 50%;

  background: #eef4ff;

  border: 1px solid rgba(37, 99, 235, 0.18);
}

.chat-message-avatar svg {
  width: 29px;
  height: 29px;
}


/* Bubble */

.chat-message {
  max-width: 78%;

  padding: 12px 15px;

  font-size: 14px;
  line-height: 1.55;

  word-break: break-word;

  border-radius: 16px;

  animation: messageIn 0.2s ease;
}


/* AI */

.chat-message.bot {
  color: #172033;

  background: #ffffff;

  border: 1.5px solid #d7deea;

  border-bottom-left-radius: 5px;

  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.035);
}


/* User */

.chat-message.user {
  color: #ffffff;

  background: linear-gradient(
    135deg,
    #2563eb,
    #1d4ed8
  );

  border: 1px solid rgba(29, 78, 216, 0.4);

  border-bottom-right-radius: 5px;

  box-shadow:
    0 4px 12px rgba(37, 99, 235, 0.16);
}


@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

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


/* =========================
   LOADING
========================= */

.chat-message.loading {
  display: flex;

  align-items: center;

  gap: 5px;

  min-width: 56px;

  padding: 14px 15px;
}

.loading-dot {
  width: 6px;
  height: 6px;

  border-radius: 50%;

  background: #6b7280;

  animation: typing 1.2s infinite ease-in-out;
}

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

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

@keyframes typing {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }

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


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

.chatbot-input {
  display: flex;

  align-items: center;

  gap: 10px;

  padding: 14px 16px;

  background: #ffffff;

  border-top: 1px solid #e5e9f0;
}

.chatbot-input input {
  flex: 1;

  min-width: 0;

  height: 48px;

  padding: 0 15px;

  border: 1.5px solid #d8e0ec;
  border-radius: 13px;

  outline: none;

  background: #ffffff;

  color: #172033;

  font-family: inherit;
  font-size: 14px;

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

.chatbot-input input::placeholder {
  color: #9aa3b2;
}

.chatbot-input input:focus {
  border-color: #2563eb;

  box-shadow:
    0 0 0 3px rgba(37, 99, 235, 0.08);
}


/* Send */

.chatbot-input button {
  width: 48px;
  height: 48px;

  flex-shrink: 0;

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

  border: none;
  border-radius: 13px;

  background: #2563eb;

  color: white;

  cursor: pointer;

  font-size: 20px;

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

.chatbot-input button:hover {
  background: #1d4ed8;

  transform: translateY(-1px);
}

.chatbot-input button:disabled {
  opacity: 0.5;

  cursor: not-allowed;

  transform: none;
}


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

@media (max-width: 600px) {
  .chatbot {
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
  }

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

  .chatbot-toggle svg {
    width: 36px;
    height: 36px;
  }

  .chatbot-window {
    position: fixed;

    right: 10px;
    left: 10px;
    bottom: calc(80px + env(safe-area-inset-bottom));
    top: env(safe-area-inset-top, 0px);

    width: auto;
    height: auto;

    max-height: calc(100dvh - 96px - env(safe-area-inset-bottom));

    border-radius: 20px;
  }

  .chatbot-header {
    min-height: 84px;

    padding: 16px 18px;
    gap: 11px;
  }

  .chatbot-avatar {
    width: 46px;
    height: 46px;
  }

  .chatbot-avatar svg {
    width: 38px;
    height: 38px;
  }

  .chatbot-header-info strong {
    font-size: 17px;
  }

  .chatbot-header-info span {
    font-size: 12.5px;
  }

  .chatbot-close {
    top: 15px;
    right: 12px;

    width: 36px;
    height: 36px;
  }

  .chatbot-messages {
    padding: 16px 14px;
    gap: 12px;
  }

  .chat-message-avatar {
    width: 28px;
    height: 28px;
  }

  .chat-message-avatar svg {
    width: 24px;
    height: 24px;
  }

  .chat-message {
    max-width: 84%;

    padding: 10px 13px;

    font-size: 13.5px;
  }

  .chatbot-input {
    padding: 10px 12px;

    gap: 8px;

    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  .chatbot-input input {
    height: 44px;

    font-size: 16px;
  }

  .chatbot-input button {
    width: 44px;
    height: 44px;

    flex-shrink: 0;
  }
}


@media (max-width: 380px) {
  .chatbot-window {
    right: 6px;
    left: 6px;

    border-radius: 16px;
  }

  .chatbot-header {
    min-height: 76px;

    padding: 14px 14px;
  }

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

  .chatbot-avatar svg {
    width: 32px;
    height: 32px;
  }

  .chatbot-header-info strong {
    font-size: 15.5px;
  }

  .chat-message {
    max-width: 88%;

    font-size: 13px;
  }
}