/* AI customer service */
.ai-chat {
  position: fixed;
  right: calc(20px + env(safe-area-inset-right, 0px));
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  z-index: 1040;
  font-family: var(--insuba-font, "Roboto", sans-serif);
  color: #17324d;
}

.ai-chat *,
.ai-chat *::before,
.ai-chat *::after {
  box-sizing: border-box;
}

.ai-chat__launcher {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 48px;
  padding: 0 16px 0 12px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #0f3260 0%, #0365d3 100%);
  color: #ffffff;
  box-shadow: 0 8px 24px rgba(3, 101, 211, 0.28);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, filter 180ms ease;
  -webkit-tap-highlight-color: transparent;
}

.ai-chat__launcher:hover,
.ai-chat__launcher:focus {
  filter: brightness(1.05);
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(3, 101, 211, 0.34);
}

.ai-chat__launcher:focus-visible {
  outline: 3px solid #ffb703;
  outline-offset: 4px;
}

.ai-chat__launcher-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
}

.ai-chat__launcher-text {
  white-space: nowrap;
}

.ai-chat__panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 40px));
  height: 560px;
  max-height: calc(100vh - 180px);
  max-height: calc(100dvh - 180px);
  border: 1px solid rgba(15, 50, 96, 0.1);
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(15, 50, 96, 0.24);
  overflow: hidden;
  z-index: 1050;
  animation: ai-chat-pop 180ms ease-out both;
}

.ai-chat__panel[hidden] {
  display: none !important;
}

@keyframes ai-chat-pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.ai-chat__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 14px 15px 16px;
  background: linear-gradient(135deg, #0f3260 0%, #0365d3 100%);
  color: #ffffff;
}

.ai-chat__identity {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ai-chat__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.14);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.ai-chat__identity-text {
  min-width: 0;
}

.ai-chat__title {
  margin: 0;
  color: #ffffff;
  font-family: var(--insuba-font2, "Rubik", sans-serif);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}

.ai-chat__status {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 4px 0 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 11px;
  line-height: 1.3;
}

.ai-chat__status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6ee7b7;
  box-shadow: 0 0 0 3px rgba(110, 231, 183, 0.16);
}

.ai-chat__header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}

.ai-chat__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #ffffff;
  cursor: pointer;
  transition: background-color 150ms ease;
}

.ai-chat__icon-btn:hover,
.ai-chat__icon-btn:focus {
  background: rgba(255, 255, 255, 0.14);
}

.ai-chat__icon-btn:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.ai-chat__messages {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: linear-gradient(180deg, #f8fbff 0%, #f3f7fc 100%);
  scroll-behavior: smooth;
}

.ai-chat__message {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  max-width: 100%;
}

.ai-chat__message--user {
  justify-content: flex-end;
}

.ai-chat__mini-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 27px;
  width: 27px;
  height: 27px;
  border-radius: 9px;
  background: #0f3260;
  color: #ffffff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.ai-chat__message-body {
  max-width: calc(100% - 36px);
}

.ai-chat__message--user .ai-chat__message-body {
  max-width: 82%;
}

.ai-chat__bubble {
  padding: 10px 12px;
  border: 1px solid #e4edf8;
  border-radius: 15px 15px 15px 5px;
  background: #ffffff;
  color: #2d4055;
  box-shadow: 0 3px 10px rgba(15, 50, 96, 0.045);
  font-size: 13.5px;
  line-height: 1.62;
}

.ai-chat__message--user .ai-chat__bubble {
  border-color: #0365d3;
  border-radius: 15px 15px 5px 15px;
  background: #0365d3;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(3, 101, 211, 0.16);
}

.ai-chat__text {
  margin: 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.ai-chat__links {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-top: 9px;
}

.ai-chat__link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 7px 10px;
  border: 1px solid #cfe3fb;
  border-radius: 9px;
  background: #eef6ff;
  color: #0759b4;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.35;
  text-decoration: none;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.ai-chat__link::after {
  content: "›";
  font-size: 15px;
  line-height: 1;
}

.ai-chat__link:hover,
.ai-chat__link:focus {
  border-color: #9dc8f5;
  background: #e2f0ff;
  color: #054b97;
}

.ai-chat__link--wa {
  border-color: #bfe9cd;
  background: #eafaf0;
  color: #128044;
}

.ai-chat__link--wa:hover,
.ai-chat__link--wa:focus {
  border-color: #8ed8a8;
  background: #ddf7e7;
  color: #0c6435;
}

.ai-chat__typing-bubble {
  padding: 13px 14px;
}

.ai-chat__typing {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 10px;
}

.ai-chat__typing span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #8ba2bb;
  animation: ai-chat-bounce 1.1s infinite ease-in-out;
}

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

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

@keyframes ai-chat-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.ai-chat__quick {
  display: flex;
  gap: 7px;
  padding: 9px 12px 0;
  overflow-x: auto;
  background: #ffffff;
  scrollbar-width: none;
}

.ai-chat__quick::-webkit-scrollbar {
  display: none;
}

.ai-chat__quick button {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid #d8e6f7;
  border-radius: 999px;
  background: #f5f9ff;
  color: #315c86;
  font-family: inherit;
  font-size: 11.5px;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.ai-chat__quick button:hover,
.ai-chat__quick button:focus {
  border-color: #9dc8f5;
  background: #eaf4ff;
}

.ai-chat__form {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 12px 7px;
  background: #ffffff;
}

.ai-chat__form input {
  flex: 1 1 auto;
  min-width: 0;
  height: 40px;
  padding: 0 14px;
  border: 1px solid #d6e3f2;
  border-radius: 999px;
  background: #f8fbff;
  color: #17324d;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

.ai-chat__form input::placeholder {
  color: #93a5b8;
}

.ai-chat__form input:focus {
  border-color: #5aa8f5;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(3, 101, 211, 0.1);
}

.ai-chat__send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #0365d3;
  color: #ffffff;
  cursor: pointer;
  transition: background-color 150ms ease, transform 150ms ease, opacity 150ms ease;
}

.ai-chat__send:hover,
.ai-chat__send:focus {
  background: #0759b4;
  transform: scale(1.03);
}

.ai-chat__send:disabled {
  cursor: wait;
  opacity: 0.55;
}

.ai-chat__send:focus-visible {
  outline: 2px solid #0f3260;
  outline-offset: 2px;
}

.ai-chat__note {
  margin: 0;
  padding: 0 12px 10px;
  background: #ffffff;
  color: #98a6b6;
  font-size: 10px;
  line-height: 1.4;
  text-align: center;
}

@media (max-width: 991px) {
  .ai-chat {
    right: calc(12px + env(safe-area-inset-right, 0px));
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  }

  .ai-chat__launcher {
    min-height: 46px;
    padding: 0 14px 0 10px;
    font-size: 13px;
  }

  .ai-chat__launcher-icon {
    width: 24px;
    height: 24px;
  }
}

@media (max-width: 767px) {
  body.ai-chat-open {
    overflow: hidden;
  }

  .ai-chat__panel {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
  }

  .ai-chat__header {
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
  }

  .ai-chat__messages {
    padding: 14px 12px;
  }

  .ai-chat__quick {
    padding-left: 10px;
    padding-right: 10px;
  }

  .ai-chat__form {
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .ai-chat__note {
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .course-has-mobile-cta .ai-chat {
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 380px) {
  .ai-chat__launcher-text {
    display: none;
  }

  .ai-chat__launcher {
    width: 48px;
    padding: 0;
  }

  .ai-chat__panel {
    border-radius: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ai-chat__panel,
  .ai-chat__typing span {
    animation: none;
  }

  .ai-chat__launcher,
  .ai-chat__send,
  .ai-chat__link,
  .ai-chat__quick button,
  .ai-chat__icon-btn {
    transition: none;
  }
}
