:root {
  --color-header-grey: #dee1e9;
  --color-theme-grey: #242424cc;
  --color-theme-blue: #165dfc;
  --color-theme-black: #242424;
  --color-theme-cyan: #5792c9;
  --color-bubble-grey: #d5e3f8;
}

.text-theme-grey {
  color: var(--color-theme-grey);
}
.text-theme-blue {
  color: var(--color-theme-blue);
}
.bg-theme-blue {
  background-color: #5792c9;
}
.text-theme-black {
  color: var(--color-theme-black);
}
body {
  font-family: Nunito Sans;
}

.border-header-grey {
  border-color: var(--color-header-grey);
}

.chat-body-gradient {
  background: linear-gradient(180deg, #f3f8ff 0%, #f7faff 57.21%, #dfecff 100%);
}

/* Avatar Toggle Switch */
.avatar-toggle-switch {
  z-index: 20;
  cursor: pointer;
  user-select: none;
}

.avatar-toggle-switch.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: blocked;
}

.switch-track {
  position: relative;
  width: 42px;
  height: 20px;
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  padding: 1px;
}

.switch-track:hover {
  background: rgba(255, 255, 255, 0.35);
  box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

.switch-thumb {
  position: absolute;
  width: 12px;
  height: 12px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  padding: 2px;
  margin: 2px;
  left: 1px;
}

.avatar-toggle-switch.active .switch-thumb {
  /* Track width (42px) - thumb width (12px) - padding left (1px) - padding right (1px) - thumb left position (1px) -margin-left(2px) - margin-right(2px)= 23px */
  transform: translateX(23px);
}

/* Avatar fade transitions */
#avatarVideo,
#staticVideo {
  transition: opacity 0.15s ease-out;
  background-color: #1a1a1a;
}

#avatarVideo.fade-out,
#staticVideo.fade-out {
  opacity: 0;
}

[data-agent-avatar] {
  transition: opacity 0.15s ease-in-out;
}

[data-agent-avatar].fade-out {
  opacity: 0;
}

.avatar-toggle-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.avatar-toggle-btn i {
  transition: transform 0.3s ease;
}

.avatar-toggle-btn:hover i {
  transform: rotate(180deg);
}

@media (max-width: 640px) {
  .avatar-toggle-btn span {
    display: none;
  }
  .avatar-toggle-btn {
    padding: 0.5rem;
  }
}

/* Sound wave visualization  */
.sound-wave-container {
  display: none;
  position: absolute;
  left: 45%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  pointer-events: none;
}

@media (max-width: 640px) {
  .sound-wave-container {
    left: 50%;
    top: 45%;
  }
}

.sound-wave {
  display: flex;
  align-items: center;
  gap: 4px;
}

.wave-bar {
  width: 4px;
  height: 12px;
  background: #5c6ac4;
  border-radius: 2.5px;
  animation: wave-animation 2s ease-in-out infinite;
  transform-origin: center;
}

.wave-bar:nth-child(1) {
  animation-delay: 0s;
}
.wave-bar:nth-child(2) {
  animation-delay: 0.15s;
}
.wave-bar:nth-child(3) {
  animation-delay: 0.3s;
}
.wave-bar:nth-child(4) {
  animation-delay: 0.45s;
}
.wave-bar:nth-child(5) {
  animation-delay: 0.6s;
}
.wave-bar:nth-child(6) {
  animation-delay: 0.45s;
}
.wave-bar:nth-child(7) {
  animation-delay: 0.3s;
}
.wave-bar:nth-child(8) {
  animation-delay: 0.15s;
}
.wave-bar:nth-child(9) {
  animation-delay: 0s;
}

@keyframes wave-animation {
  0%,
  100% {
    transform: scaleY(0.3);
    opacity: 0.6;
  }
  50% {
    transform: scaleY(1.8);
    opacity: 1;
  }
}

.avatar-shadow {
  box-shadow: 0px 4px 24px 0px #5792c980;
}

.avatar-background {
  transition: height 0.5s ease, width 0.5s ease;
  background-color: #1a1a1a;
}

.bg-theme-cyan {
  background-color: var(--color-theme-cyan);
}
.border-bubble-grey {
  border-color: var(--color-bubble-grey);
}

/* Custom scrollbar for chat body */
.chat-body::-webkit-scrollbar {
  width: 5px;
}

.chat-body::-webkit-scrollbar-track {
  background: transparent;
}

.chat-body::-webkit-scrollbar-thumb {
  background: var(--color-header-grey);
  border-radius: 6px;
  max-height: 20px;
}

.chat-body::-webkit-scrollbar-thumb:hover {
  background: var(--color-theme-cyan);
}

/* Send button disabled state */
#sendBtn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Chat view layout - sticky behavior */
.avatar-section.is-sticky {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, #f3f8ff 0%, #f7faff 100%);
  padding-top: 5px;
  padding-bottom: 5px;
}

.chat-footer-section.is-sticky {
  position: sticky;
  bottom: 0;
  z-index: 20;
  padding-top: 10px;
}

/* Chat messages wrapper in chat view */
#chatMessagesWrapper {
  min-height: 0;
}

#chatMessagesWrapper .chat-body {
  max-height: none;
}

/* Compact avatar for chat view */
.avatar-compact .avatar-background {
  height: 320px;
  width: 500px;
  transition: height 0.5s ease, width 0.5s ease;
}

@media (max-width: 768px) {
  .avatar-compact .avatar-background {
    height: 250px;
    width: 90vw;
    max-width: 400px;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .avatar-compact .avatar-background {
    height: 280px;
    width: 450px;
  }
}

.avatar-section {
  transition: all 0.3s ease;
}

/* Chat body scrollbar (for chat messages) */
#chatMessagesWrapper .chat-body::-webkit-scrollbar {
  width: 5px;
}

#chatMessagesWrapper .chat-body::-webkit-scrollbar-track {
  background: transparent;
}

#chatMessagesWrapper .chat-body::-webkit-scrollbar-thumb {
  background: var(--color-header-grey);
  border-radius: 6px;
}

#chatMessagesWrapper .chat-body::-webkit-scrollbar-thumb:hover {
  background: var(--color-theme-cyan);
}

/* Main container scrollbar */
#chatBodyContainer::-webkit-scrollbar {
  width: 6px;
}

#chatBodyContainer::-webkit-scrollbar-track {
  background: transparent;
}

#chatBodyContainer::-webkit-scrollbar-thumb {
  background: var(--color-header-grey);
  border-radius: 6px;
}

#chatBodyContainer::-webkit-scrollbar-thumb:hover {
  background: var(--color-theme-cyan);
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .chat-footer-section {
    padding-bottom: 12px;
  }

  .avatar-section {
    padding-top: 8px;
    padding-bottom: 8px;
  }
}

@media (max-width: 480px) {
  .chat-input::placeholder {
    font-size: 14px;
  }
}

/* Typing animation with bouncing dots */
.loading-dots-bounce {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.loading-dots-bounce span {
  width: 6px;
  height: 6px;
  margin: 0 2px;
  background-color: #5792c9;
  border-radius: 50%;
  display: inline-block;
  animation: bounce-dot 1.45s infinite ease-in-out both;
}

.loading-dots-bounce span:nth-child(1) {
  animation-delay: -0.32s;
}

.loading-dots-bounce span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes bounce-dot {
  0%,
  80%,
  100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}
