/* ============================================================
   Product Compare Page Styles - Keenyoda
   ============================================================ */

/* ---------- Page Container ---------- */
.ky-compare-section {
  background: #fff;
  padding: 0 0 60px 0;
  min-height: calc(100vh - 180px);
  box-sizing: border-box;
  font-family: "HarmonyOS Sans SC Light", "Microsoft YaHei", sans-serif;
  font-weight: normal;
}

.ky-compare-inner {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 32px;
  box-sizing: border-box;
}

/* ---------- Breadcrumb ---------- */
.ky-compare-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 24px 0 20px 0;
  font-size: 14px;
  color: #666;
  border-bottom: 1px solid #f0f0f0;
  margin-bottom: 24px;
}

.ky-compare-breadcrumb a {
  color: #00A1E9;
  text-decoration: none;
}

.ky-compare-breadcrumb a:hover {
  color: #0090d0;
  text-decoration: underline;
}

.ky-compare-breadcrumb .ky-sep {
  color: #ccc;
}

.ky-compare-breadcrumb .ky-current {
  color: #333;
}

/* ---------- Page Title ---------- */
.ky-compare-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.ky-compare-title h1 {
  font-size: 26px;
  font-family: "HarmonyOS Sans SC Regular", "Microsoft YaHei", sans-serif;
  font-weight: normal;
  color: #132A3E;
  margin: 0;
}

.ky-compare-title-actions {
  display: flex;
  gap: 12px;
}

/* ---------- Buttons ---------- */
.ky-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 20px;
  font-size: 14px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  font-family: inherit;
  line-height: 1.5;
}

.ky-btn--primary {
  background: #00A1E9;
  color: #fff;
  border-color: #00A1E9;
}

.ky-btn--primary:hover {
  background: #0090d0;
  border-color: #0090d0;
}

.ky-btn--outline {
  background: #fff;
  color: #00A1E9;
  border-color: #00A1E9;
}

.ky-btn--outline:hover {
  background: rgba(0, 161, 233, 0.12);
}

.ky-btn--ghost {
  background: #fff;
  color: #666;
  border-color: #ddd;
}

.ky-btn--ghost:hover {
  color: #e74c3c;
  border-color: #e74c3c;
}

.ky-btn--sm {
  padding: 4px 12px;
  font-size: 12px;
}

/* ---------- Product Cards Header ---------- */
.ky-compare-header {
  display: flex;
  gap: 0;
  margin-bottom: 0;
  overflow-x: auto;
  border: 1px solid #e8eaed;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: #fafbfc;
}

.ky-compare-header-cell {
  flex: 1;
  min-width: 180px;
  max-width: 280px;
  border-right: 1px solid #e8eaed;
  position: relative;
}

.ky-compare-header-cell:last-child {
  border-right: none;
}

.ky-compare-header-cell--label {
  flex: 0 0 180px;
  min-width: 180px;
  max-width: 180px;
  background: #f5f6f8;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
}

.ky-compare-header-cell--label .ky-label-text {
  font-size: 14px;
  color: #999;
  font-weight: normal;
}

.ky-compare-header-cell--label .ky-label-count {
  font-size: 13px;
  color: #bbb;
}

.ky-compare-header-cell--add {
  flex: 1;
  min-width: 180px;
  max-width: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Product Card in Header ---------- */
.ky-compare-product-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px;
  gap: 10px;
  position: relative;
}

.ky-compare-product-card .ky-card-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.1);
  color: #666;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  transition: all 0.2s ease;
  z-index: 1;
}

.ky-compare-product-card .ky-card-remove:hover {
  background: #e74c3c;
  color: #fff;
}

.ky-compare-product-card .ky-card-image {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ky-compare-product-card .ky-card-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.ky-compare-product-card .ky-card-name {
  font-size: 15px;
  font-weight: 600;
  color: #132A3E;
  text-align: center;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.ky-compare-product-card .ky-card-name a {
  color: #132A3E;
  text-decoration: none;
}

.ky-compare-product-card .ky-card-name a:hover {
  color: #00A1E9;
}

.ky-compare-product-card .ky-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
}

.ky-compare-product-card .ky-card-meta span {
  display: inline-block;
  font-size: 11px;
  color: #666;
  background: #f0f2f5;
  border-radius: 10px;
  padding: 2px 8px;
  line-height: 1.4;
}

/* ---------- Add Product Button ---------- */
.ky-add-product-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 100%;
  min-height: 160px;
  background: #fafbfc;
  border: 2px dashed #d0d5dd;
  border-radius: 6px;
  cursor: pointer;
  color: #00A1E9;
  font-size: 14px;
  transition: all 0.2s ease;
  padding: 16px;
  position: relative;
}

.ky-add-product-btn:hover {
  background: rgba(0, 161, 233, 0.12);
  border-color: #00A1E9;
}

.ky-add-product-btn .ky-add-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 161, 233, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #00A1E9;
  transition: all 0.2s ease;
}

.ky-add-product-btn:hover .ky-add-icon {
  background: #00A1E9;
  color: #fff;
}

/* ---------- Spec Comparison Table ---------- */
.ky-compare-table-wrap {
  border: 1px solid #e8eaed;
  border-top: none;
  border-radius: 0 0 8px 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.ky-compare-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 600px;
}

/* First column (parameter label) - sticky */
.ky-compare-table th:first-child,
.ky-compare-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 180px;
  min-width: 180px;
}

.ky-compare-table thead th:first-child {
  background: #f5f6f8;
}

.ky-compare-table td:first-child {
  background: #fafbfc;
}

/* Column widths */
.ky-compare-table th:not(:first-child),
.ky-compare-table td:not(:first-child) {
  width: calc((100% - 180px) / 5);
  min-width: 140px;
}

/* ---------- Group Header Row ---------- */
.ky-compare-group-header td {
  background: #00A1E9 !important;
  color: #fff !important;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 16px !important;
  border-bottom: 2px solid #0090d0 !important;
}

/* ---------- Table Header (product names) ---------- */
.ky-compare-table thead th {
  background: #f5f6f8;
  padding: 14px 12px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #333;
  border-bottom: 2px solid #e0e4e8;
  border-right: 1px solid #e8eaed;
  vertical-align: middle;
}

.ky-compare-table thead th:last-child {
  border-right: none;
}

.ky-compare-table thead th .ky-th-name {
  display: block;
  font-size: 13px;
  line-height: 1.4;
}

.ky-compare-table thead th .ky-th-image {
  display: block;
  width: 48px;
  height: 48px;
  margin: 0 auto 6px;
}

.ky-compare-table thead th .ky-th-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* ---------- Data Rows ---------- */
.ky-compare-table tbody td {
  padding: 10px 12px;
  text-align: center;
  font-size: 14px;
  color: #333;
  border-bottom: 1px solid #f0f0f0;
  border-right: 1px solid #f0f0f0;
  vertical-align: middle;
  word-break: break-word;
}

.ky-compare-table tbody td:last-child {
  border-right: none;
}

.ky-compare-table tbody td:first-child {
  text-align: left;
  font-weight: 500;
  color: #555;
}

/* ---------- Striped Rows ---------- */
.ky-compare-table tbody tr:nth-child(even):not(.ky-compare-group-header) td {
  background: #fcfcfd;
}

.ky-compare-table tbody tr:nth-child(even):not(.ky-compare-group-header) td:first-child {
  background: #f6f7f9;
}

/* ---------- Diff Highlighting ---------- */
.ky-compare-table td.ky-diff {
  background: #fff8e1 !important;
  color: #333;
  font-weight: 600;
}

.ky-compare-table td.ky-diff::after {
  display: none;
}

/* Emphasize the first column diff differently */
.ky-compare-table td:first-child.ky-diff {
  background: #fafbfc !important;
  font-weight: 500;
}

/* ---------- Empty Value ---------- */
.ky-compare-table td.ky-empty {
  color: #ccc;
  font-style: italic;
}

/* ---------- Modal ---------- */
.ky-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

.ky-modal-overlay.ky-modal--open {
  display: flex;
}

.ky-modal {
  background: #fff;
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.ky-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #e8eaed;
}

.ky-modal-header h3 {
  margin: 0;
  font-size: 18px;
  color: #132A3E;
  font-family: "HarmonyOS Sans SC Regular", "Microsoft YaHei", sans-serif;
  font-weight: normal;
}

.ky-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f0f2f5;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #666;
  transition: all 0.2s ease;
}

.ky-modal-close:hover {
  background: #e74c3c;
  color: #fff;
}

.ky-modal-body {
  padding: 20px 24px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ky-modal-search {
  position: relative;
}

.ky-modal-search input {
  width: 100%;
  height: 44px;
  padding: 0 44px 0 16px;
  border: 1px solid #d0d5dd;
  border-radius: 4px;
  font-size: 14px;
  color: #333;
  box-sizing: border-box;
  transition: border-color 0.2s ease;
  font-family: inherit;
}

.ky-modal-search input:focus {
  outline: none;
  border-color: #00A1E9;
  box-shadow: 0 0 0 3px rgba(0, 91, 172, 0.1);
}

.ky-modal-search input::placeholder {
  color: #bbb;
}

.ky-modal-search .ky-search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #999;
  font-size: 16px;
  pointer-events: none;
}

.ky-modal-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 100px;
}

.ky-modal-result-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid #e8eaed;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ky-modal-result-item:hover {
  background: #f0f7ff;
  border-color: #00A1E9;
}

.ky-modal-result-item.ky-modal-result-item--disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #f5f5f5;
}

.ky-modal-result-item.ky-modal-result-item--disabled:hover {
  border-color: #e8eaed;
  background: #f5f5f5;
}

.ky-modal-result-item .ky-result-img {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f6f8;
  border-radius: 4px;
  overflow: hidden;
}

.ky-modal-result-item .ky-result-img img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.ky-modal-result-item .ky-result-info {
  flex: 1;
  min-width: 0;
}

.ky-modal-result-item .ky-result-name {
  font-size: 14px;
  font-weight: 600;
  color: #132A3E;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ky-modal-result-item .ky-result-meta {
  font-size: 12px;
  color: #999;
  margin-top: 2px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ky-modal-result-item .ky-result-added {
  font-size: 12px;
  color: #00A1E9;
  font-weight: 600;
  white-space: nowrap;
}

.ky-modal-empty {
  text-align: center;
  padding: 32px 0;
  color: #999;
  font-size: 14px;
}

.ky-modal-loading {
  text-align: center;
  padding: 32px 0;
  color: #999;
  font-size: 14px;
}

/* ---------- Clear All Section ---------- */
.ky-compare-clear-wrap {
  display: flex;
  align-items: center;
  margin-top: 24px;
}

.ky-compare-clear-wrap .ky-btn--ghost {
  margin-left: auto;
}

/* ---------- Loading State ---------- */
.ky-compare-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 0;
  flex-direction: column;
  gap: 12px;
  color: #999;
}

.ky-compare-loading .ky-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e8eaed;
  border-top-color: #00A1E9;
  border-radius: 50%;
  animation: ky-spin 0.8s linear infinite;
}

@keyframes ky-spin {
  to { transform: rotate(360deg); }
}

/* ---------- Empty State ---------- */
.ky-compare-empty {
  text-align: center;
  padding: 60px 0;
  color: #999;
  font-size: 16px;
}

.ky-compare-empty p {
  margin: 0 0 16px 0;
}

/* ---------- Error State ---------- */
.ky-compare-error {
  text-align: center;
  padding: 60px 0;
  color: #e74c3c;
  font-size: 16px;
}

/* ---------- Responsive: Mobile ---------- */
@media screen and (max-width: 768px) {
  .ky-compare-inner {
    padding: 0 16px;
  }

  .ky-compare-header {
    display: none;
  }

  .ky-compare-table-wrap {
    border: none;
    overflow-x: visible;
  }

  .ky-compare-table {
    display: none;
  }

  /* Mobile: stacked cards */
  .ky-compare-mobile-cards {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }

  .ky-compare-mobile-card {
    border: 1px solid #e8eaed;
    border-radius: 8px;
    overflow: hidden;
  }

  .ky-compare-mobile-card__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: #fafbfc;
    border-bottom: 1px solid #e8eaed;
    position: relative;
  }

  .ky-compare-mobile-card__img {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
  }

  .ky-compare-mobile-card__img img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
  }

  .ky-compare-mobile-card__name {
    font-size: 15px;
    font-weight: 600;
    color: #132A3E;
    flex: 1;
  }

  .ky-compare-mobile-card__remove {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.08);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #666;
    flex-shrink: 0;
  }

  .ky-compare-mobile-card__group-title {
    padding: 10px 16px;
    background: #00A1E9;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
  }

  .ky-compare-mobile-card__specs {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .ky-compare-mobile-card__spec-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
  }

  .ky-compare-mobile-card__spec-label {
    color: #999;
    flex-shrink: 0;
  }

  .ky-compare-mobile-card__spec-value {
    color: #333;
    text-align: right;
  }

  .ky-compare-mobile-card__spec-value.ky-diff {
    color: #e67e22;
    font-weight: 600;
  }

  .ky-compare-mobile-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    justify-content: center;
  }
}

@media screen and (min-width: 769px) {
  .ky-compare-mobile-cards {
    display: none;
  }

  .ky-compare-mobile-actions {
    display: none;
  }
}

/* ---------- Print Styles ---------- */
@media print {
  .ky-compare-header-cell--add,
  .ky-card-remove,
  .ky-btn,
  .ky-modal-overlay,
  .ky-compare-breadcrumb {
    display: none !important;
  }

  .ky-compare-table td.ky-diff {
    background: #fff8e1 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
