:root {
  --vh: 1vh;
  --primary-500: #14b8a6;
  --primary-600: #0d9488;
  --accent-400: #fb923c;
  --accent-500: #f97316;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-400: #9ca3af;
  --gray-600: #4b5563;
  --gray-800: #1f2937;
}

/* Modal Base Styles */
.product-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: none; /* Hidden by default */
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 20px;
  box-sizing: border-box;
}

.product-modal.show {
  display: flex;
}

.product-modal-content {
  max-width: 850px;
  max-height: 80vh;
  max-height: calc(80 * var(--vh));
  width: 90%;
  background-color: white;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  display: flex;
  flex-wrap: nowrap;
  position: relative;
  margin: 0 auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.product-modal-content::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* Animation */
.animate-popup {
  animation: popupEffect 0.4s ease-out;
  transform-origin: center;
}

@keyframes popupEffect {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  70% {
    transform: scale(1.03);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Prevent body scroll when modal is open */
body.modal-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

/* Left Side Styles */
.modal-left {
  width: 45%;
  padding: 30px 25px;
  background-color: var(--gray-100);
  border-right: 1px solid var(--gray-200);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.product-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--gray-800);
  margin: 0 0 15px 0;
  line-height: 1.3;
}

.buyers-guide-badge {
  margin: 15px auto;
  text-align: center;
}

.buyers-guide-badge img {
  max-width: 180px;
  height: auto;
  width: 100%;
}

.product-info {
  margin-top: 15px;
}

.product-description {
  font-size: 16px;
  color: var(--gray-600);
  margin-bottom: 20px;
  line-height: 1.5;
}

.exclusive-savings {
  background-color: rgba(251, 146, 60, 0.2);
  color: var(--accent-500);
  padding: 8px 15px;
  border-radius: 4px;
  font-weight: 600;
  display: inline-block;
  margin-bottom: 20px;
  font-size: 15px;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
}

.view-deal-btn {
  display: block;
  background-color: var(--primary-500);
  color: white;
  text-align: center;
  padding: 14px 20px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s ease;
  margin-bottom: 20px;
  box-shadow: 0 4px 8px rgba(20, 184, 166, 0.2);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  font-size: 16px;
  width: 100%;
  box-sizing: border-box;
}

.view-deal-btn:hover {
  background-color: var(--primary-600);
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(20, 184, 166, 0.3);
}

.amazon-logo {
  text-align: center;
  margin-top: 15px;
}

.amazon-logo.large-logo img {
  max-width: 200px;
  height: auto;
  width: 100%;
}

/* Right Side Styles */
.modal-right {
  width: 55%;
  padding: 30px 25px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 15px;
  position: relative;
  padding-bottom: 20px;
}

/* Rating Section */
.desktop-rating-section {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  background-color: rgba(20, 184, 166, 0.1);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 15px;
  line-height: 1;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.mobile-rating-section {
  display: none;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 8px 12px;
  background-color: rgba(20, 184, 166, 0.1);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 15px;
  line-height: 1;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.rating-score {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-500);
  margin-right: 6px;
}

.rating-stars {
  font-size: 14px;
  color: var(--accent-400);
  display: flex;
  gap: 3px;
}

.rating-text {
  font-size: 13px;
  color: var(--gray-600);
  margin-left: auto;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Product Images */
.product-image-main {
  height: 220px;
  margin: 15px 0;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: var(--gray-100);
  border-radius: 8px;
  padding: 15px;
  position: relative;
  min-height: 220px;
}

.active-image {
  display: block;
  max-height: 220px;
  max-width: 100%;
  height: auto;
  width: auto;
  object-fit: contain;
  transition: opacity 0.3s ease;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.hover-image {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-height: 220px;
  max-width: 100%;
  height: auto;
  width: auto;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.hover-image.active {
  opacity: 1;
  z-index: 2;
}

.active-image.hidden {
  opacity: 0;
}

.thumbnail {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border: 2px solid var(--gray-200);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.thumbnail:hover {
  border-color: var(--primary-500);
  transform: scale(1.05);
}

.thumbnail.active {
  border-color: var(--primary-500);
  position: relative;
  transform: scale(1.1);
  box-shadow: 0 4px 8px rgba(20, 184, 166, 0.2);
}

.thumbnail.active::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border: 2px solid var(--primary-500);
  border-radius: 4px;
  pointer-events: none;
}

.product-thumbnails {
  display: flex;
  gap: 12px;
  margin: 15px 0;
  padding: 8px 0 10px;
  justify-content: center;
  scrollbar-width: none;
  -ms-overflow-style: none;
  overflow-x: auto;
  flex-wrap: nowrap;
}

.product-thumbnails::-webkit-scrollbar {
  display: none;
}

/* Availability */
.product-availability {
  font-size: 14px;
  color: var(--gray-600);
  margin-top: 10px;
  text-align: center;
  flex-shrink: 0;
}

.size-link {
  color: var(--primary-500);
  text-decoration: none;
  font-weight: 600;
}

.size-link:hover {
  text-decoration: underline;
}

.close-modal {
  position: absolute;
  top: 15px;
  right: 15px;
  font-size: 30px;
  color: var(--gray-400);
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 10;
  padding: 5px;
  -webkit-tap-highlight-color: transparent;
  background-color: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.close-modal:hover {
  color: var(--accent-500);
  transform: rotate(90deg);
  background-color: rgba(255, 255, 255, 1);
}

/* Responsive Styles */
@media (max-width: 768px) {
  .product-modal {
    padding: 40px 15px 15px;
    align-items: flex-start;
  }

  .product-modal-content {
    flex-direction: column;
    max-height: none;
    height: auto;
    overflow: visible;
    width: 100%;
    margin: 0 auto;
    -webkit-overflow-scrolling: touch;
    overflow-x: hidden !important;
  }

  .modal-left,
  .modal-right {
    width: 100%;
    padding: 20px 15px;
    overflow: visible;
  }

  .modal-left {
    padding-bottom: 15px;
    border-right: none;
    border-bottom: 1px solid var(--gray-200);
  }

  .modal-right {
    padding-top: 15px;
  }

  .desktop-rating-section {
    display: none;
  }

  .mobile-rating-section {
    display: flex;
  }

  .product-title {
    font-size: 20px;
    margin-bottom: 12px;
  }

  .product-description {
    font-size: 15px;
    margin-bottom: 15px;
  }

  .product-image-main {
    height: auto;
    min-height: 120px;
    max-height: 180px;
    margin: 10px 0;
  }

  .active-image,
  .hover-image {
    max-height: 160px;
  }

  .thumbnail {
    width: 50px;
    height: 50px;
  }

  .view-deal-btn {
    padding: 14px 15px;
    margin-bottom: 15px;
    font-size: 15px;
  }

  .buyers-guide-badge img {
    max-width: 150px;
  }

  .amazon-logo.large-logo img {
    max-width: 180px;
  }

  .close-modal {
    top: 10px;
    right: 10px;
    font-size: 26px;
    width: 36px;
    height: 36px;
  }

  .product-thumbnails {
    margin-top: -10px;
    padding-bottom: 5px;
    margin-bottom: 5px;
    flex-wrap: wrap !important;
    justify-content: center;
    overflow-x: hidden !important;
    gap: 8px;
    -webkit-overflow-scrolling: auto;
    touch-action: pan-y;
  }
}

@media (max-width: 480px) {
  .product-modal {
    padding: 50px 10px 10px;
  }

  .product-modal-content {
    width: 100%;
    border-radius: 8px;
  }

  .product-title {
    font-size: 18px;
  }

  .product-description {
    font-size: 14px;
  }

  .view-deal-btn {
    padding: 13px 15px;
    font-size: 15px;
  }

  .rating-section {
    padding: 6px 10px;
    margin-bottom: 10px;
  }

  .rating-score {
    font-size: 16px;
  }

  .rating-stars {
    font-size: 12px;
  }

  .rating-text {
    font-size: 12px;
  }

  .product-thumbnails {
    gap: 8px;
    padding: 5px 0;
  }

  .thumbnail {
    width: 45px !important;
    height: 45px !important;
  }

  .close-modal {
    top: 8px;
    right: 8px;
    font-size: 24px;
    width: 34px;
    height: 34px;
  }

  .exclusive-savings {
    font-size: 14px;
    padding: 6px 10px;
  }

  .product-availability {
    font-size: 13px;
    margin-top: 5px;
  }

  .product-image-main {
    height: auto;
  }

  .active-image,
  .hover-image {
    max-height: 140px;
  }

  .amazon-logo.large-logo img {
    max-width: 160px;
  }
}

@media (max-width: 360px) {
  .modal-left,
  .modal-right {
    padding: 15px 10px;
  }

  .product-title {
    font-size: 17px;
  }

  .product-description {
    font-size: 13px;
  }

  .view-deal-btn {
    padding: 12px 10px;
    font-size: 14px;
  }

  .thumbnail {
    width: 40px !important;
    height: 40px !important;
  }

  .product-image-main {
    height: auto;
  }

  .active-image,
  .hover-image {
    max-height: 120px;
  }

  .buyers-guide-badge img {
    max-width: 120px;
  }

  .amazon-logo.large-logo img {
    max-width: 140px;
  }

  .close-modal {
    top: 6px;
    right: 6px;
    font-size: 22px;
    width: 32px;
    height: 32px;
  }
}
