/* ─── Compare Overlay ─── */
/* Pure Vue-managed overlay — uses Bootstrap variables for consistency */

.compare-overlay {
  position: fixed;
  inset: 0;
  z-index: 1055; /* Bootstrap modal z-index range */
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: compare-fade-in 0.2s ease-out;
}

@keyframes compare-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes compare-slide-up {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ─── Panel ─── */

.compare-panel {
  background: var(--bs-body-bg, #fff);
  border-radius: var(--bs-border-radius-lg, 0.5rem);
  box-shadow: var(--bs-box-shadow-lg, 0 1rem 3rem rgba(0, 0, 0, 0.175));
  display: flex;
  flex-direction: column;
  width: 90vw;
  max-width: 1400px;
  height: 80vh;
  max-height: 900px;
  animation: compare-slide-up 0.25s ease-out;
  overflow: hidden;
}

.compare-panel--fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  border-radius: 0;
}

/* ─── Header ─── */

.compare-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--bs-border-color, #dee2e6);
  background: var(--bs-light, #f8f9fa);
  flex-shrink: 0;
}

.compare-header__left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.compare-header__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--bs-body-color, #212529);
  display: flex;
  align-items: center;
  gap: 8px;
}

.compare-header__icon {
  font-size: 20px;
  color: var(--bs-primary, #0d6efd);
}

.compare-header__badge {
  background: var(--bs-primary, #0d6efd);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--bs-border-radius-pill, 50rem);
}

.compare-header__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Search ─── */

.compare-search__input {
  padding: 5px 10px;
  border: 1px solid var(--bs-border-color, #dee2e6);
  border-radius: var(--bs-border-radius, 0.375rem);
  font-size: 13px;
  width: 200px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
  outline: none;
  color: var(--bs-body-color, #212529);
  background: var(--bs-body-bg, #fff);
}

.compare-search__input:focus {
  border-color: var(--bs-primary, #0d6efd);
  box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb, 13, 110, 253), 0.15);
}

/* ─── Buttons ─── */

.compare-btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.compare-btn--icon {
  background: transparent;
  color: var(--bs-secondary-color, #6c757d);
  font-size: 18px;
  padding: 6px 8px;
  border-radius: var(--bs-border-radius, 0.375rem);
}

.compare-btn--icon:hover {
  background: var(--bs-tertiary-bg, #f8f9fa);
  color: var(--bs-body-color, #212529);
}

.compare-btn--close {
  background: transparent;
  color: var(--bs-secondary-color, #6c757d);
  font-size: 16px;
  padding: 6px 10px;
  border-radius: var(--bs-border-radius, 0.375rem);
  font-weight: 600;
}

.compare-btn--close:hover {
  background: rgba(var(--bs-danger-rgb, 220, 53, 69), 0.1);
  color: var(--bs-danger, #dc3545);
}

.compare-btn--secondary {
  background: var(--bs-secondary-bg, #e9ecef);
  color: var(--bs-body-color, #212529);
  padding: 6px 14px;
  border-radius: var(--bs-border-radius, 0.375rem);
  font-size: 13px;
  font-weight: 500;
}

.compare-btn--secondary:hover {
  background: var(--bs-border-color, #dee2e6);
}

.compare-btn--retry {
  background: var(--bs-primary, #0d6efd);
  color: #fff;
  padding: 6px 14px;
  border-radius: var(--bs-border-radius, 0.375rem);
  font-size: 13px;
  font-weight: 500;
}

.compare-btn--retry:hover {
  background: var(--bs-primary-darken, #0b5ed7);
}

/* ─── Body (scrollable table area) ─── */

.compare-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.compare-table-wrapper {
  flex: 1;
  overflow: auto;
}

/* ─── Table ─── */

.compare-table {
  width: max-content;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.compare-table__head {
  position: sticky;
  top: 0;
  z-index: 10;
}

.compare-table__head th {
  background: var(--bs-light, #f8f9fa);
  border-bottom: 2px solid var(--bs-border-color, #dee2e6);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--bs-body-color, #212529);
  white-space: nowrap;
}

.compare-table__corner {
  position: sticky;
  left: 0;
  z-index: 11;
  background: var(--bs-light, #f8f9fa) !important;
  min-width: 200px;
  max-width: 280px;
  width: 280px;
}

.compare-table__material-header {
  min-width: 180px;
  max-width: 300px;
}

/* ─── Material header cell ─── */

.compare-material {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
  padding-right: 20px;
}

.compare-material__name {
  font-weight: 600;
  color: var(--bs-body-color, #212529);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compare-material__db {
  font-size: 11px;
  color: var(--bs-secondary-color, #6c757d);
  font-weight: 400;
}

.compare-material__remove {
  position: absolute;
  right: 0;
  top: 0;
  background: none;
  border: none;
  color: var(--bs-border-color, #dee2e6);
  cursor: pointer;
  font-size: 12px;
  padding: 2px;
  border-radius: var(--bs-border-radius-sm, 0.25rem);
  line-height: 1;
  transition: all 0.15s;
}

.compare-material__remove:hover {
  color: var(--bs-danger, #dc3545);
  background: rgba(var(--bs-danger-rgb, 220, 53, 69), 0.1);
}

/* ─── Section (collection) header ─── */

.compare-table__section-row {
  cursor: pointer;
  user-select: none;
}

.compare-table__section-row:hover .compare-table__section-cell {
  background: rgba(var(--bs-primary-rgb, 13, 110, 253), 0.06);
}

.compare-table__section-cell {
  background: var(--bs-secondary-bg, #e9ecef);
  padding: 8px 14px;
  font-weight: 600;
  color: var(--bs-body-color, #212529);
  font-size: 13px;
  border-top: 1px solid var(--bs-border-color, #dee2e6);
  border-bottom: 1px solid var(--bs-border-color, #dee2e6);
  transition: background 0.15s;
}

.compare-table__section-cell--sticky {
  position: sticky;
  left: 0;
  z-index: 6;
  white-space: nowrap;
  border-right: 1px solid var(--bs-border-color, #dee2e6);
  background: var(--bs-secondary-bg, #e9ecef);
  max-width: 280px;
  width: 280px;
  overflow: hidden;
}

.compare-table__section-filler {
  background: var(--bs-secondary-bg, #e9ecef);
  border-top: 1px solid var(--bs-border-color, #dee2e6);
  border-bottom: 1px solid var(--bs-border-color, #dee2e6);
  padding: 0;
  transition: background 0.15s;
}

.compare-table__section-row:hover .compare-table__section-filler {
  background: rgba(var(--bs-primary-rgb, 13, 110, 253), 0.06);
}

.compare-table__section-chevron {
  display: inline-block;
  transition: transform 0.2s;
  font-size: 14px;
  color: var(--bs-secondary-color, #6c757d);
}

.compare-table__section-chevron--collapsed {
  transform: rotate(-90deg);
}

.compare-table__section-name {
  flex: 1;
}

/* ─── Data rows ─── */

.compare-table__row {
  transition: background 0.1s;
}

.compare-table__row:hover {
  background: var(--bs-light, #f8f9fa);
}

.compare-table__prop-name {
  padding: 6px 14px;
  font-weight: 500;
  color: var(--bs-body-color, #212529);
  border-bottom: 1px solid
    var(--bs-border-color-translucent, rgba(0, 0, 0, 0.075));
  position: sticky;
  left: 0;
  background: var(--bs-light, #f8f9fa);
  z-index: 5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
  width: 280px;
}

.compare-table__row:hover .compare-table__prop-name {
  background: var(--bs-secondary-bg, #e9ecef);
}

.compare-params {
  white-space: normal;
  display: flex;
  flex-wrap: wrap;
}

.compare-param-badge--selected {
  outline: 2px solid var(--bs-dark);
  outline-offset: 1px;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
  transform: scale(1.05);
  transition: all 0.15s ease;
  z-index: 2;
}

.compare-table__cell {
  padding: 6px 14px;
  color: var(--bs-body-color, #212529);
  border-bottom: 1px solid
    var(--bs-border-color-translucent, rgba(0, 0, 0, 0.075));
  border-left: 1px solid var(--bs-border-color-translucent, rgba(0, 0, 0, 0.04));
  word-break: break-word;
  max-width: 300px;
}

.compare-panel--fullscreen .compare-table__cell,
.compare-panel--fullscreen .compare-table__material-header {
  max-width: 600px;
}
.compare-panel--fullscreen .compare-table__corner {
  max-width: 400px;
}

/* ─── Highlights ─── */
.compare-row--identical td.compare-table__cell:not(.bg-light),
.compare-row--identical td.compare-table__prop-name {
  background-color: rgba(25, 135, 84, 0.1) !important;
}
.compare-row--identical td.compare-table__cell.bg-light {
  background-color: rgba(25, 135, 84, 0.15) !important;
}

.compare-row--similar td.compare-table__cell:not(.bg-light),
.compare-row--similar td.compare-table__prop-name {
  background-color: rgba(255, 193, 7, 0.1) !important;
}
.compare-row--similar td.compare-table__cell.bg-light {
  background-color: rgba(255, 193, 7, 0.15) !important;
}

.compare-row--different td.compare-table__cell:not(.bg-light),
.compare-row--different td.compare-table__prop-name {
  background-color: rgba(220, 53, 69, 0.08) !important;
}
.compare-row--different td.compare-table__cell.bg-light {
  background-color: rgba(220, 53, 69, 0.12) !important;
}

/* ─── Skeleton loading ─── */

.compare-skeleton {
  height: 14px;
  background: linear-gradient(
    90deg,
    var(--bs-secondary-bg, #e9ecef) 25%,
    var(--bs-border-color, #dee2e6) 50%,
    var(--bs-secondary-bg, #e9ecef) 75%
  );
  background-size: 200% 100%;
  animation: compare-shimmer 1.5s infinite;
  border-radius: var(--bs-border-radius-sm, 0.25rem);
  width: 80%;
}

@keyframes compare-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ─── Spinners ─── */

.compare-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 16px;
  color: var(--bs-secondary-color, #6c757d);
}

.compare-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--bs-border-color, #dee2e6);
  border-top-color: var(--bs-primary, #0d6efd);
  border-radius: 50%;
  animation: compare-spin 0.7s linear infinite;
}

.compare-mini-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--bs-border-color, #dee2e6);
  border-top-color: var(--bs-primary, #0d6efd);
  border-radius: 50%;
  animation: compare-spin 0.7s linear infinite;
  vertical-align: middle;
}

@keyframes compare-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ─── Error ─── */

.compare-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 12px;
  color: var(--bs-danger, #dc3545);
}

.compare-error__icon {
  font-size: 32px;
}

.compare-error__text {
  font-size: 14px;
  color: var(--bs-secondary-color, #6c757d);
}

/* ─── Extensions ─── */

.compare-table__extension-row td {
  padding: 0;
}

.compare-table__extension-cell {
  padding: 0 !important;
}

.compare-table__extension-cell .rawdiagram .fullscreen-btn {
  display: none !important;
}

.compare-extensions {
  border-top: 1px solid var(--bs-border-color, #dee2e6);
}

.compare-extensions__tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--bs-border-color, #dee2e6);
  background: var(--bs-light, #f8f9fa);
}

.compare-extensions__tab {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--bs-secondary-color, #6c757d);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}

.compare-extensions__tab--active {
  color: var(--bs-primary, #0d6efd);
  border-bottom-color: var(--bs-primary, #0d6efd);
}

.compare-extensions__raw {
  font-size: 11px;
  color: var(--bs-secondary-color, #6c757d);
  background: var(--bs-light, #f8f9fa);
  padding: 12px;
  border-radius: var(--bs-border-radius, 0.375rem);
  max-height: 300px;
  overflow: auto;
  margin: 0;
}

.compare-extension-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  color: var(--bs-secondary-color, #6c757d);
  font-size: 12px;
}

/* ─── Footer ─── */

.compare-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-top: 1px solid var(--bs-border-color, #dee2e6);
  background: var(--bs-light, #f8f9fa);
  flex-shrink: 0;
}

.compare-footer__status {
  font-size: 12px;
  color: var(--bs-secondary-color, #6c757d);
}

.compare-footer__actions {
  display: flex;
  gap: 8px;
}

@keyframes blurFadeIn {
  0% {
    filter: blur(5px);
    opacity: 0;
    transform: scale(0.98);
  }
  100% {
    filter: blur(0);
    opacity: 1;
    transform: scale(1);
  }
}

.compare-cell-blur-anim {
  animation: blurFadeIn 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* ─── Print ─── */

@media print {
  body.compare-printing * {
    visibility: hidden;
  }
  body.compare-printing .compare-overlay,
  body.compare-printing .compare-overlay * {
    visibility: visible;
  }
  body.compare-printing .compare-overlay {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: auto !important;
    overflow: visible !important;
    background: transparent;
    padding: 0;
    align-items: flex-start !important;
    justify-content: flex-start !important;
  }
  body.compare-printing .compare-panel {
    position: relative;
    box-shadow: none;
    border: none;
    height: auto !important;
    overflow: visible !important;
    width: 100%;
    max-width: 100%;
    margin: 0;
  }
  body.compare-printing .compare-body {
    overflow: visible !important;
    height: auto !important;
    display: block !important;
  }
  body.compare-printing .compare-table-wrapper {
    overflow: visible !important;
    height: auto !important;
  }
  body.compare-printing .compare-table__head {
    position: table-header-group !important;
  }
  body.compare-printing .compare-table__corner,
  body.compare-printing .compare-table__prop-name,
  body.compare-printing .compare-table__section-cell--sticky {
    position: static !important;
    max-width: none !important;
    white-space: normal !important;
  }
  body.compare-printing .compare-header__right,
  body.compare-printing .compare-footer {
    display: none !important;
  }
  body.compare-printing .compare-table {
    page-break-inside: auto;
  }
  body.compare-printing tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }
  body.compare-printing .compare-table__section-cell,
  body.compare-printing .compare-table__section-filler,
  body.compare-printing th {
    background: transparent !important;
    border-bottom: 2px solid #ccc !important;
    position: static !important;
  }
  body.compare-printing .bg-light {
    background: transparent !important;
  }
}
