.product-comparison {
  position: relative;
  margin: 2rem 0;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.product-comparison__table {
  border-collapse: collapse;
  table-layout: fixed;
  border: 1px solid var(--color-gray-300);
}

/* Header/Cell Styles */
.product-comparison__label-cell {
  width: 250px;
}

.product-comparison__product-cell {
  width: 400px;
  padding: 0 !important;
  vertical-align: top;
}

.product-comparison__add-cell {
  width: 400px;
  padding: 0 !important;
  vertical-align: middle;
}

.product-comparison__product {
  position: relative;
  padding: 1.5rem;
  text-align: center;
  height: 100%;
}

.product-comparison__product-image {
  height: 120px;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-comparison__product-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.product-comparison__product-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: #006ba1;
  margin-bottom: 0.5rem;
}

.product-comparison__product-subtitle {
  font-size: 0.875rem;
  color: #6b7280;
  margin-bottom: 0.5rem;
}

.product-comparison__remove-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  color: #6b7280;
  transition: color 0.2s;
}

.product-comparison__remove-btn span {
  font-size: 1.5rem;
}

.product-comparison__remove-btn:hover {
  color: #ef4444;
}

/* Add Product Styles */
.product-comparison__add-product {
  height: 100%;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.product-comparison__add-product p{
    font-size:var(--text-xs);
    color:var(--color-primary-dark);
    font-weight:300;
}

.product-comparison__add-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background-color: var(--color-primary);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s;
  margin-bottom: var(--spacing-3);
}


.product-comparison__add-btn:hover {
  background-color: var(--color-primary-dark);
}

.product-comparison__add-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.product-comparison__add-btn i{
    font-size:2rem;
}

/* Table Body Styles */
.product-comparison__table tbody th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-weight: 500;
  border-right: 1px solid var(--color-gray-300);
}

.product-comparison__table tbody td {
  text-align: center;
  padding: 0.75rem 1rem;
  border-right: 1px solid var(--color-gray-300);
}

.product-comparison__table thead > tr > th {
  text-align: center;
  border-right: 1px solid var(--color-gray-300);
}

.product-comparison__table thead > tr > th:last-child {
  border-right: none;
}

.product-comparison__table tbody tr:nth-child(even) {
  background-color: #f3f7f9;
}

.product-comparison__group-header {
  background-color: #006ba1 !important;
}

.product-comparison__group-header th {
  color: white !important;
  font-weight: 600;
  padding: 0.75rem 1rem;
}

/* Dropdown Styles */
.product-comparison__dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  z-index: 50;
  min-width: 250px;
}

.product-comparison__dropdown-header {
  padding: var(--spacing-3) var(--spacing-3) 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.product-comparison__dropdown-content {
  padding: 1rem;
  max-height: 400px;
  overflow-y: auto;
}

.product-comparison__product-option {
  width: 100%;
  display: flex;
  align-items: center;
  padding: 0.5rem;
  border: none;
  background: none;
  cursor: pointer;
  transition: background-color 0.2s;
}

.product-comparison__product-option span {
  font-weight: 400;
}

.product-comparison__product-option:hover {
  background-color: #f3f7f9;
}

.product-comparison__product-option img {
  width: 50px;
  height: 50px;
  margin-right: 1rem;
  object-fit: contain;
}

/* Loading State */
.product-comparison__loading {
  position: fixed; 
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  width: 100vw;
  height: 100vh; 
}

.product-comparison__loading[aria-hidden="false"] {
  display: flex;
}

.product-comparison__loading-spinner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #006ba1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
  }

  .product-comparison__more-link{
    color:var(--color-accent);
    font-weight:300;
    transition:200ms;
  }

  .product-comparison__more-link:hover{
    color:var(--color-accent-dark);
    text-decoration:underline;
  }

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Animation Utilities */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Animate Product Cells */
.product-comparison__product-cell {
  transition: width 0.3s ease-out;
}

.product-comparison__product-cell.is-entering {
  animation: slideInRight 0.3s ease-out;
}

.product-comparison__product-cell.is-leaving {
  animation: slideOutRight 0.3s ease-out;
}

/* Smooth Row Updates */
.product-comparison__table tbody tr {
  transition: background-color 0.2s ease;
}

.product-comparison__table tbody td {
  transition: all 0.2s ease;
}

/* Dropdown Animations */
.product-comparison__dropdown {
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  transform-origin: top right;
}

.product-comparison__dropdown[hidden] {
  opacity: 0;
  transform: scale(0.95);
  pointer-events: none;
}

.product-comparison__dropdown:not([hidden]) {
  opacity: 1;
  transform: scale(1);
  display: block;
}

/* Product Option Hover Effects */
.product-comparison__product-option {
  transition: all 0.2s ease;
}

.product-comparison__product-option:hover {
  transform: translateX(5px);
  background-color: #f3f7f9;
}

/* Remove Button Animation */
.product-comparison__remove-btn {
  transition: all 0.2s ease;
}

.product-comparison__product:hover .product-comparison__remove-btn {
  opacity: 1;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .product-comparison {
    margin: 2rem -1rem;
    padding: 0 1rem;
    width: calc(100% + 2rem);
  }

  .product-comparison__table {
    table-layout: fixed; /* Keep fixed layout for predictable column widths */
  }

  .product-comparison__label-cell {
    position: sticky; /* Stick first column */
    left: 0;
    z-index: 2;
    background: white;
    width: 200px;
    min-width: 200px;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
  }

  .product-comparison__product-cell,
  .product-comparison__add-cell {
    width: 300px;
    min-width: 300px;
  }

  .product-comparison__product-image {
    height: 100px;
  }
}

@media (max-width: 768px) {
  .product-comparison {
    margin: 1rem -0.5rem;
    padding: 0 0.5rem;
  }

  .product-comparison__label-cell {
    width: 150px;
    min-width: 150px;
  }

  .product-comparison__product-cell,
  .product-comparison__add-cell {
    width: 250px;
    min-width: 250px;
  }

  /* Further reduce content size */
  .product-comparison__product-image {
    height: 80px;
  }

  .product-comparison__product-title {
    font-size: 0.875rem;
  }

  .product-comparison__product-subtitle {
    font-size: 0.75rem;
  }

  .product-comparison__table thead > tr > th {
    position: relative;
  }

  .product-comparison__table tbody th,
  .product-comparison__table tbody td {
    padding: 0.5rem;
    font-size: 0.875rem;
  }

  /* Add scroll indicators */
  .product-comparison::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.9));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
  }

  .product-comparison:not([data-scrolled="end"])::after {
    opacity: 0;
  }
}
