/* ===========================================
   PRODUCTS SECTION
   =========================================== */
.products-section {
  padding: 80px 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.section-header {
  text-align: center;
  margin-bottom: 60px;
}

.section-title {
  font-size: 42px;
  font-weight: 800;
  margin-bottom: 16px;
  color: var(--primary);
}

.section-subtitle {
  font-size: 18px;
  color: var(--gray-600);
  max-width: 600px;
  margin: 0 auto;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 32px;
  margin-bottom: 60px;
  justify-items: center;
}

.product-card {
  background: var(--secondary);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius);
  overflow: hidden;
  transition: all 0.4s ease;
  position: relative;
  cursor: pointer;
  box-shadow: var(--shadow);
  max-width: 400px;
  width: 100%;
}

.product-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent);
}

.product-image {
  width: 100%;
  height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--gray-200);
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.product-card:hover .product-image img {
  transform: scale(1.05);
}

.product-image::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at center,
      rgba(0, 255, 148, 0.1) 0%,
      transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.product-card:hover .product-image::before {
  opacity: 1;
}

/* For single product, make the grid use a single centered column */
.products-grid:has(> .product-card:only-child) {
  grid-template-columns: minmax(320px, 400px);
  justify-content: center;
}

.product-info {
  padding: 24px;
}

.product-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--primary);
  line-height: 1.3;
}

.product-description {
  font-size: 14px;
  color: var(--gray-600);
  margin-bottom: 20px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.product-price {
  font-size: 24px;
  font-weight: 800;
  color: var(--accent);
}

.add-to-cart-btn {
  background: var(--primary);
  color: var(--secondary);
  border: none;
  padding: 12px 20px;
  border-radius: 50px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 14px;
}

.add-to-cart-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.add-to-cart-btn:disabled {
  background: var(--gray-200);
  color: var(--gray-600);
  cursor: not-allowed;
  transform: none;
}

/* ===========================================
   PRODUCT POPUP MODAL
   =========================================== */
.product-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-overlay);
  backdrop-filter: blur(10px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  padding: 20px;
}

.product-popup-overlay.active {
  opacity: 1;
  visibility: visible;
}

.product-popup {
  background: var(--secondary);
  border-radius: 20px;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  transform: scale(0.9) translateY(20px);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
}

.product-popup-overlay.active .product-popup {
  transform: scale(1) translateY(0);
}

.popup-header {
  padding: 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.popup-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

.close-popup-btn {
  background: var(--gray-100);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--gray-600);
  transition: all 0.2s ease;
}

.close-popup-btn:hover {
  background: var(--gray-200);
  color: var(--primary);
}

.popup-content {
  display: flex;
  flex: 1;
  min-height: 0;
}

.popup-images-section {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.image-gallery {
  position: relative;
  margin-bottom: 20px;
}

.main-image-container {
  position: relative;
  width: 100%;
  height: 260px;
  background: linear-gradient(135deg, var(--gray-100) 0%, var(--gray-200) 100%);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.main-image {
  font-size: 120px;
  color: var(--gray-600);
}

.image-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-size: 18px;
}

.image-nav:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: translateY(-50%) scale(1.1);
}

.image-nav.prev {
  left: 10px;
}

.image-nav.next {
  right: 10px;
}

.image-indicators {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

.indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gray-200);
  cursor: pointer;
  transition: all 0.2s ease;
}

.indicator.active {
  background: var(--accent);
}

.popup-info-section {
  flex: 1;
  padding: 24px;
  border-left: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
}

.popup-description {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 20px;
  padding-right: 10px;
}

.popup-description::-webkit-scrollbar {
  width: 6px;
}

.popup-description::-webkit-scrollbar-track {
  background: var(--gray-100);
  border-radius: 3px;
}

.popup-description::-webkit-scrollbar-thumb {
  background: var(--gray-600);
  border-radius: 3px;
}

.popup-description::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

.description-content {
  font-size: 16px;
  line-height: 1.6;
  color: var(--gray-600);
  margin-bottom: 24px;
}

.popup-footer {
  border-top: 1px solid var(--gray-200);
  padding: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.popup-price {
  font-size: 32px;
  font-weight: 800;
  color: var(--accent);
}

.popup-add-to-cart {
  background: var(--primary);
  color: var(--secondary);
  border: none;
  padding: 16px 32px;
  border-radius: 50px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 16px;
}

.popup-add-to-cart:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

/* ===========================================
   PRODUCT BADGES
   =========================================== */
.product-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  z-index: 10;
  animation: badgePulse 2s infinite;
}

.product-badge.featured {
  background: var(--accent);
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 255, 148, 0.3);
}

.product-badge.new {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
}

.product-badge.sale {
  background: linear-gradient(135deg, #feca57 0%, #ff9ff3 100%);
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(254, 202, 87, 0.3);
}

/* Badge pulse animation */
@keyframes badgePulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.9;
  }
}

/* ===========================================
   PRODUCT SPECIFICATIONS - IMPROVED STYLING
   =========================================== */

/* Product card specs */
.product-specs {
  margin: 16px 0;
  padding: 16px;
  background: linear-gradient(135deg, var(--gray-50) 0%, rgba(0, 255, 148, 0.02) 100%);
  border: 1px solid var(--gray-100);
  border-radius: 12px;
  backdrop-filter: blur(10px);
}

.spec-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0, 255, 148, 0.1);
  transition: all 0.2s ease;
}

.spec-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.spec-item:hover {
  transform: translateX(2px);
  background: rgba(0, 255, 148, 0.05);
  border-radius: 6px;
  padding-left: 8px;
  padding-right: 8px;
}

.spec-label {
  font-weight: 600;
  font-size: 12px;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.spec-label::before {
  content: "▪";
  color: var(--accent);
  font-size: 14px;
  line-height: 1;
}

.spec-item span:last-child {
  font-weight: 600;
  font-size: 13px;
  color: var(--primary);
  background: var(--secondary);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--gray-200);
  min-width: fit-content;
}

/* Popup specs styling */
.popup-specs {
  margin-bottom: 24px;
  padding: 20px;
  background: linear-gradient(135deg, var(--gray-50) 0%, rgba(0, 255, 148, 0.03) 100%);
  border-radius: 16px;
  border: 1px solid var(--gray-100);
}

.popup-specs h4 {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.popup-specs h4::before {
  content: "📋";
  font-size: 16px;
}

.popup-spec-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  margin-bottom: 8px;
  background: var(--secondary);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  font-size: 14px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.popup-spec-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  transform: scaleY(0);
  transition: transform 0.3s ease;
}

.popup-spec-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 255, 148, 0.1);
  border-color: var(--accent);
}

.popup-spec-item:hover::before {
  transform: scaleY(1);
}

.popup-spec-item:last-child {
  margin-bottom: 0;
}

.popup-spec-label {
  font-weight: 700;
  color: var(--gray-600);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.popup-spec-label::after {
  content: "→";
  color: var(--accent);
  font-size: 14px;
  font-weight: 900;
}

.popup-spec-value {
  color: var(--primary);
  font-weight: 600;
  background: linear-gradient(135deg, var(--accent) 0%, rgba(0, 255, 148, 0.8) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 20px;
  background-color: rgba(0, 255, 148, 0.1);
  -webkit-text-fill-color: var(--primary);
}

/* Special styling for different spec types */
.popup-spec-item:nth-child(odd) {
  background: linear-gradient(135deg, var(--secondary) 0%, rgba(0, 255, 148, 0.02) 100%);
}

.popup-spec-item:nth-child(even) {
  background: linear-gradient(135deg, rgba(0, 255, 148, 0.02) 0%, var(--secondary) 100%);
}

/* Icon indicators for common specs */
.popup-spec-label:has-text("Material")::before,
.spec-label:has-text("Material")::before {
  content: "🧱";
}

.popup-spec-label:has-text("Color")::before,
.spec-label:has-text("Color")::before {
  content: "🎨";
}

.popup-spec-label:has-text("Weight")::before,
.spec-label:has-text("Weight")::before {
  content: "⚖️";
}

.popup-spec-label:has-text("Size")::before,
.spec-label:has-text("Size")::before {
  content: "📏";
}

.popup-spec-label:has-text("Print Time")::before,
.spec-label:has-text("Print Time")::before {
  content: "⏱️";
}

/* Alternative approach for icons since :has-text() isn't widely supported */
.popup-spec-item[data-spec="material"] .popup-spec-label::before,
.spec-item[data-spec="material"] .spec-label::before {
  content: "🧱" !important;
}

.popup-spec-item[data-spec="color"] .popup-spec-label::before,
.spec-item[data-spec="color"] .spec-label::before {
  content: "🎨" !important;
}

.popup-spec-item[data-spec="weight"] .popup-spec-label::before,
.spec-item[data-spec="weight"] .spec-label::before {
  content: "⚖️" !important;
}

.popup-spec-item[data-spec="size"] .popup-spec-label::before,
.spec-item[data-spec="size"] .spec-label::before {
  content: "📏" !important;
}

.popup-spec-item[data-spec="time"] .popup-spec-label::before,
.spec-item[data-spec="time"] .spec-label::before {
  content: "⏱️" !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .products-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .product-popup {
    margin: 10px;
    max-height: 95vh;
  }

  .popup-content {
    flex-direction: column;
  }

  .popup-info-section {
    border-left: none;
    border-top: 1px solid var(--gray-200);
  }

  .main-image-container {
    height: 200px;
  }

  .main-image {
    font-size: 80px;
  }

  .product-specs {
    margin: 12px 0;
    padding: 12px;
  }
  
  .spec-item {
    padding: 6px 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  
  .spec-item span:last-child {
    align-self: flex-end;
    font-size: 12px;
    padding: 3px 8px;
  }
  
  .popup-specs {
    padding: 16px;
  }
  
  .popup-spec-item {
    padding: 10px 12px;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  
  .popup-spec-value {
    align-self: flex-end;
    font-size: 13px;
    padding: 4px 10px;
  }

  .product-badge {
    top: 8px;
    right: 8px;
    padding: 4px 8px;
    font-size: 10px;
  }
}

/* Dark mode adjustments */
.dark-mode .product-specs {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(0, 255, 148, 0.05) 100%);
  border-color: rgba(255, 255, 255, 0.1);
}

.dark-mode .popup-specs {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(0, 255, 148, 0.08) 100%);
  border-color: rgba(255, 255, 255, 0.1);
}

.dark-mode .popup-spec-item {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.1);
}

.dark-mode .popup-spec-item:nth-child(odd) {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.03) 0%, rgba(0, 255, 148, 0.03) 100%);
}

.dark-mode .popup-spec-item:nth-child(even) {
  background: linear-gradient(135deg, rgba(0, 255, 148, 0.03) 0%, rgba(255, 255, 255, 0.03) 100%);
}