/* Global AI floating button — admin mockup style */

.ai-floating-button {
  position: fixed;
  right: 28px;
  bottom: 26px;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  color: #E5DED4;
  border: 0;
  border-radius: 24px;
  background: #76563D;
  box-shadow: 0 8px 24px rgba(80, 56, 41, 0.28);
  z-index: 10050;
  cursor: pointer;
  padding: 0;
  animation: aiFloat 3.8s ease-in-out infinite;
  transition:
    transform 180ms cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 180ms cubic-bezier(0.16, 1, 0.3, 1),
    background 180ms ease;
}

[data-theme="light"] .ai-floating-button {
  box-shadow: 0 8px 24px rgba(80, 56, 41, 0.22);
}

.ai-floating-button::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 30px;
  border: 1px solid rgba(136, 97, 66, 0.35);
  animation: aiPulse 2.2s cubic-bezier(0.16, 1, 0.3, 1) infinite;
  pointer-events: none;
}

.ai-floating-button:hover {
  transform: translateY(-3px);
  background: #503829;
  color: #E5DED4;
  box-shadow: 0 10px 28px rgba(80, 56, 41, 0.32);
}

.ai-floating-button:active {
  transform: scale(0.96);
}

.ai-floating-button.is-open {
  animation: none;
  background: #694A36;
  color: #E5DED4;
}

.ai-floating-button.is-open::after {
  animation: none;
  opacity: 0;
}

.ai-floating-icon {
  position: relative;
  z-index: 1;
  display: block;
}

.ai-assistant-fab__icon--close {
  display: none;
}

.ai-floating-button.is-open .ai-assistant-fab__icon--spark {
  display: none;
}

.ai-floating-button.is-open .ai-assistant-fab__icon--close {
  display: block;
}

@keyframes aiFloat {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

@keyframes aiPulse {
  from {
    transform: scale(0.92);
    opacity: 0.75;
  }
  to {
    transform: scale(1.25);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ai-floating-button,
  .ai-floating-button::after {
    animation: none !important;
  }
}

@media (max-width: 768px) {
  .ai-floating-button.is-open {
    animation: none;
  }
}

@media (max-width: 480px) {
  .ai-floating-button {
    right: 16px;
    bottom: 16px;
    width: 58px;
    height: 58px;
    border-radius: 20px;
  }
}

.page-chat .ai-floating-button {
  right: auto;
  left: max(16px, env(safe-area-inset-left, 0px));
  bottom: max(20px, env(safe-area-inset-bottom, 0px));
  z-index: 40;
}

.page-chat .ai-assistant-panel {
  right: auto;
  left: max(16px, env(safe-area-inset-left, 0px));
  bottom: calc(20px + 64px + 12px);
}

@media (max-width: 480px) {
  .page-chat .ai-floating-button {
    left: 12px;
    bottom: 12px;
  }
  .page-chat .ai-assistant-panel {
    left: 8px;
    right: 8px;
    width: auto;
  }
}

.has-chat-sidebar .ai-floating-button {
  right: auto;
  left: 28px;
}
