/* ============================================
   TryOnCloud Premium Modal v2.0
   Scoped styles - no CSS variable conflicts
   ============================================ */

/* ============================================
   TryOnCloud Button - Fully Isolated
   Prefixed with .aivt- to avoid conflicts
   ============================================ */

/* Reset all inherited styles (exclude SVG elements) */
.aivt-tryon-button {
  all: unset !important;
  box-sizing: border-box !important;
}
.aivt-tryon-button > span {
  all: unset !important;
  box-sizing: border-box !important;
}

/* Try On Button - ALL dynamic values via CSS custom properties (set by PHP via wp_add_inline_style) */
.aivt-tryon-button {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  padding: var(--aivt-btn-pad-v, 12px) var(--aivt-btn-pad-h, 24px) !important;
  border: none !important;
  border-radius: var(--aivt-btn-radius, 12px) !important;
  background: var(--aivt-btn-bg, #1a1a1a) !important;
  color: #ffffff !important;
  font-size: var(--aivt-btn-font-sz, 14px) !important;
  font-weight: var(--aivt-btn-font-wt, 600) !important;
  font-family: var(--aivt-btn-font-fam, inherit) !important;
  cursor: pointer !important;
  transition: transform 0.2s ease, opacity 0.2s ease !important;
  margin: 10px 0 !important;
  width: fit-content !important;
  max-width: 280px !important;
  min-width: 120px !important;
  box-sizing: border-box !important;
  line-height: 1.4 !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  text-align: center !important;
  text-decoration: none !important;
  vertical-align: middle !important;
  white-space: nowrap !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  position: relative !important;
  overflow: hidden !important;
}

/* Magic Sparkle SVG Icon */
.aivt-tryon-button .aivt-icon {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
  width: 18px !important;
  height: 18px !important;
}

.aivt-tryon-button .aivt-icon svg {
  display: inline-block !important;
  width: 18px !important;
  height: 18px !important;
  stroke: #ffffff !important;
  fill: none !important;
  stroke-width: 2 !important;
  vertical-align: middle !important;
}
.aivt-tryon-button .aivt-icon svg path,
.aivt-tryon-button .aivt-icon svg polyline {
  stroke: inherit !important;
  fill: none !important;
}

.aivt-tryon-button:hover {
  transform: translateY(-2px) !important;
  opacity: 0.88 !important;
}

.aivt-tryon-button:hover .aivt-icon svg {
  animation: aivt-sparkle 0.6s ease infinite !important;
}

@keyframes aivt-sparkle {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.15) rotate(10deg); }
}

.aivt-tryon-button:active {
  transform: translateY(0) !important;
}

.aivt-tryon-button:focus {
  outline: 2px solid var(--aivt-btn-bg, #1a1a1a) !important;
  outline-offset: 3px !important;
}

/* ============================================
   MODAL CONTAINER
   ============================================ */

.aivt-modal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  z-index: 999999 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 16px !important;
  box-sizing: border-box !important;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif !important;
}

.aivt-modal * {
  box-sizing: border-box !important;
  font-family: inherit !important;
}

.aivt-modal-backdrop {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  background: rgba(0, 0, 0, 0.65) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
}

.aivt-modal-content {
  position: relative !important;
  background: #ffffff !important;
  border-radius: 20px !important;
  width: 100% !important;
  max-width: 440px !important;
  max-height: 90vh !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.35) !important;
  animation: aivt-modal-in 0.25s ease-out !important;
}

@keyframes aivt-modal-in {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ============================================
   HEADER
   ============================================ */

.aivt-modal-header {
  display: flex !important;
  align-items: flex-start !important;
  justify-content: space-between !important;
  padding: 20px 24px 16px !important;
  flex-shrink: 0 !important;
  border-bottom: 1px solid #f3f4f6 !important;
}

.aivt-header-left {
  flex: 1 !important;
}

.aivt-modal-title {
  font-size: 18px !important;
  font-weight: 700 !important;
  color: #111827 !important;
  margin: 0 !important;
  line-height: 1.3 !important;
}

.aivt-modal-subtitle {
  font-size: 13px !important;
  color: #6b7280 !important;
  margin: 4px 0 0 !important;
  line-height: 1.4 !important;
}

.aivt-header-right {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
}

.aivt-icon-btn {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 38px !important;
  height: 38px !important;
  padding: 0 !important;
  border: 1px solid #e5e7eb !important;
  border-radius: 10px !important;
  background: #ffffff !important;
  color: #6b7280 !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
}

.aivt-icon-btn:hover {
  background: #f9fafb !important;
  border-color: #d1d5db !important;
  color: #374151 !important;
}

.aivt-icon-btn svg {
  width: 18px !important;
  height: 18px !important;
}

/* ============================================
   MODAL BODY & STEPS
   ============================================ */

.aivt-modal-body {
  padding: 24px !important;
  flex: 1 !important;
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  overflow-y: auto !important;
}

.aivt-step {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 !important;
  min-height: 0 !important;
}

.aivt-step-content {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  text-align: center !important;
  flex: 1 !important;
}

.aivt-step-headline {
  font-size: 22px !important;
  font-weight: 700 !important;
  color: #111827 !important;
  margin: 0 0 8px !important;
  line-height: 1.3 !important;
}

.aivt-step-subtext {
  font-size: 14px !important;
  color: #6b7280 !important;
  margin: 0 0 28px !important;
  max-width: 300px !important;
  line-height: 1.6 !important;
}

/* ============================================
   SELECTED ITEM (Product thumbnail)
   ============================================ */

.aivt-selected-item {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  margin-bottom: 28px !important;
}

.aivt-item-label {
  font-size: 11px !important;
  font-weight: 600 !important;
  color: #9ca3af !important;
  text-transform: uppercase !important;
  letter-spacing: 0.8px !important;
  margin-bottom: 10px !important;
}

.aivt-selected-item img {
  width: 100px !important;
  height: 100px !important;
  object-fit: cover !important;
  border-radius: 14px !important;
  background: #f9fafb !important;
  border: 2px solid #e5e7eb !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
}

/* ============================================
   BUTTONS
   ============================================ */

.aivt-primary-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 10px !important;
  width: 100% !important;
  max-width: 340px !important;
  padding: 16px 28px !important;
  border: none !important;
  border-radius: 14px !important;
  background: linear-gradient(135deg, #111827 0%, #1f2937 100%) !important;
  color: #ffffff !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  box-shadow: 0 4px 14px rgba(17, 24, 39, 0.25) !important;
}

.aivt-primary-btn:hover:not(:disabled) {
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 25px rgba(17, 24, 39, 0.35) !important;
}

.aivt-primary-btn:active:not(:disabled) {
  transform: translateY(0) !important;
}

.aivt-primary-btn:disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
}

.aivt-primary-btn svg {
  width: 18px !important;
  height: 18px !important;
  flex-shrink: 0 !important;
}

.aivt-secondary-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  width: 100% !important;
  max-width: 340px !important;
  padding: 14px 24px !important;
  margin-top: 12px !important;
  border: 2px solid #e5e7eb !important;
  border-radius: 14px !important;
  background: transparent !important;
  color: #374151 !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
}

.aivt-secondary-btn:hover {
  background: #f9fafb !important;
  border-color: #d1d5db !important;
}

.aivt-text-link {
  display: inline-block !important;
  padding: 12px !important;
  margin-top: 12px !important;
  background: none !important;
  border: none !important;
  color: #6b7280 !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  text-decoration: underline !important;
  text-underline-offset: 3px !important;
}

.aivt-text-link:hover {
  color: #374151 !important;
}

.aivt-remove-link {
  margin-top: 20px !important;
  font-size: 12px !important;
  color: #9ca3af !important;
}

.aivt-remove-link:hover {
  color: #ef4444 !important;
}

/* ============================================
   PRIVACY NOTICE
   ============================================ */

.aivt-privacy-notice {
  font-size: 11px !important;
  color: #9ca3af !important;
  text-align: center !important;
  line-height: 1.6 !important;
  margin-top: auto !important;
  padding-top: 24px !important;
}

.aivt-privacy-notice a {
  color: #6b7280 !important;
  text-decoration: underline !important;
}

.aivt-privacy-notice a:hover {
  color: #374151 !important;
}

/* ============================================
   CONFIRM STEP (Side-by-side images)
   ============================================ */

.aivt-confirm-images {
  display: flex !important;
  justify-content: center !important;
  gap: 20px !important;
  margin-bottom: 28px !important;
}

.aivt-confirm-image {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
}

.aivt-confirm-image img {
  width: 130px !important;
  height: 170px !important;
  object-fit: cover !important;
  border-radius: 14px !important;
  background: #f9fafb !important;
  border: 2px solid #e5e7eb !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
}

/* ============================================
   PROCESSING STEP (Progress bar)
   ============================================ */

.aivt-processing-content {
  justify-content: center !important;
  padding: 50px 0 !important;
}

.aivt-progress-container {
  width: 100% !important;
  max-width: 300px !important;
  margin-top: 16px !important;
}

.aivt-progress-bar {
  width: 100% !important;
  height: 8px !important;
  background: #e5e7eb !important;
  border-radius: 999px !important;
  overflow: hidden !important;
}

.aivt-progress-fill {
  height: 100% !important;
  width: 0% !important;
  background: linear-gradient(90deg, #10b981 0%, #059669 100%) !important;
  border-radius: 999px !important;
  transition: width 0.3s ease !important;
}

.aivt-progress-percent {
  display: block !important;
  text-align: center !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  color: #10b981 !important;
  margin-top: 12px !important;
}

/* ============================================
   RESULT STEP
   ============================================ */

.aivt-result-container {
  width: 100% !important;
  max-height: 380px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin-bottom: 24px !important;
  overflow: hidden !important;
  border-radius: 16px !important;
  background: #f9fafb !important;
  border: 2px solid #e5e7eb !important;
}

.aivt-result-container img {
  max-width: 100% !important;
  max-height: 380px !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain !important;
}

/* ============================================
   ERROR STEP
   ============================================ */

.aivt-error-content {
  justify-content: center !important;
  padding: 50px 0 !important;
}

.aivt-error-icon {
  color: #ef4444 !important;
  margin-bottom: 20px !important;
}

.aivt-error-icon svg {
  width: 56px !important;
  height: 56px !important;
}

.aivt-error-message {
  font-size: 15px !important;
  color: #374151 !important;
  line-height: 1.6 !important;
  margin: 0 0 28px !important;
  max-width: 300px !important;
}

/* ============================================
   HISTORY PANEL (Slide-in overlay)
   ============================================ */

.aivt-history-panel {
  position: absolute !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 280px !important;
  background: #ffffff !important;
  border-left: 1px solid #e5e7eb !important;
  display: flex !important;
  flex-direction: column !important;
  z-index: 10 !important;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.12) !important;
  animation: aivt-slide-in 0.2s ease-out !important;
}

@keyframes aivt-slide-in {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

.aivt-history-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 18px !important;
  border-bottom: 1px solid #e5e7eb !important;
}

.aivt-history-header h3 {
  font-size: 15px !important;
  font-weight: 600 !important;
  color: #111827 !important;
  margin: 0 !important;
}

.aivt-history-list {
  flex: 1 !important;
  overflow-y: auto !important;
  padding: 14px !important;
}

.aivt-history-item {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 12px !important;
  border-radius: 12px !important;
  cursor: pointer !important;
  transition: background 0.15s ease !important;
  margin-bottom: 10px !important;
  border: 1px solid #f3f4f6 !important;
}

.aivt-history-item:hover {
  background: #f9fafb !important;
  border-color: #e5e7eb !important;
}

.aivt-history-item img {
  width: 52px !important;
  height: 52px !important;
  object-fit: cover !important;
  border-radius: 10px !important;
  flex-shrink: 0 !important;
  border: 1px solid #e5e7eb !important;
}

.aivt-history-item-actions {
  margin-left: auto !important;
  display: flex !important;
  gap: 6px !important;
}

.aivt-history-item-actions button {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 32px !important;
  height: 32px !important;
  padding: 0 !important;
  border: 1px solid #e5e7eb !important;
  border-radius: 8px !important;
  background: #ffffff !important;
  color: #6b7280 !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
}

.aivt-history-item-actions button:hover {
  background: #f3f4f6 !important;
  border-color: #d1d5db !important;
  color: #374151 !important;
}

.aivt-history-item-actions button svg {
  width: 14px !important;
  height: 14px !important;
}

.aivt-history-empty {
  font-size: 13px !important;
  color: #9ca3af !important;
  text-align: center !important;
  padding: 40px 16px !important;
}

/* ============================================
   RESPONSIVE (Mobile-first)
   ============================================ */

@media (max-width: 480px) {
  .aivt-modal {
    padding: 0 !important;
  }

  .aivt-modal-content {
    max-width: 100% !important;
    max-height: 100% !important;
    height: 100% !important;
    border-radius: 0 !important;
  }

  .aivt-modal-header {
    padding: 16px 20px 14px !important;
  }

  .aivt-modal-body {
    padding: 20px !important;
  }

  .aivt-step-headline {
    font-size: 20px !important;
  }

  .aivt-confirm-images {
    gap: 14px !important;
  }

  .aivt-confirm-image img {
    width: 110px !important;
    height: 145px !important;
  }

  .aivt-history-panel {
    width: 100% !important;
  }

  .aivt-primary-btn,
  .aivt-secondary-btn {
    max-width: 100% !important;
  }
}

/* ============================================
   DARK MODE (via class toggle)
   ============================================ */

.aivt-modal-content.aivt-dark {
  background: #1a1a1a !important;
}

.aivt-modal-content.aivt-dark .aivt-modal-header {
  border-color: #374151 !important;
}

.aivt-modal-content.aivt-dark .aivt-modal-title {
  color: #ffffff !important;
}

.aivt-modal-content.aivt-dark .aivt-modal-subtitle {
  color: #9ca3af !important;
}

.aivt-modal-content.aivt-dark .aivt-icon-btn {
  background: #262626 !important;
  border-color: #374151 !important;
  color: #9ca3af !important;
}

.aivt-modal-content.aivt-dark .aivt-icon-btn:hover {
  background: #374151 !important;
  color: #ffffff !important;
}

.aivt-modal-content.aivt-dark .aivt-step-headline {
  color: #ffffff !important;
}

.aivt-modal-content.aivt-dark .aivt-step-subtext {
  color: #9ca3af !important;
}

.aivt-modal-content.aivt-dark .aivt-item-label {
  color: #6b7280 !important;
}

.aivt-modal-content.aivt-dark .aivt-selected-item img,
.aivt-modal-content.aivt-dark .aivt-confirm-image img {
  background: #262626 !important;
  border-color: #374151 !important;
}

.aivt-modal-content.aivt-dark .aivt-primary-btn {
  background: linear-gradient(135deg, #ffffff 0%, #e5e7eb 100%) !important;
  color: #111827 !important;
}

.aivt-modal-content.aivt-dark .aivt-secondary-btn {
  border-color: #374151 !important;
  color: #d1d5db !important;
}

.aivt-modal-content.aivt-dark .aivt-secondary-btn:hover {
  background: #262626 !important;
}

.aivt-modal-content.aivt-dark .aivt-text-link {
  color: #9ca3af !important;
}

.aivt-modal-content.aivt-dark .aivt-text-link:hover {
  color: #ffffff !important;
}

.aivt-modal-content.aivt-dark .aivt-privacy-notice {
  color: #6b7280 !important;
}

.aivt-modal-content.aivt-dark .aivt-privacy-notice a {
  color: #9ca3af !important;
}

.aivt-modal-content.aivt-dark .aivt-progress-bar {
  background: #374151 !important;
}

.aivt-modal-content.aivt-dark .aivt-result-container {
  background: #262626 !important;
  border-color: #374151 !important;
}

.aivt-modal-content.aivt-dark .aivt-error-message {
  color: #d1d5db !important;
}

.aivt-modal-content.aivt-dark .aivt-history-panel {
  background: #1a1a1a !important;
  border-color: #374151 !important;
}

.aivt-modal-content.aivt-dark .aivt-history-header {
  border-color: #374151 !important;
}

.aivt-modal-content.aivt-dark .aivt-history-header h3 {
  color: #ffffff !important;
}

.aivt-modal-content.aivt-dark .aivt-history-item {
  border-color: #262626 !important;
}

.aivt-modal-content.aivt-dark .aivt-history-item:hover {
  background: #262626 !important;
  border-color: #374151 !important;
}

.aivt-modal-content.aivt-dark .aivt-history-item img {
  border-color: #374151 !important;
}

.aivt-modal-content.aivt-dark .aivt-history-item-actions button {
  background: #262626 !important;
  border-color: #374151 !important;
  color: #9ca3af !important;
}

.aivt-modal-content.aivt-dark .aivt-history-item-actions button:hover {
  background: #374151 !important;
  color: #ffffff !important;
}

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