/* ===== 3D Preview Modal Styles ===== */

.preview-3d-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(0,0,0,0.95) 0%, rgba(17,24,39,0.98) 100%);
  z-index: 200;
  backdrop-filter: blur(15px);
}

.preview-3d-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: modalFadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalFadeIn {
  from { 
    opacity: 0; 
    transform: scale(0.85) translateY(20px); 
  }
  to { 
    opacity: 1; 
    transform: scale(1) translateY(0); 
  }
}

.preview-3d-content {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0a0e1a 100%);
  border: none;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
}

.preview-3d-header {
  padding: 20px 32px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: transparent;
  backdrop-filter: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

.preview-3d-title {
  font-size: 24px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  gap: 12px;
}

.preview-3d-title span:first-child {
  font-size: 28px;
}

.preview-3d-close {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: bold;
  transition: all 0.3s ease;
}

.preview-3d-close::before {
  display: none;
}

.preview-3d-close:hover {
  background: rgba(239, 68, 68, 0.8);
  border-color: rgba(239, 68, 68, 1);
  transform: scale(1.1);
}

.preview-3d-close:hover::before {
  display: none;
}

.preview-3d-viewport {
  position: relative;
  width: 100%;
  height: calc(100% - 100px);
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 2000px;
  perspective-origin: 50% 50%;
  background: transparent;
  overflow: hidden;
}

.bag-3d-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  background: transparent;
}

/* Custom 3D Mylar Bag Styles */
.mylar-bag-3d {
  position: relative;
  width: 700px;
  height: 900px;
  margin: 0 auto;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transform: rotateX(-15deg) rotateY(-15deg) scale(1);
  transition: transform 0.3s ease;
  cursor: grab;
  filter: drop-shadow(0 20px 50px rgba(0, 0, 0, 0.5));
  background: transparent;
}

.mylar-bag-3d:active {
  cursor: grabbing;
}

.bag-face-front,
.bag-face-back {
  position: absolute;
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  overflow: hidden;
}

.bag-face-front {
  transform: rotateY(0deg) translateZ(3px);
  -webkit-transform: rotateY(0deg) translateZ(3px);
}

.bag-face-back {
  transform: rotateY(180deg) translateZ(1px);
  -webkit-transform: rotateY(180deg) translateZ(1px);
}

.bag-design-front,
.bag-design-back {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  background: transparent;
  border: none;
  outline: none;
  box-shadow: none;
}

/* Ensure no browser default outlines */
.mylar-bag-3d *,
.bag-face-front *,
.bag-face-back * {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
}

.bag-edge-left,
.bag-edge-right {
  display: none;
}

.bag-highlight {
  display: none;
}

/* 3D Controls */
.bag-3d-controls {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 16px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.95));
  padding: 20px 32px;
  border-radius: 20px;
  border: 2px solid rgba(239, 68, 68, 0.3);
  backdrop-filter: blur(25px);
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.6),
    0 0 40px rgba(239, 68, 68, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.bag-3d-control-btn {
  padding: 14px 24px;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(51, 65, 85, 0.8));
  border: 2px solid rgba(148, 163, 184, 0.3);
  border-radius: 12px;
  color: #e2e8f0;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.bag-3d-control-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(45deg, transparent, rgba(255,255,255,0.1), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s;
}

.bag-3d-control-btn:hover {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.4), rgba(220, 38, 38, 0.4));
  border-color: var(--red-primary);
  transform: translateY(-3px);
  color: #ffffff;
  box-shadow: 
    0 8px 25px rgba(239, 68, 68, 0.4),
    0 0 30px rgba(239, 68, 68, 0.2);
}

.bag-3d-control-btn:hover::before {
  transform: translateX(100%);
}

.bag-3d-control-btn.active {
  background: linear-gradient(135deg, var(--red-primary), #dc2626);
  border-color: var(--red-primary);
  color: white;
  box-shadow: 
    0 6px 20px rgba(239, 68, 68, 0.6),
    inset 0 2px 0 rgba(255, 255, 255, 0.2);
}

/* Enhanced Realistic 3D Bag Face Styles */
.bag-3d-face {
  position: absolute;
  width: 420px;
  height: 630px;
  background: linear-gradient(135deg, 
    rgba(248, 250, 252, 0.95) 0%, 
    rgba(241, 245, 249, 0.90) 20%, 
    rgba(226, 232, 240, 0.85) 40%, 
    rgba(203, 213, 225, 0.80) 60%, 
    rgba(148, 163, 184, 0.85) 80%, 
    rgba(100, 116, 139, 0.90) 100%);
  border-radius: 28px;
  box-shadow: 
    0 25px 80px rgba(0, 0, 0, 0.6),
    inset 0 2px 15px rgba(255, 255, 255, 0.4),
    inset 0 -2px 15px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  backface-visibility: hidden;
}

/* Realistic mylar bag metallic reflection */
.bag-3d-face::before {
  content: '';
  position: absolute;
  top: 15px;
  left: 15px;
  right: 15px;
  bottom: 15px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  pointer-events: none;
}

.bag-3d-face::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, 
    transparent 30%, 
    rgba(255, 255, 255, 0.1) 35%, 
    rgba(255, 255, 255, 0.3) 40%, 
    rgba(255, 255, 255, 0.1) 45%, 
    transparent 50%);
  animation: shimmer 3s ease-in-out infinite;
  pointer-events: none;
}

@keyframes shimmer {
  0%, 100% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
  50% { transform: translateX(200%) translateY(200%) rotate(45deg); }
}

.bag-3d-front {
  transform: translateZ(35px);
  z-index: 2;
}

.bag-3d-back {
  transform: rotateY(180deg) translateZ(35px);
  z-index: 1;
}

.bag-3d-left {
  width: 70px;
  transform: rotateY(-90deg) translateZ(210px);
  background: linear-gradient(135deg, #64748b 0%, #475569 50%, #374151 100%);
  z-index: 1;
}

.bag-3d-right {
  width: 70px;
  transform: rotateY(90deg) translateZ(210px);
  background: linear-gradient(135deg, #64748b 0%, #475569 50%, #374151 100%);
  z-index: 1;
}

.bag-3d-top {
  height: 70px;
  transform: rotateX(90deg) translateZ(315px);
  background: linear-gradient(135deg, #94a3b8 0%, #64748b 50%, #475569 100%);
  border-radius: 28px 28px 8px 8px;
  z-index: 1;
}

.bag-3d-bottom {
  height: 70px;
  transform: rotateX(-90deg) translateZ(315px);
  background: linear-gradient(135deg, #475569 0%, #374151 50%, #1f2937 100%);
  border-radius: 8px 8px 28px 28px;
  z-index: 1;
}

.bag-3d-design {
  max-width: 88%;
  max-height: 88%;
  object-fit: contain;
  pointer-events: none;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

@keyframes enhance3dRotate {
  0% { transform: rotateY(0deg) rotateX(8deg) rotateZ(2deg); }
  15% { transform: rotateY(45deg) rotateX(10deg) rotateZ(1deg); }
  25% { transform: rotateY(90deg) rotateX(12deg) rotateZ(-1deg); }
  35% { transform: rotateY(135deg) rotateX(10deg) rotateZ(0deg); }
  50% { transform: rotateY(180deg) rotateX(8deg) rotateZ(2deg); }
  65% { transform: rotateY(225deg) rotateX(6deg) rotateZ(-1deg); }
  75% { transform: rotateY(270deg) rotateX(5deg) rotateZ(-1deg); }
  85% { transform: rotateY(315deg) rotateX(7deg) rotateZ(1deg); }
  100% { transform: rotateY(360deg) rotateX(8deg) rotateZ(2deg); }
}

.bag-3d-container.paused {
  animation-play-state: paused;
}

/* Enhanced mobile responsiveness for 3D preview */
@media (max-width: 768px) {
  .preview-3d-content {
    width: 98%;
    height: 98vh;
    border-radius: 16px;
  }
  
  .preview-3d-header {
    padding: 20px;
  }
  
  .preview-3d-title {
    font-size: 22px;
  }
  
  .mylar-bag-3d {
    width: 350px;
    height: 460px;
    margin: 30px auto;
  }
  
  .bag-3d-container {
    width: 320px;
    height: 480px;
    animation-duration: 30s;
  }
  
  .bag-3d-face {
    width: 320px;
    height: 480px;
    border-radius: 20px;
  }
  
  .bag-3d-controls {
    bottom: 20px;
    padding: 16px 24px;
    gap: 12px;
  }
  
  .bag-3d-control-btn {
    padding: 12px 20px;
    font-size: 14px;
  }
  
  .bag-edge-left,
  .bag-edge-right {
    width: 30px;
  }
  
  .bag-edge-left {
    left: -15px;
    transform: rotateY(-90deg) translateZ(15px);
  }
  
  .bag-edge-right {
    right: -15px;
    transform: rotateY(90deg) translateZ(15px);
  }
}

/* Very small screens */
@media (max-width: 480px) {
  .mylar-bag-3d {
    width: 300px;
    height: 400px;
    margin: 20px auto;
  }
}