/* ============================================================
   AI Dress Try-On Feature — Premium Raphael AI Inspired Design
   ============================================================ */

.tryon-section {
  padding: 80px 0;
  background: 
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(218, 165, 32, 0.15), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(139, 69, 19, 0.1), transparent),
    linear-gradient(180deg, #fdf8f3 0%, #faf4ed 50%, #f7efe5 100%);
  position: relative;
  overflow: hidden;
}

.tryon-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    radial-gradient(circle at 20% 30%, rgba(139, 69, 19, 0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(218, 165, 32, 0.04) 0%, transparent 50%);
  pointer-events: none;
}

.tryon-container {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
}

/* Header */
.tryon-header {
  text-align: center;
  margin-bottom: 48px;
}

.tryon-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(139, 69, 19, 0.1), rgba(218, 165, 32, 0.15));
  color: var(--color-primary);
  padding: 8px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  margin-bottom: 20px;
  border: 1px solid rgba(139, 69, 19, 0.15);
  backdrop-filter: blur(10px);
}

.tryon-badge .sparkle {
  animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.1); }
}

.tryon-title {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5vw, 3rem);
  color: var(--color-text);
  margin: 0 0 16px;
  line-height: 1.15;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #4a2c1a 0%, #8b4513 50%, #b8860b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tryon-subtitle {
  color: var(--color-text-secondary);
  font-size: clamp(1rem, 2vw, 1.15rem);
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.7;
  font-weight: 400;
}

/* Step Indicators */
.tryon-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 32px;
}

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  opacity: 0.5;
  transition: all 0.4s ease;
}

.step-item.active {
  opacity: 1;
}

.step-item.completed {
  opacity: 1;
}

.step-number {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.8);
  border: 2px solid rgba(139, 69, 19, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  transition: all 0.3s ease;
}

.step-item.active .step-number {
  background: linear-gradient(135deg, var(--color-primary), #a0522d);
  color: white;
  border-color: var(--color-primary);
  box-shadow: 0 4px 12px rgba(139, 69, 19, 0.3);
}

.step-item.completed .step-number {
  background: linear-gradient(135deg, #2e7d32, #388e3c);
  color: white;
  border-color: #2e7d32;
}

.step-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.step-item.active .step-label {
  color: var(--color-primary);
}

.step-line {
  width: 60px;
  height: 2px;
  background: rgba(139, 69, 19, 0.15);
  margin: 0 12px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.step-line.completed::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #2e7d32, #388e3c);
  animation: lineFill 0.6s ease forwards;
}

@keyframes lineFill {
  from { width: 0; }
  to { width: 100%; }
}

/* Main Card - Glassmorphism */
.tryon-main-card {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 24px;
  padding: 40px;
  box-shadow: 
    0 10px 40px rgba(139, 69, 19, 0.08),
    0 2px 10px rgba(139, 69, 19, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  position: relative;
}

/* Upload Area */
.tryon-upload-area {
  display: grid;
  grid-template-columns: 1fr 80px 1fr;
  gap: 0;
  align-items: stretch;
  margin-bottom: 32px;
}

.upload-box {
  background: linear-gradient(145deg, #ffffff, #faf6f1);
  border: 2px solid transparent;
  border-radius: 16px;
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 
    0 2px 8px rgba(139, 69, 19, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.upload-box:hover {
  border-color: var(--color-primary);
  transform: translateY(-4px);
  box-shadow: 
    0 12px 32px rgba(139, 69, 19, 0.12),
    0 4px 12px rgba(139, 69, 19, 0.08);
}

.upload-box.dragover {
  border-color: var(--color-primary);
  background: linear-gradient(145deg, rgba(139, 69, 19, 0.05), rgba(218, 165, 32, 0.05));
  transform: scale(1.02);
}

.upload-box.has-image {
  border-style: solid;
  border-color: rgba(139, 69, 19, 0.2);
  padding: 20px;
  background: white;
}

.upload-icon-wrapper {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--color-accent-light), #f5e6d3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  transition: all 0.3s ease;
}

.upload-box:hover .upload-icon-wrapper {
  transform: scale(1.1) rotate(-5deg);
  background: linear-gradient(135deg, var(--color-primary), #a0522d);
}

.upload-icon {
  font-size: 36px;
  transition: all 0.3s ease;
}

.upload-box:hover .upload-icon {
  transform: scale(1.1);
}

.upload-label {
  font-weight: 600;
  color: var(--color-text);
  font-size: 1rem;
  margin-bottom: 6px;
}

.upload-hint {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.upload-preview {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 12px;
  margin-bottom: 12px;
}

.upload-change-btn {
  font-size: 0.8rem;
  color: var(--color-primary);
  background: rgba(139, 69, 19, 0.08);
  border: none;
  cursor: pointer;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.upload-change-btn:hover {
  background: rgba(139, 69, 19, 0.15);
}

/* Swap Arrow */
.tryon-swap-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.tryon-arrow {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), #a0522d);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  box-shadow: 
    0 4px 16px rgba(139, 69, 19, 0.3),
    0 2px 6px rgba(139, 69, 19, 0.2);
  animation: floatArrow 3s ease-in-out infinite;
  z-index: 2;
  position: relative;
}

.tryon-arrow::before {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  border: 2px solid rgba(139, 69, 19, 0.2);
  animation: pulseRing 2s ease-out infinite;
}

@keyframes floatArrow {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(4px); }
}

@keyframes pulseRing {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.3); opacity: 0; }
}

/* Generate Button */
.tryon-generate-area {
  text-align: center;
  margin-bottom: 8px;
}

.tryon-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 16px 48px;
  font-size: 1rem;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, var(--color-primary) 0%, #a0522d 50%, #8b4513 100%);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 
    0 6px 24px rgba(139, 69, 19, 0.35),
    0 2px 8px rgba(139, 69, 19, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  position: relative;
  overflow: hidden;
}

.tryon-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s ease;
}

.tryon-btn:hover:not(:disabled)::before {
  left: 100%;
}

.tryon-btn:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 
    0 10px 32px rgba(139, 69, 19, 0.4),
    0 4px 12px rgba(139, 69, 19, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.tryon-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

.tryon-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.3);
}

.tryon-btn.loading {
  pointer-events: none;
  padding-left: 56px;
}

.tryon-btn .btn-icon {
  font-size: 20px;
  transition: transform 0.3s ease;
}

.tryon-btn:hover:not(:disabled) .btn-icon {
  transform: rotate(15deg) scale(1.1);
}

.generate-subtext {
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.generate-subtext::before {
  content: '✓';
  color: #2e7d32;
  font-weight: 700;
}

/* Loading State */
.tryon-loading {
  display: none;
  text-align: center;
  padding: 32px 24px;
}

.tryon-loading.show {
  display: block;
  animation: fadeInUp 0.5s ease;
}

.loading-visual {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
}

.loading-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 3px solid rgba(139, 69, 19, 0.1);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1.2s linear infinite;
}

.loading-ring::before {
  content: '';
  position: absolute;
  top: 5px;
  left: 5px;
  right: 5px;
  bottom: 5px;
  border: 3px solid transparent;
  border-top-color: #daa520;
  border-radius: 50%;
  animation: spin 0.8s linear infinite reverse;
}

.loading-icon-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 28px;
  animation: pulse 1.5s ease-in-out infinite;
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.7; transform: translate(-50%, -50%) scale(0.9); }
}

.loading-text {
  font-size: 1.05rem;
  color: var(--color-text);
  font-weight: 600;
  margin-bottom: 4px;
}

.loading-subtext {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.loading-progress {
  margin-top: 16px;
  height: 4px;
  background: rgba(139, 69, 19, 0.1);
  border-radius: 999px;
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
  overflow: hidden;
}

.loading-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), #daa520);
  border-radius: 999px;
  width: 0%;
  transition: width 0.5s ease;
  animation: progressAnim 15s ease-out forwards;
}

@keyframes progressAnim {
  0% { width: 5%; }
  30% { width: 35%; }
  60% { width: 65%; }
  85% { width: 85%; }
  100% { width: 95%; }
}

/* Result Area */
.tryon-result-area {
  display: none;
  margin-top: 32px;
}

.tryon-result-area.show {
  display: block;
  animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-header {
  text-align: center;
  margin-bottom: 24px;
}

.result-header h3 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  margin: 0 0 4px;
  color: var(--color-text);
}

.result-header p {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin: 0;
}

/* Before/After Comparison */
.result-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.comparison-item {
  text-align: center;
}

.comparison-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.comparison-image-wrapper {
  background: white;
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 4px 16px rgba(139, 69, 19, 0.08);
  aspect-ratio: 3/4;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.comparison-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 10px;
}

.result-image-wrapper {
  background: white;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 
    0 16px 48px rgba(139, 69, 19, 0.15),
    0 4px 16px rgba(139, 69, 19, 0.08);
  text-align: center;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.result-image-wrapper::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--color-primary), #daa520, var(--color-primary));
  background-size: 200% 100%;
  animation: shimmer 3s linear infinite;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.result-image {
  max-width: 100%;
  max-height: 480px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  font-size: 0.95rem;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, #2e7d32, #388e3c);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(46, 125, 50, 0.3);
}

.download-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(46, 125, 50, 0.4);
}

.try-again-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-primary);
  background: white;
  border: 2px solid rgba(139, 69, 19, 0.2);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.try-again-btn:hover {
  border-color: var(--color-primary);
  background: rgba(139, 69, 19, 0.03);
  transform: translateY(-2px);
}

/* Error State */
.tryon-error {
  display: none;
  text-align: center;
  padding: 24px;
  background: linear-gradient(135deg, #fef2f2, #fee2e2);
  border: 1px solid #fecaca;
  border-radius: 16px;
  margin-top: 20px;
}

.tryon-error.show {
  display: block;
  animation: shakeIn 0.5s ease;
}

@keyframes shakeIn {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.error-icon {
  font-size: 40px;
  margin-bottom: 8px;
}

.error-text {
  color: #dc2626;
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 4px;
}

.error-subtext {
  color: #991b1b;
  font-size: 0.85rem;
}

/* Tips */
.tryon-tips {
  margin-top: 32px;
  padding: 20px 24px;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  border: 1px solid rgba(139, 69, 19, 0.08);
}

.tryon-tips h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--color-text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tryon-tips ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.tryon-tips li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
}

.tryon-tips li .tip-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2e7d32, #388e3c);
  color: white;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

/* Gallery Section */
.tryon-gallery {
  margin-top: 40px;
  text-align: center;
}

.gallery-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: var(--color-text);
  margin: 0 0 24px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.gallery-item {
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.3s ease;
  border: 1px solid rgba(139, 69, 19, 0.08);
}

.gallery-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(139, 69, 19, 0.12);
}

.gallery-image-placeholder {
  aspect-ratio: 3/4;
  background: linear-gradient(135deg, #fdf8f3, #f5e6d3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  position: relative;
  overflow: hidden;
}

.gallery-image-placeholder::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(218, 165, 32, 0.1) 0%, transparent 70%);
  animation: galleryGlow 4s ease-in-out infinite;
}

@keyframes galleryGlow {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(10%, 10%); }
}

.gallery-image-placeholder span {
  position: relative;
  z-index: 1;
  animation: float 3s ease-in-out infinite;
}

.gallery-item:nth-child(2) .gallery-image-placeholder span {
  animation-delay: 0.5s;
}

.gallery-item:nth-child(3) .gallery-image-placeholder span {
  animation-delay: 1s;
}

.gallery-item:nth-child(4) .gallery-image-placeholder span {
  animation-delay: 1.5s;
}

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

.gallery-label {
  padding: 12px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  background: rgba(255, 255, 255, 0.9);
  border-top: 1px solid rgba(139, 69, 19, 0.06);
}

/* Responsive */
@media (max-width: 768px) {
  .tryon-section {
    padding: 48px 0;
  }

  .tryon-steps {
    margin-bottom: 24px;
  }

  .step-line {
    width: 30px;
    margin: 0 8px;
    margin-bottom: 24px;
  }

  .step-label {
    font-size: 0.65rem;
  }

  .tryon-main-card {
    padding: 24px 20px;
  }

  .tryon-upload-area {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .tryon-swap-wrapper {
    padding: 8px 0;
  }

  .tryon-arrow {
    transform: rotate(90deg);
  }

  @keyframes floatArrow {
    0%, 100% { transform: rotate(90deg) translateY(0); }
    50% { transform: rotate(90deg) translateY(4px); }
  }

  .upload-box {
    min-height: 180px;
    padding: 28px 20px;
  }

  .upload-icon-wrapper {
    width: 56px;
    height: 56px;
  }

  .upload-icon {
    font-size: 28px;
  }

  .tryon-tips ul {
    grid-template-columns: 1fr;
  }

  .result-comparison {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}

@media (max-width: 480px) {
  .tryon-title {
    font-size: 1.75rem;
  }

  .tryon-subtitle {
    font-size: 0.9rem;
  }

  .result-actions {
    flex-direction: column;
    width: 100%;
  }

  .download-btn, .try-again-btn {
    width: 100%;
    justify-content: center;
  }
}
