/* ============================================================
   AI CHATBOT PUBLIC - SILEBAT
   Fokus: floating chatbot, responsif mobile, dan proporsi pop-up.
============================================================ */
.chat-fab {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 9999;
}

.chat-toggle {
  width: 86px;
  height: 92px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--navy);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 1.45rem;
  transition: transform .3s ease;
}

.chat-toggle:hover {
  transform: scale(1.08);
}

.chat-toggle .chat-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter:
    drop-shadow(0 10px 18px rgba(16, 62, 111, .28))
    drop-shadow(0 2px 5px rgba(4, 18, 36, .18));
  transition: filter .3s ease;
}

.chat-toggle:hover .chat-icon {
  filter:
    drop-shadow(0 14px 24px rgba(16, 62, 111, .34))
    drop-shadow(0 4px 8px rgba(4, 18, 36, .2));
}

.chat-window {
  display: none;
  position: absolute;
  right: 0;
  bottom: 106px;
  width: min(360px, calc(100vw - 40px));
  height: min(520px, calc(100dvh - 132px));
  min-height: 390px;
  max-height: 560px;
  overflow: hidden;
  border: 1px solid #e0eaf3;
  border-radius: 20px;
  background: var(--white);
  box-shadow: 0 16px 60px rgba(16, 62, 111, .22);
  flex-direction: column;
}

.chat-window.open {
  display: flex;
  animation: chatSlideUp .3s ease;
}

@keyframes chatSlideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  background: linear-gradient(135deg, var(--navy), #1a5c9c);
  color: var(--white);
}

.chat-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .9);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(4, 18, 36, .16);
}

.chat-avatar img {
  width: 92%;
  height: 92%;
  object-fit: contain;
}

.chat-head-text {
  min-width: 0;
}

.chat-head-text .t1 {
  font-size: .88rem;
  font-weight: 600;
  line-height: 1.25;
}

.chat-head-text .t2 {
  margin-top: 2px;
  font-size: .72rem;
  line-height: 1.25;
  opacity: .75;
}

.chat-online {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  margin-left: auto;
  border-radius: 50%;
  background: #4ade80;
}

.chat-close {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  color: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .78rem;
  transition: background-color .2s ease, transform .2s ease;
}

.chat-close:hover {
  background: rgba(255, 255, 255, .28);
  transform: scale(1.05);
}

.chat-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overscroll-behavior: contain;
}

.chat-body::-webkit-scrollbar {
  width: 4px;
}

.chat-body::-webkit-scrollbar-thumb {
  border-radius: 2px;
  background: #d0dae4;
}

.msg {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 12px;
  font-size: .83rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.msg.bot {
  border-radius: 4px 12px 12px 12px;
  background: var(--offwhite);
  color: #1a2b3c;
}

.msg.user {
  margin-left: auto;
  border-radius: 12px 12px 4px 12px;
  background: var(--navy);
  color: var(--white);
}

.chat-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #e9eff5;
  background: var(--white);
}

.chat-input {
  min-width: 0;
  flex: 1 1 auto;
  border: 1.5px solid #d1dbe6;
  border-radius: 10px;
  padding: 9px 12px;
  outline: none;
  font-family: 'Poppins', sans-serif;
  font-size: .83rem;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.chat-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(100, 205, 209, .14);
}

.chat-send {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: none;
  border-radius: 10px;
  background: var(--navy);
  color: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  transition: background-color .2s ease, transform .2s ease;
}

.chat-send:hover {
  background: var(--teal);
  transform: translateY(-1px);
}

.typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
}

.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal);
  animation: blink 1.2s infinite;
}

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

.typing span:nth-child(3) {
  animation-delay: .4s;
}

@keyframes blink {
  0%, 80%, 100% { opacity: .3; }
  40% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-window.open,
  .typing span {
    animation: none;
  }
}

@media (max-width: 560px) {
  .chat-fab {
    right: 14px;
    bottom: 14px;
  }

  .chat-toggle {
    width: 76px;
    height: 80px;
    font-size: 1.35rem;
  }

  .chat-window {
    position: fixed;
    left: 14px;
    right: 14px;
    bottom: 108px;
    width: auto;
    height: min(520px, calc(100dvh - 108px));
    min-height: 340px;
    max-height: calc(100dvh - 108px);
    border-radius: 18px;
  }

  .chat-head {
    padding: 13px 14px;
  }

  .chat-avatar {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .chat-head-text .t1 {
    font-size: .84rem;
  }

  .chat-head-text .t2 {
    font-size: .66rem;
  }

  .chat-body {
    padding: 12px;
    gap: 9px;
  }

  .msg {
    max-width: 90%;
    padding: 8px 11px;
    font-size: .8rem;
  }

  .chat-foot {
    gap: 7px;
    padding: 10px;
  }

  .chat-input {
    height: 40px;
    padding: 8px 11px;
    font-size: .8rem;
  }

  .chat-send {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }
}

@media (max-width: 360px), (max-height: 560px) {
  .chat-window {
    min-height: 300px;
    height: calc(100dvh - 96px);
    max-height: calc(100dvh - 96px);
  }

  .chat-head {
    padding-block: 11px;
  }

  .chat-foot {
    padding: 8px;
  }
}
