/* WC Compare Table - Modern Responsive Styles */

:root {
  --wccmp-col-min: 200px;
  --wccmp-head-h: 280px;
  --wccmp-radius: 16px;
  --wccmp-border: #e5e7eb;
  --wccmp-muted: #64748b;
  --wccmp-bg: #ffffff;
  --wccmp-bg-soft: #f8fafc;
  --wccmp-brand: #0ea5e9;
  --wccmp-row-hover: #fbfdff;
  --wccmp-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --wccmp-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --wccmp-transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Main wrapper */
.wccmp-wrap {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: #1f2937;
  margin: 1rem 0;
}

/* Error states */
.wccmp-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--wccmp-radius);
  padding: 1rem;
  color: #dc2626;
  text-align: center;
}

/* Toolbar */
.wccmp-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.wccmp-title {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.025em;
  color: #111827;
}

.wccmp-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.wccmp-toggle {
  user-select: none;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #374151;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.5rem;
  transition: var(--wccmp-transition);
}

.wccmp-toggle:hover {
  background: var(--wccmp-bg-soft);
}

.wccmp-toggle input {
  transform: translateY(1px);
  margin: 0;
}

.wccmp-reset,
.wccmp-mobile-toggle {
  border: 1px solid var(--wccmp-border);
  background: #fff;
  border-radius: 9999px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  transition: var(--wccmp-transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.wccmp-reset:hover,
.wccmp-mobile-toggle:hover {
  background: var(--wccmp-bg-soft);
  transform: translateY(-1px);
  box-shadow: var(--wccmp-shadow);
}

.wccmp-mobile-toggle {
  display: none;
}

.wccmp-mobile-icon {
  font-size: 1rem;
}

/* Hint */
.wccmp-hint {
  font-size: 0.875rem;
  color: var(--wccmp-muted);
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--wccmp-bg-soft);
  border-radius: 0.5rem;
  border-left: 4px solid var(--wccmp-brand);
}

.wccmp-hint span {
  font-weight: 700;
  color: #111827;
}

/* Scroll container */
.wccmp-scroll {
  overflow: auto;
  border: 1px solid var(--wccmp-border);
  border-radius: var(--wccmp-radius);
  background: var(--wccmp-bg);
  box-shadow: var(--wccmp-shadow);
  -webkit-overflow-scrolling: touch;
}

/* Table */
.wccmp-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: calc(1 * var(--wccmp-col-min) + 1px + 4 * var(--wccmp-col-min));
}

/* Table cells */
thead th,
tbody td,
tbody th {
  border-bottom: 1px solid #eef2f7;
  padding: 1rem;
  vertical-align: top;
  text-align: left;
}

thead th {
  background: var(--wccmp-bg-soft);
  position: sticky;
  top: 0;
  z-index: 2;
  font-weight: 700;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #374151;
}

/* Sticky first column */
.wccmp-sticky {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--wccmp-bg);
  min-width: var(--wccmp-col-min);
  max-width: 300px;
}

thead .wccmp-sticky {
  background: #f1f5f9;
}

/* Centered text for product columns */
.wccmp-product,
.wccmp-val,
.wccmp-name,
.wccmp-cta,
.wccmp-price,
.wccmp-rating {
  text-align: center;
}

.wccmp-product {
  min-width: var(--wccmp-col-min);
  background: var(--wccmp-bg-soft);
  vertical-align: top;
}

/* Product header */
.wccmp-thumb {
  display: block;
  margin: 0.5rem auto;
  width: 100%;
  max-width: 140px;
  aspect-ratio: 1 / 1;
  background: #f1f5f9;
  border-radius: 12px;
  overflow: hidden;
  transition: var(--wccmp-transition);
  text-decoration: none;
}

.wccmp-thumb:hover {
  transform: scale(1.05);
  box-shadow: var(--wccmp-shadow-lg);
}

.wccmp-img {
  width: 100%;
  height: 100%;
  object-fit: contain !important;
  object-position: center !important;
  display: block;
}

.wccmp-name {
  font-weight: 700;
  line-height: 1.25;
  margin: 0.5rem 0;
}

.wccmp-name .wccmp-sort-name {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: #111827;
  text-decoration: none;
  font: inherit;
  font-weight: 800;
  transition: var(--wccmp-transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.wccmp-name .wccmp-sort-name:hover {
  color: var(--wccmp-brand);
  text-decoration: underline;
}

.wccmp-sort-indicator {
  display: inline-block;
  width: 0.75em;
  height: 0.75em;
  opacity: 0.5;
  transition: var(--wccmp-transition);
}

.wccmp-name .wccmp-sort-name:hover .wccmp-sort-indicator {
  opacity: 1;
}

/* Price */
.wccmp-price {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--wccmp-brand);
  margin: 0.5rem 0;
}

.wccmp-price del {
  color: var(--wccmp-muted);
  font-weight: 400;
  font-size: 0.875rem;
}

/* Rating */
.wccmp-rating {
  margin: 0.5rem 0;
}

.wccmp-rating .star-rating {
  margin: 0 auto;
}

/* SKU */
.wccmp-sku {
  margin: 0.25rem 0;
  color: var(--wccmp-muted);
}

.wccmp-sku small {
  font-size: 0.75rem;
  font-weight: 500;
}

/* Weight */
.wccmp-weight {
  margin: 0.25rem 0;
  color: var(--wccmp-muted);
}

.wccmp-weight small {
  font-size: 0.75rem;
  font-weight: 500;
}

/* Dimensions */
.wccmp-dimensions {
  margin: 0.25rem 0;
  color: var(--wccmp-muted);
}

.wccmp-dimensions small {
  font-size: 0.75rem;
  font-weight: 500;
}

/* CTA button */
.wccmp-cta {
  margin: 0.75rem 0 0.5rem;
}

.wccmp-btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: 9999px;
  background: var(--wccmp-brand);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.875rem;
  transition: var(--wccmp-transition);
  border: none;
  cursor: pointer;
}

.wccmp-btn:hover {
  background: #0284c7;
  transform: translateY(-2px);
  box-shadow: var(--wccmp-shadow-lg);
  color: #fff;
}

/* Rows */
tbody tr:nth-child(even) {
  background: #fcfdff;
}

tbody tr:hover td,
tbody tr:hover th.wccmp-sticky {
  background: var(--wccmp-row-hover);
}

/* Attribute column */
.wccmp-attr {
  font-weight: 700;
  color: #111827;
  background: var(--wccmp-bg);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
}

.wccmp-attr .wccmp-sort-attr {
  width: 20px;
  height: 20px;
  border: 1px solid var(--wccmp-border);
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  position: relative;
  flex: 0 0 auto;
  transition: var(--wccmp-transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.wccmp-attr .wccmp-sort-attr::before {
  content: "⇅";
  font-size: 0.75rem;
  line-height: 1;
  color: #6b7280;
}

.wccmp-attr .wccmp-sort-attr:hover {
  background: var(--wccmp-bg-soft);
  border-color: var(--wccmp-brand);
}

.wccmp-attr .wccmp-sort-attr:hover::before {
  color: var(--wccmp-brand);
}

.wccmp-val {
  color: #111827;
  font-weight: 500;
}

/* Show only differences */
.wccmp-wrap.wccmp-diff-only tbody tr.is-same {
  display: none;
}

/* Highlight differences */
.wccmp-wrap.wccmp-highlight-differences tbody tr.is-different {
  background: linear-gradient(90deg, #fef3c7 0%, #fef3c7 100%);
  border-left: 4px solid #f59e0b;
}

.wccmp-wrap.wccmp-highlight-differences tbody tr.is-different th.wccmp-sticky {
  background: #fef3c7;
  border-left: 4px solid #f59e0b;
}

.wccmp-wrap.wccmp-highlight-differences tbody tr.is-different td {
  background: #fef3c7;
}

/* Column highlight */
.wccmp-colhighlight {
  background: #f6fbff !important;
}

/* Mobile responsive design */
@media (max-width: 1024px) {
  .wccmp-wrap {
    --wccmp-col-min: 180px;
  }
  
  .wccmp-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  
  .wccmp-actions {
    justify-content: center;
  }
  
  .wccmp-mobile-toggle {
    display: flex;
  }
}

@media (max-width: 768px) {
  .wccmp-wrap {
    --wccmp-col-min: 160px;
  }
  
  thead th,
  tbody td,
  tbody th {
    padding: 0.75rem 0.5rem;
  }
  
  .wccmp-thumb {
    max-width: 120px;
  }
  
  .wccmp-name {
    font-size: 0.875rem;
  }
  
  .wccmp-price {
    font-size: 1rem;
  }
  
  .wccmp-btn {
    padding: 0.625rem 1.25rem;
    font-size: 0.8125rem;
  }
}

@media (max-width: 640px) {
  .wccmp-wrap {
    --wccmp-col-min: 140px;
  }
  
  .wccmp-hint {
    font-size: 0.8125rem;
    padding: 0.625rem;
  }
  
  .wccmp-thumb {
    max-width: 100px;
  }
  
  .wccmp-name {
    font-size: 0.8125rem;
    line-height: 1.2;
  }
  
  .wccmp-price {
    font-size: 0.875rem;
  }
  
  .wccmp-btn {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
  }
  
  .wccmp-attr {
    font-size: 0.875rem;
    padding: 0.75rem 0.5rem;
  }
  
  .wccmp-val {
    font-size: 0.875rem;
  }
}

/* Mobile view modes */
.wccmp-mobile-cards .wccmp-scroll {
  overflow: visible;
}

.wccmp-mobile-cards .wccmp-table {
  display: block;
  min-width: auto;
}

.wccmp-mobile-cards .wccmp-table thead {
  display: none;
}

.wccmp-mobile-cards .wccmp-table tbody {
  display: block;
}

.wccmp-mobile-cards .wccmp-table tbody tr {
  display: block;
  margin-bottom: 1rem;
  border: 1px solid var(--wccmp-border);
  border-radius: var(--wccmp-radius);
  background: var(--wccmp-bg);
  box-shadow: var(--wccmp-shadow);
  overflow: hidden;
}

.wccmp-mobile-cards .wccmp-table tbody tr:last-child {
  margin-bottom: 0;
}

.wccmp-mobile-cards .wccmp-table tbody th,
.wccmp-mobile-cards .wccmp-table tbody td {
  display: block;
  border: none;
  padding: 0.75rem 1rem;
  text-align: left;
}

.wccmp-mobile-cards .wccmp-table tbody th {
  background: var(--wccmp-bg-soft);
  font-weight: 700;
  border-bottom: 1px solid var(--wccmp-border);
}

.wccmp-mobile-cards .wccmp-table tbody td {
  border-bottom: 1px solid #f3f4f6;
}

.wccmp-mobile-cards .wccmp-table tbody td:last-child {
  border-bottom: none;
}

/* Stack mobile view */
.wccmp-mobile-stack .wccmp-scroll {
  overflow: visible;
}

.wccmp-mobile-stack .wccmp-table {
  display: block;
  min-width: auto;
}

.wccmp-mobile-stack .wccmp-table thead {
  display: none;
}

.wccmp-mobile-stack .wccmp-table tbody {
  display: block;
}

.wccmp-mobile-stack .wccmp-table tbody tr {
  display: block;
  margin-bottom: 2rem;
  border: 1px solid var(--wccmp-border);
  border-radius: var(--wccmp-radius);
  background: var(--wccmp-bg);
  box-shadow: var(--wccmp-shadow);
  overflow: hidden;
}

.wccmp-mobile-stack .wccmp-table tbody tr:last-child {
  margin-bottom: 0;
}

.wccmp-mobile-stack .wccmp-table tbody th,
.wccmp-mobile-stack .wccmp-table tbody td {
  display: block;
  border: none;
  padding: 1rem;
  text-align: left;
}

.wccmp-mobile-stack .wccmp-table tbody th {
  background: var(--wccmp-bg-soft);
  font-weight: 700;
  border-bottom: 1px solid var(--wccmp-border);
  font-size: 1.125rem;
}

.wccmp-mobile-stack .wccmp-table tbody td {
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.wccmp-mobile-stack .wccmp-table tbody td:last-child {
  border-bottom: none;
}

.wccmp-mobile-stack .wccmp-table tbody td::before {
  content: attr(data-label);
  font-weight: 600;
  color: var(--wccmp-muted);
  flex: 0 0 auto;
  margin-right: 1rem;
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles */
.wccmp-sort-name:focus,
.wccmp-sort-attr:focus,
.wccmp-reset:focus,
.wccmp-mobile-toggle:focus,
.wccmp-btn:focus {
  outline: 2px solid var(--wccmp-brand);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .wccmp-wrap {
    --wccmp-border: #000000;
    --wccmp-muted: #000000;
  }
}
