/**
 * AR Preview overlay — design-online page
 */

.wax-ar-shell {
  position: fixed;
  inset: 0;
  /* Above typical chat widgets so controls stay tappable */
  z-index: 9999999;
  pointer-events: none;
}

.wax-ar-shell.wax-ar-shell--active {
  pointer-events: auto;
  /* Above Tawk / similar widgets that use very high z-index */
  z-index: 2147483600;
}

/* Desktop 3D AR: panel below site header; --wax-ar-header-offset from ar-preview.js */
.wax-ar-shell--desktop {
  --wax-ar-theme: #ff6b35;
  --wax-ar-theme-dark: #e85d2c;
  --wax-ar-surface: #ffffff;
  --wax-ar-border: #e9ecef;
  inset: var(--wax-ar-header-offset, 0px) 0 0 0;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--wax-ar-header-offset, 0px));
  height: calc(100vh - var(--wax-ar-header-offset, 0px));
  width: 100%;
  padding-left: clamp(0.75rem, 3.5vw, 2.5rem);
  padding-right: clamp(0.75rem, 3.5vw, 2.5rem);
  padding-top: 2.85rem;
  background: rgba(248, 249, 250, 0.86);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  overflow-x: hidden;
  overflow-y: auto;
}

.wax-ar-close {
  position: absolute;
  top: calc(0.5rem + env(safe-area-inset-top, 0px));
  right: clamp(0.5rem, 2.5vw, 1.75rem);
  z-index: 100165;
  display: inline-flex;
  height: 2.5rem;
  width: 2.5rem;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 2px solid var(--wax-ar-border, #e9ecef);
  background: #fff;
  color: #1d2129;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.wax-ar-close:hover {
  border-color: var(--wax-ar-theme, #ff6b35);
  color: var(--wax-ar-theme, #ff6b35);
  background: #fff;
}

.wax-ar-close:focus-visible {
  outline: 2px solid var(--wax-ar-theme, #ff6b35);
  outline-offset: 2px;
}

.wax-ar-desktop-stage {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem 1.25rem;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  flex: 1 1 auto;
  min-height: 0;
}

.wax-ar-desktop-main {
  flex: 1 1 220px;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-self: stretch;
}

.wax-ar-shell--desktop .wax-ar-desktop-inner {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
  width: 100%;
  padding: 0;
}

/* Narrow viewports: tighter chrome */
@media (max-width: 719px) {
  .wax-ar-shell--desktop {
    padding-left: clamp(0.5rem, 3vw, 1rem);
    padding-right: clamp(0.5rem, 3vw, 1rem);
    padding-top: 2.35rem;
  }

  .wax-ar-close {
    top: calc(0.35rem + env(safe-area-inset-top, 0px));
    right: 0.5rem;
    height: 2.35rem;
    width: 2.35rem;
  }

  .wax-ar-desktop-stage {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .wax-ar-shell--desktop .wax-ar-overlay {
    padding-bottom: max(1.25rem, calc(env(safe-area-inset-bottom, 0px) + 0.75rem));
  }

  .wax-ar-shell--desktop .wax-ar-hint {
    font-size: 0.78rem;
    padding: 0.55rem 0.75rem;
  }
}

.wax-ar-shell--desktop .wax-ar-overlay {
  position: relative;
  inset: auto;
  flex: 0 0 auto;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.65rem;
  padding: 0 0 0.75rem;
  justify-content: flex-start;
  pointer-events: auto;
}

.wax-ar-shell--desktop .wax-ar-hint {
  position: relative;
  bottom: auto;
  left: auto;
  transform: none;
  max-width: none;
  margin: 0;
  order: 0;
  pointer-events: none;
  padding: 0.65rem 0.9rem;
  background: #fff;
  color: #383838;
  font-size: 0.8125rem;
  line-height: 1.45;
  text-align: center;
  border-radius: 12px;
  border: 1px solid var(--wax-ar-border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  border-left: 3px solid var(--wax-ar-theme);
  backdrop-filter: none;
}

.wax-ar-shell--desktop .wax-ar-loading {
  position: fixed;
  z-index: 100160;
}

.wax-ar-shell--desktop .wax-ar-toast {
  position: fixed;
  z-index: 100155;
  background: rgba(255, 107, 53, 0.96);
  color: #fff;
  border: 1px solid rgba(232, 93, 44, 0.9);
  box-shadow: 0 4px 14px rgba(255, 107, 53, 0.28);
}

.wax-ar-shell .wax-ar-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  touch-action: none;
}

.wax-ar-shell--desktop .wax-ar-canvas {
  display: block;
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  min-height: 0;
}

.wax-ar-canvas--desktop {
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: none;
  border: 1px solid rgba(0, 0, 0, 0.07);
}

.wax-ar-shell:not(.wax-ar-shell--desktop) .wax-ar-desktop-inner {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 1rem 1rem 0;
  max-height: calc(100vh - 120px);
  overflow: auto;
}

.wax-ar-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
}

.wax-ar-overlay > * {
  pointer-events: auto;
}

.wax-ar-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 999px;
  backdrop-filter: blur(8px);
  z-index: 3;
}

.wax-ar-loading--hidden {
  display: none !important;
}

.wax-ar-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: wax-ar-spin 0.75s linear infinite;
}

@keyframes wax-ar-spin {
  to {
    transform: rotate(360deg);
  }
}

.wax-ar-toast {
  position: absolute;
  top: max(1rem, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  max-width: min(92vw, 420px);
  padding: 0.65rem 1rem;
  background: rgba(46, 125, 50, 0.92);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  z-index: 2;
}

.wax-ar-toast--hidden {
  display: none !important;
}

.wax-ar-hint {
  position: absolute;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(94vw, 480px);
  margin: 0;
  padding: 0.5rem 0.9rem;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.8125rem;
  line-height: 1.35;
  text-align: center;
  border-radius: 10px;
  backdrop-filter: blur(8px);
  pointer-events: none;
  z-index: 1;
}

/* Launch button in toolbar (design builder) */
.ar-preview-launch-btn {
  border-color: #ff6b35 !important;
}

.ar-preview-launch-btn:not(:disabled):hover {
  background: #ff6b35 !important;
  color: #fff !important;
}

.ar-preview-launch-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ar-preview-launch-btn svg {
  color: inherit;
}
