/**
 * Fixed cookie banner + chat FAB stacking (mobile-first).
 * Loaded on all storefront screens (landing, shop, auth).
 */
:root {
  --aiya-fab-clearance: calc(88px + env(safe-area-inset-bottom, 0px));
  --aiya-cookie-h: 0px;
  /* Back-to-top clearance: button bottom 20 + size 40 + gap 18 ≈ 78 */
  --aiya-totop-clearance: calc(78px + env(safe-area-inset-bottom, 0px));
}

/* Closed preference center is visibility:hidden but still wide — clamp to viewport. */
html body .wcc-modal {
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  max-width: 100vw !important;
  overflow-x: hidden !important;
  box-sizing: border-box !important;
  contain: layout paint;
}
html body .wcc-preference-center,
html body .wcc-preference-header,
html body .wcc-preference-body-wrapper,
html body .wcc-footer-wrapper {
  max-width: 100% !important;
  box-sizing: border-box !important;
}
html body .wcc-preference-center {
  width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* Fully inert when JS marks prefs closed (kills false scrollWidth). */
html body .wcc-modal.aiya-wcc-modal-closed {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
  left: 0 !important;
  top: 0 !important;
}

/* CSS-only fallback (no JS): hide FABs while WebToffee notice is visible. */
@media (max-width: 600px) {
  html body:has(.wcc-consent-container:not(.wcc-hide)) .aiya-chat-root,
  html body:has(.wcc-consent-container:not(.wcc-hide)) .aimy-chat-root,
  html body:has(.wcc-consent-container:not(.wcc-hide)) #wp-chatbot-ball-container,
  html body:has(.wcc-consent-container:not(.wcc-hide)) .wp-chatbot-notification-welcome,
  html body:has(.wcc-consent-container:not(.wcc-hide)) .aiya-float-cart,
  html body:has(.wcc-consent-container:not(.wcc-hide)) .aiya-scroll-up,
  html body.aiya-cookie-banner .aiya-chat-root,
  html body.aiya-cookie-banner .aimy-chat-root,
  html body.aiya-cookie-banner #wp-chatbot-ball-container,
  html body.aiya-cookie-banner .wp-chatbot-notification-welcome,
  html body.aiya-cookie-banner .aiya-float-cart,
  html body.aiya-cookie-banner .aiya-scroll-up {
    visibility: hidden !important;
    pointer-events: none !important;
    opacity: 0 !important;
  }

  html body.aiya-landing,
  html body.aiya-docs-page,
  html body.aiya-store-chrome,
  html body.aiya-auth-screen,
  html body.aiya-account-screen,
  html body.aiya-cms-page,
  html body.aiya-demo-page {
    padding-bottom: var(--aiya-fab-clearance) !important;
  }

  html body:has(.wcc-consent-container:not(.wcc-hide)),
  html body.aiya-cookie-banner {
    padding-bottom: calc(var(--aiya-cookie-h, 186px) + 20px + env(safe-area-inset-bottom, 0px)) !important;
  }

  html body.aiya-auth-screen .woocommerce-form-login,
  html body.aiya-auth-screen .woocommerce-form-register,
  html body.aiya-auth-screen .aiya-auth,
  html body .aiya-support-form,
  html body .aiya-feedback,
	html body.woocommerce-checkout .woocommerce,
  html body.woocommerce-cart .woocommerce {
    scroll-margin-bottom: var(--aiya-fab-clearance);
  }
}

/* Back to top — like proacton.ru #scrollUp, AIYA teal; bottom-right. */
.aiya-scroll-up {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  margin: 0;
  width: 40px;
  height: 40px;
  padding: 1px;
  position: fixed;
  right: 40px !important;
  bottom: 20px !important;
  left: auto !important;
  top: auto !important;
  z-index: 100001;
  border-radius: 50%;
  background: var(--teal, #00b4a6);
  color: #fff;
  cursor: pointer;
  display: none;
  box-shadow: 0 0 20px rgba(8, 150, 139, 0.35);
  transition: background 0.3s, opacity 0.3s;
  line-height: 0;
}
.aiya-scroll-up.is-visible {
  display: block !important;
}
.aiya-scroll-up:hover,
.aiya-scroll-up:focus-visible {
  opacity: 0.8;
  background: var(--teal-deep, #08968b);
}
.aiya-scroll-up:focus-visible {
  outline: 3px solid color-mix(in srgb, #00b4a6 45%, transparent);
  outline-offset: 3px;
}
.aiya-scroll-up__arrow {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: block;
}
.aiya-scroll-up__progress {
  display: block;
  width: 40px;
  height: 40px;
}
.aiya-scroll-up__ring {
  transition: stroke-dashoffset 0.5s ease;
}
html[data-aiya-theme="night"] .aiya-scroll-up {
  background: #00b4a6;
  box-shadow: 0 0 20px rgba(0, 180, 166, 0.45);
}

/* Raise Aimy / legacy chat FAB above the back-to-top button (vertical stack). */
html body .aimy-chat-root.aimy-chat-root--bottom-right,
html body #aimy-chat-root.aimy-chat-root--bottom-right,
html body .aiya-chat-root,
html body #wp-chatbot-ball-container,
html body #wp-chatbot-ball {
  bottom: var(--aiya-totop-clearance) !important;
}

@media (max-width: 767px) {
  /* Evgeny: no Back to top on mobile — desktop only (proacton-like corner there). */
  .aiya-scroll-up,
  .aiya-scroll-up.is-visible {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
  /* No totop clearance needed on mobile — restore normal chat FAB bottom. */
  html body .aimy-chat-root.aimy-chat-root--bottom-right,
  html body #aimy-chat-root.aimy-chat-root--bottom-right,
  html body .aiya-chat-root,
  html body #wp-chatbot-ball-container,
  html body #wp-chatbot-ball {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* Cookie banner is bottom-left — do NOT lift Back to top (keep extreme bottom-right like proacton.ru). */

/* Hide while chat panel is open (Aimy data-open or legacy class). */
html body:has(.aimy-chat-root[data-open="1"]) .aiya-scroll-up,
html body:has(.aiya-chat-root.aiya-chat-is-open) .aiya-scroll-up,
html body:has(.aiya-chat-root.wp-chatbot-is-expanded) .aiya-scroll-up {
  visibility: hidden;
  pointer-events: none;
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .aiya-scroll-up,
  .aiya-scroll-up__ring {
    transition: none;
  }
}
@media print {
  .aiya-scroll-up {
    display: none !important;
  }
}
