/**
 * Enhanced Product Modal - AliExpress Style
 * Features: Image slideshow, thumbnails, hover magnify
 */

/* ============================================
   PRODUCT MODAL - ALIEXPRESS STYLE
   ============================================ */

.product-modal-enhanced {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.product-modal-enhanced.active {
  opacity: 1;
  visibility: visible;
}

.product-modal-enhanced .modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  cursor: pointer;
  backdrop-filter: blur(3px);
}

.product-modal-enhanced .modal-container {
  position: relative;
  background: white;
  border-radius: 12px;
  max-width: 1100px;
  width: 95%;
  max-height: 92vh;
  overflow-y: auto;
  margin: 15px;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.35);
  animation: modalSlideUp 0.35s ease;
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.product-modal-enhanced .modal-close-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  background: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 100;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #555;
  transition: all 0.25s ease;
}

.product-modal-enhanced .modal-close-btn:hover {
  background: #ff4444;
  color: white;
  transform: rotate(90deg);
}

/* Modal Body Layout */
.product-modal-enhanced .modal-body {
  display: grid;
  grid-template-columns: minmax(320px, 520px) 1fr;
  gap: 35px;
  padding: 30px;
}

@media (max-width: 768px) {
  .product-modal-enhanced .modal-body {
    grid-template-columns: 1fr;
    gap: 25px;
    padding: 20px;
  }
}

/* ============================================
   IMAGE GALLERY SECTION
   ============================================ */

.product-gallery {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.product-gallery-thumbnails {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 70px;
  max-height: 500px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #ddd #f5f5f5;
  flex-shrink: 0;
}

.product-gallery-thumbnails::-webkit-scrollbar {
  width: 4px;
}

.product-gallery-thumbnails::-webkit-scrollbar-track {
  background: #f5f5f5;
  border-radius: 2px;
}

.product-gallery-thumbnails::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 2px;
}

.thumbnail-item {
  width: 65px;
  height: 65px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.thumbnail-item:hover {
  border-color: var(--primary-color);
}

.thumbnail-item.active {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(255, 105, 0, 0.25);
}

.thumbnail-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Main Image Container */
.product-gallery-main {
  flex: 1;
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  background: #fafafa;
  border: 1px solid #eee;
  display: flex;
  flex-direction: column;
}

.main-image-container {
  position: relative;
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 200px;
  max-height: 500px;
}

.main-image-slide {
  display: none;
  width: 100%;
  text-align: center;
}

.main-image-slide.active {
  display: block;
}

.main-image-slide img {
  display: block;
  max-width: 100%;
  max-height: 500px;
  width: auto;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
  transition: transform 0.1s ease;
}

/* Image Navigation Arrows */
.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.95);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #333;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
  z-index: 10;
  opacity: 0.7;
}

.product-gallery-main:hover .gallery-nav {
  opacity: 1;
}

.gallery-nav:hover {
  background: var(--primary-color);
  color: white;
}

.gallery-nav.prev {
  left: 12px;
}

.gallery-nav.next {
  right: 12px;
}

/* Image Counter */
.image-counter {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  z-index: 5;
}

/* ============================================
   ZOOM/MAGNIFY FUNCTIONALITY
   ============================================ */

.main-image-slide.zoom-enabled img {
  cursor: zoom-in;
}

.zoom-lens {
  position: absolute;
  width: 150px;
  height: 150px;
  border: 2px solid var(--primary-color);
  background: rgba(255, 105, 0, 0.1);
  border-radius: 8px;
  pointer-events: none;
  opacity: 0;
  z-index: 20;
}

.zoom-lens.active {
  opacity: 1;
}

.zoom-preview {
  position: absolute;
  top: 0;
  left: calc(100% + 15px);
  width: 450px;
  height: 450px;
  border: 1px solid #ddd;
  border-radius: 10px;
  background: white;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.zoom-preview.active {
  opacity: 1;
  visibility: visible;
}

.zoom-preview img {
  position: absolute;
  max-width: none;
  max-height: none;
}

/* Mobile: No zoom preview, use pinch-zoom instead */
@media (max-width: 1024px) {
  .zoom-lens,
  .zoom-preview {
    display: none !important;
  }
  
  .product-gallery {
    flex-direction: column-reverse;
  }
  
  .product-gallery-thumbnails {
    flex-direction: row;
    width: 100%;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 5px;
  }
  
  .thumbnail-item {
    width: 55px;
    height: 55px;
  }
}

/* ============================================
   PRODUCT INFO SECTION
   ============================================ */

.product-modal-info {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.product-modal-info .product-badge-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.product-modal-info .product-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.product-badge.badge-new {
  background: #e3f2fd;
  color: #1976d2;
}

.product-badge.badge-hot {
  background: #ffebee;
  color: #d32f2f;
}

.product-badge.badge-sale {
  background: #fff3e0;
  color: #f57c00;
}

.product-badge.badge-featured {
  background: #e8f5e9;
  color: #388e3c;
}

.product-modal-info .product-title {
  font-size: 1.6rem;
  font-weight: 600;
  color: #222;
  line-height: 1.35;
  margin: 0;
}

.product-modal-info .product-rating-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.product-modal-info .stars {
  color: #ffc107;
  font-size: 14px;
  display: flex;
  gap: 2px;
}

.product-modal-info .rating-text {
  color: #666;
  font-size: 14px;
}

.product-modal-info .rating-text strong {
  color: #333;
}

.product-modal-info .sales-count {
  color: #888;
  font-size: 13px;
  padding-left: 10px;
  border-left: 1px solid #ddd;
}

/* Price Section */
.product-price-section {
  background: linear-gradient(135deg, #fff5f0 0%, #fff 100%);
  border: 1px solid #ffe0d0;
  border-radius: 10px;
  padding: 18px 20px;
  margin: 5px 0;
}

.product-price-section .current-price {
  font-size: 2rem;
  font-weight: 700;
  color: #ff4400;
}

.product-price-section .original-price {
  font-size: 1rem;
  color: #999;
  text-decoration: line-through;
  margin-left: 12px;
}

.product-price-section .discount-badge {
  background: #ff4400;
  color: white;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 10px;
}

.product-price-section .price-note {
  font-size: 12px;
  color: #888;
  margin-top: 8px;
}

/* Category */
.product-modal-info .product-category-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f0f0f0;
  color: #555;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  width: fit-content;
}

.product-modal-info .product-category-tag i {
  font-size: 11px;
}

/* Description */
.product-description-section {
  border-top: 1px solid #eee;
  padding-top: 15px;
}

.product-description-section h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 10px;
}

.product-description-section p {
  color: #555;
  line-height: 1.7;
  font-size: 14px;
}

/* Specifications */
.product-specs-section {
  border-top: 1px solid #eee;
  padding-top: 15px;
}

.product-specs-section h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 12px;
}

.specs-grid {
  display: grid;
  gap: 8px;
}

.spec-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  padding: 8px 0;
  border-bottom: 1px dashed #eee;
}

.spec-item:last-child {
  border-bottom: none;
}

.spec-item i {
  color: var(--primary-color);
  font-size: 12px;
  margin-top: 3px;
}

.spec-item span {
  color: #444;
}

/* Stock Status */
.stock-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  padding: 8px 0;
}

.stock-status.in-stock {
  color: #28a745;
}

.stock-status.out-of-stock {
  color: #dc3545;
}

.stock-status i {
  font-size: 12px;
}

/* Action Buttons */
.product-action-buttons {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  padding-top: 15px;
  border-top: 1px solid #eee;
}

.product-action-buttons .btn {
  flex: 1;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.product-action-buttons .btn-add-cart {
  background: var(--primary-color);
  color: white;
  border: none;
}

.product-action-buttons .btn-add-cart:hover {
  background: var(--secondary-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(255, 105, 0, 0.35);
}

.product-action-buttons .btn-quote {
  background: white;
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
}

.product-action-buttons .btn-quote:hover {
  background: var(--primary-color);
  color: white;
}

.product-action-buttons .btn:disabled {
  background: #ccc;
  border-color: #ccc;
  color: #888;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Product Meta */
.product-meta-info {
  font-size: 12px;
  color: #999;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #eee;
}

.product-meta-info span {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 768px) {
  .product-modal-enhanced .modal-container {
    max-height: 95vh;
    margin: 10px;
    border-radius: 10px;
  }
  
  .product-modal-enhanced .modal-body {
    padding: 15px;
    gap: 20px;
  }
  
  .product-modal-info .product-title {
    font-size: 1.3rem;
  }
  
  .product-price-section .current-price {
    font-size: 1.6rem;
  }
  
  .product-action-buttons {
    flex-direction: column;
  }
  
  .product-action-buttons .btn {
    padding: 12px 16px;
  }
}

/* ============================================
   ADMIN IMAGE UPLOAD SECTION
   ============================================ */

.image-upload-section {
  border: 2px dashed #ddd;
  border-radius: 10px;
  padding: 20px;
  background: #fafafa;
}

.image-upload-section h4 {
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

.image-upload-hint {
  font-size: 12px;
  color: #888;
  margin-bottom: 15px;
}

.image-previews-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
  margin-bottom: 15px;
}

.image-preview-item {
  position: relative;
  aspect-ratio: 1;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.image-preview-item.primary {
  border-color: var(--primary-color);
}

.image-preview-item.primary::after {
  content: 'Main';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--primary-color);
  color: white;
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  padding: 3px;
}

.image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview-item .remove-image {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  background: rgba(255, 0, 0, 0.85);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.image-preview-item:hover .remove-image {
  opacity: 1;
}

.image-preview-item .set-primary {
  position: absolute;
  bottom: 5px;
  right: 5px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 9px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.image-preview-item:hover .set-primary {
  opacity: 1;
}

.image-preview-item.primary .set-primary {
  display: none;
}

.add-image-placeholder {
  aspect-ratio: 1;
  border: 2px dashed #ccc;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: #fff;
  transition: all 0.2s ease;
  gap: 5px;
}

.add-image-placeholder:hover {
  border-color: var(--primary-color);
  background: #fff5f0;
}

.add-image-placeholder i {
  font-size: 24px;
  color: #aaa;
}

.add-image-placeholder span {
  font-size: 11px;
  color: #888;
}

.add-image-placeholder.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* URL input alternative */
.image-url-input-group {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.image-url-input-group input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
}

.image-url-input-group button {
  padding: 10px 16px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.image-url-input-group button:hover {
  background: var(--secondary-color);
}
