/* =========================================================
   EDUXAE AI ASSISTANT
   Responsive • Desktop • Tablet • Mobile
   ========================================================= */

#eduxaeAi {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 99999;
  font-family: "DM Sans", sans-serif;
}


/* =========================================================
   FLOATING BUTTON
   ========================================================= */

#eduxaeAiButton {
  border: 0;
  outline: none;
  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;

  padding: 13px 19px;

  min-height: 48px;

  border-radius: 999px;

  background: linear-gradient(
    135deg,
    #315efb,
    #2450df
  );

  color: #ffffff;

  font-family: inherit;
  font-size: 14px;
  font-weight: 700;

  box-shadow:
    0 12px 35px rgba(49, 94, 251, 0.28);

  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

#eduxaeAiButton:hover {
  transform: translateY(-2px);

  background: linear-gradient(
    135deg,
    #3c68ff,
    #2855e8
  );

  box-shadow:
    0 16px 40px rgba(49, 94, 251, 0.38);
}

#eduxaeAiButton:active {
  transform: translateY(0);
}

#eduxaeAiButton:focus-visible {
  box-shadow:
    0 0 0 4px rgba(49, 94, 251, 0.18),
    0 12px 35px rgba(49, 94, 251, 0.28);
}

.ai-spark {
  font-size: 18px;
  line-height: 1;
}


/* =========================================================
   CHAT WINDOW
   ========================================================= */

.ai-chat-window {
  position: absolute;

  right: 0;
  bottom: 64px;

  width: 390px;
  max-width: calc(100vw - 30px);

  height: 590px;
  max-height: calc(100vh - 110px);

  display: flex;
  flex-direction: column;

  background: #ffffff;

  border: 1px solid #e8ecf5;
  border-radius: 22px;

  overflow: hidden;

  box-shadow:
    0 25px 80px rgba(15, 30, 70, 0.18);

  opacity: 0;
  visibility: hidden;

  pointer-events: none;

  transform:
    translateY(15px)
    scale(0.98);

  transform-origin: bottom right;

  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    visibility 0.2s ease;
}

.ai-chat-window.open {
  opacity: 1;
  visibility: visible;

  pointer-events: auto;

  transform:
    translateY(0)
    scale(1);
}


/* =========================================================
   HEADER
   ========================================================= */

.ai-chat-header {
  flex: 0 0 auto;

  min-height: 72px;

  padding: 15px 17px;

  display: flex;
  align-items: center;
  justify-content: space-between;

  background:
    linear-gradient(
      135deg,
      #315efb,
      #4d72ff
    );

  color: #ffffff;
}

.ai-chat-brand {
  display: flex;
  align-items: center;
  gap: 11px;

  min-width: 0;
}

.ai-logo {
  width: 40px;
  height: 40px;

  flex: 0 0 40px;

  border-radius: 12px;

  display: grid;
  place-items: center;

  background: rgba(255, 255, 255, 0.18);

  font-size: 20px;
}

.ai-chat-brand > div:last-child {
  min-width: 0;
}

.ai-chat-brand strong {
  display: block;

  font-size: 15px;
  font-weight: 700;

  white-space: nowrap;
}

.ai-chat-brand span {
  display: block;

  margin-top: 2px;

  font-size: 11px;

  opacity: 0.82;

  white-space: nowrap;
}


/* CLOSE BUTTON */

#aiCloseButton {
  width: 34px;
  height: 34px;

  flex: 0 0 34px;

  border: 0;
  outline: none;

  border-radius: 50%;

  background: rgba(255, 255, 255, 0.14);

  color: #ffffff;

  cursor: pointer;

  display: grid;
  place-items: center;

  font-size: 24px;
  line-height: 1;

  transition:
    background 0.2s ease,
    transform 0.2s ease;
}

#aiCloseButton:hover {
  background: rgba(255, 255, 255, 0.24);
  transform: rotate(90deg);
}

#aiCloseButton:focus-visible {
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.3);
}


/* =========================================================
   MESSAGES AREA
   ========================================================= */

.ai-messages {
  flex: 1 1 auto;

  min-height: 0;

  overflow-y: auto;
  overflow-x: hidden;

  padding: 20px;

  background: #f8faff;

  scroll-behavior: smooth;

  scrollbar-width: thin;
  scrollbar-color: #d7def2 transparent;
}

.ai-messages::-webkit-scrollbar {
  width: 6px;
}

.ai-messages::-webkit-scrollbar-track {
  background: transparent;
}

.ai-messages::-webkit-scrollbar-thumb {
  background: #d7def2;
  border-radius: 999px;
}


/* =========================================================
   AI MESSAGE
   ========================================================= */

.ai-message {
  display: flex;

  align-items: flex-start;

  gap: 9px;

  margin-bottom: 15px;

  animation: aiMessageIn 0.2s ease;
}

@keyframes aiMessageIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ai-message-avatar {
  flex: 0 0 30px;

  width: 30px;
  height: 30px;

  border-radius: 9px;

  display: grid;
  place-items: center;

  background: #e8edff;

  color: #315efb;

  font-size: 13px;
  font-weight: 800;
}

.ai-bubble {
  max-width: 82%;

  padding: 12px 14px;

  background: #ffffff;

  border: 1px solid #e9edf5;

  border-radius: 5px 15px 15px 15px;

  color: #172033;

  font-size: 13px;

  line-height: 1.55;

  overflow-wrap: anywhere;

  box-shadow:
    0 3px 12px rgba(20, 40, 80, 0.04);
}

.ai-bubble strong {
  font-size: 13px;
}

.ai-bubble p {
  margin: 6px 0 0;
}

.ai-bubble p:first-child {
  margin-top: 0;
}

.ai-bubble ul,
.ai-bubble ol {
  margin: 7px 0;
  padding-left: 20px;
}

.ai-bubble li {
  margin-bottom: 4px;
}


/* =========================================================
   USER MESSAGE
   ========================================================= */

.ai-user-message {
  justify-content: flex-end;
}

.ai-user-message .ai-bubble {
  max-width: 82%;

  color: #ffffff;

  background: #315efb;

  border: none;

  border-radius: 15px 5px 15px 15px;

  box-shadow:
    0 4px 14px rgba(49, 94, 251, 0.15);
}


/* =========================================================
   SUGGESTIONS
   ========================================================= */

.ai-suggestions {
  display: flex;

  flex-wrap: wrap;

  gap: 7px;

  margin-left: 39px;
  margin-bottom: 15px;
}

.ai-suggestions button {
  border: 1px solid #dce4ff;

  background: #ffffff;

  color: #315efb;

  border-radius: 999px;

  padding: 8px 11px;

  font-family: inherit;

  font-size: 11px;
  font-weight: 600;

  cursor: pointer;

  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.15s ease;
}

.ai-suggestions button:hover {
  background: #eef2ff;

  border-color: #cbd7ff;

  transform: translateY(-1px);
}

.ai-suggestions button:active {
  transform: translateY(0);
}


/* =========================================================
   TYPING INDICATOR
   ========================================================= */

.ai-typing {
  display: none;

  align-items: center;

  gap: 4px;

  padding: 0 20px 10px;

  background: #f8faff;

  color: #7b8498;

  font-size: 10px;
}

.ai-typing.active {
  display: flex;
}

.ai-typing span {
  width: 5px;
  height: 5px;

  border-radius: 50%;

  background: #315efb;

  animation: aiDot 1.2s infinite;
}

.ai-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.ai-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes aiDot {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }

  30% {
    transform: translateY(-4px);
  }
}

.ai-typing em {
  margin-left: 5px;

  font-style: normal;
}


/* =========================================================
   INPUT AREA
   ========================================================= */

.ai-chat-input {
  flex: 0 0 auto;

  display: flex;

  gap: 8px;

  padding: 12px;

  background: #ffffff;

  border-top: 1px solid #edf0f5;
}

#aiInput {
  flex: 1;

  min-width: 0;

  min-height: 42px;

  border: 1px solid #e1e6ef;

  outline: none;

  border-radius: 12px;

  padding: 11px 13px;

  font-family: inherit;

  font-size: 13px;

  color: #172033;

  background: #ffffff;

  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

#aiInput::placeholder {
  color: #9aa2b2;
}

#aiInput:focus {
  border-color: #315efb;

  box-shadow:
    0 0 0 3px rgba(49, 94, 251, 0.08);
}


/* SEND BUTTON */

#aiSendButton {
  width: 42px;
  height: 42px;

  flex: 0 0 42px;

  border: 0;
  outline: none;

  border-radius: 12px;

  background: #315efb;

  color: #ffffff;

  font-size: 20px;

  cursor: pointer;

  display: grid;
  place-items: center;

  transition:
    background 0.2s ease,
    transform 0.15s ease,
    box-shadow 0.2s ease;
}

#aiSendButton:hover:not(:disabled) {
  background: #2855e8;

  transform: translateY(-1px);

  box-shadow:
    0 5px 15px rgba(49, 94, 251, 0.22);
}

#aiSendButton:active:not(:disabled) {
  transform: translateY(0);
}

#aiSendButton:disabled {
  opacity: 0.5;

  cursor: not-allowed;
}


/* =========================================================
   FOOTER
   ========================================================= */

.ai-footer {
  flex: 0 0 auto;

  text-align: center;

  padding: 6px;

  font-size: 9px;

  color: #9aa2b2;

  background: #ffffff;
}


/* =========================================================
   TABLET
   ========================================================= */

@media (max-width: 768px) {

  #eduxaeAi {
    right: 18px;
    bottom: 18px;
  }

  .ai-chat-window {
    width: 380px;
    max-width: calc(100vw - 36px);

    height: min(590px, calc(100vh - 105px));
  }
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 600px) {

  #eduxaeAi {
    right: 15px;
    bottom: 15px;
  }

  #eduxaeAiButton {
    padding: 12px 15px;

    min-height: 46px;

    font-size: 13px;
  }

  .ai-chat-window {
    right: 0;
    bottom: 58px;

    width: calc(100vw - 30px);

    max-width: calc(100vw - 30px);

    height: min(600px, calc(100vh - 100px));

    max-height: calc(100vh - 100px);

    border-radius: 20px;
  }

  .ai-chat-header {
    min-height: 66px;

    padding: 13px 14px;
  }

  .ai-logo {
    width: 37px;
    height: 37px;

    flex-basis: 37px;

    border-radius: 11px;

    font-size: 18px;
  }

  .ai-chat-brand strong {
    font-size: 14px;
  }

  .ai-chat-brand span {
    font-size: 10px;
  }

  #aiCloseButton {
    width: 32px;
    height: 32px;

    flex-basis: 32px;

    font-size: 22px;
  }

  .ai-messages {
    padding: 15px;
  }

  .ai-bubble {
    max-width: 86%;

    padding: 11px 12px;

    font-size: 12.5px;
  }

  .ai-user-message .ai-bubble {
    max-width: 86%;
  }

  .ai-suggestions {
    margin-left: 39px;

    gap: 6px;
  }

  .ai-suggestions button {
    padding: 7px 10px;

    font-size: 10.5px;
  }

  .ai-chat-input {
    padding: 10px;
  }

  #aiInput {
    min-height: 40px;

    padding: 10px 12px;

    font-size: 12px;
  }

  #aiSendButton {
    width: 40px;
    height: 40px;

    flex-basis: 40px;
  }

  .ai-footer {
    padding: 5px;

    font-size: 8px;
  }
}


/* =========================================================
   VERY SMALL PHONES
   ========================================================= */

@media (max-width: 380px) {

  #eduxaeAi {
    right: 10px;
    bottom: 10px;
  }

  #eduxaeAiButton {
    padding: 11px 13px;

    font-size: 12px;
  }

  .ai-chat-window {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);

    bottom: 55px;

    height: calc(100vh - 85px);

    max-height: calc(100vh - 85px);

    border-radius: 18px;
  }

  .ai-messages {
    padding: 12px;
  }

  .ai-bubble {
    max-width: 88%;

    font-size: 12px;
  }

  .ai-suggestions {
    margin-left: 35px;
  }
}


/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

  #eduxaeAiButton,
  .ai-chat-window,
  #aiCloseButton,
  #aiSendButton,
  .ai-suggestions button,
  .ai-message {
    transition: none;
    animation: none;
  }

  .ai-messages {
    scroll-behavior: auto;
  }
}