/* Product Comparison Checkbox in Loops */
.product-compare-checkbox-wrap {
  position: absolute;
  top: 15px;
  right: 15px;
  z-index: 15;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease-in-out;
}

/* Parent container hover or active comparison state */
.product-item-info {
  position: relative;
}

.product-item-info:hover .product-compare-checkbox-wrap,
.product-compare-checkbox-wrap.active {
  opacity: 1;
  visibility: visible;
}

.product-compare-label {
  cursor: pointer;
  display: block;
}

.product-compare-checkbox {
  display: none !important; /* Hide native checkbox */
}

.compare-button-content {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 11px;
  font-weight: bold;
  color: #444444;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  transition: all 0.2s ease-in-out;
}

.compare-button-content svg {
  stroke: #444444;
  transition: stroke 0.2s ease;
  flex-shrink: 0;
}

.compare-text {
  line-height: 1;
}

/* Selected active state styles */
.product-compare-checkbox-wrap.active .compare-button-content {
  background: #3D7DC9;
  border-color: #3D7DC9;
  color: #ffffff;
}

.product-compare-checkbox-wrap.active .compare-button-content svg {
  stroke: #ffffff;
}

/* Hover effects */
.compare-button-content:hover {
  border-color: #3D7DC9;
  color: #3D7DC9;
}

.compare-button-content:hover svg {
  stroke: #3D7DC9;
}

.product-compare-checkbox-wrap.active .compare-button-content:hover {
  background: #2F6CB5;
  border-color: #2F6CB5;
  color: #ffffff;
}

.product-compare-checkbox-wrap.active .compare-button-content:hover svg {
  stroke: #ffffff;
}

/* Compare action for the standard product detail layout. */
.f1z-product-compare-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.f1z-product-compare-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  max-width: 100%;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid #407ec9;
  border-radius: 6px;
  background-color: #407ec9;
  color: #ffffff;
  box-sizing: border-box;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.f1z-product-compare-button:hover,
.f1z-product-compare-button:active {
  border-color: #2f6cb5;
  background-color: #2f6cb5;
  color: #ffffff;
  text-decoration: none;
}

.f1z-product-compare-button:focus {
  outline: 2px solid #1f5f9f;
  outline-offset: 2px;
  color: #ffffff;
  text-decoration: none;
}

.f1z-product-compare-actions + .joie-tabs {
  margin-top: 18px;
}

@media (max-width: 768px) {
  .f1z-product-compare-button {
    min-height: 44px;
  }
}

/* Sticky Bottom Comparison Bar */
/* Keep the drawer anchored to the viewport when page layouts constrain content width. */
html body > #compare-bar.compare-bar {
  left: 0 !important;
  right: auto !important;
  width: 100vw !important;
  max-width: none !important;
  box-sizing: border-box;
}

.compare-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
  z-index: 10000;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  transition: transform 0.3s ease-in-out, height 0.3s ease-in-out;
  overflow: hidden;
}

.compare-bar-hidden {
  transform: translateY(100%);
}

.compare-bar-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 15px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

/* Comparison slots */
.compare-slots-wrapper {
  display: flex;
  gap: 15px;
  flex-grow: 1;
}

.compare-slot {
  width: 200px;
  height: 90px;
  border-radius: 8px;
  position: relative;
  transition: all 0.2s ease-in-out;
  flex-shrink: 0;
}

/* Empty slot state */
.compare-slot.empty {
  border: 1px dashed #cccccc;
  background-color: #fafafa;
  cursor: pointer;
}

.compare-slot.empty:hover {
  border-color: #3D7DC9;
  background-color: #f0f7ff;
}

.compare-slot-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  text-align: center;
}

.compare-slot-plus {
  font-size: 22px;
  color: #888;
  font-weight: 300;
  line-height: 1;
  margin-bottom: 4px;
}

.compare-slot.empty:hover .compare-slot-plus {
  color: #3D7DC9;
}

.compare-slot-text {
  font-size: 11px;
  color: #777;
  font-weight: 500;
}

/* Filled slot state */
.compare-slot.filled {
  border: 1px solid #e5e5e5;
  background-color: #ffffff;
}

.compare-product-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
  position: relative;
}

.compare-product-img {
  height: 45px;
  max-width: 100%;
  object-fit: contain;
}

.compare-product-title {
  font-size: 11px;
  color: #333;
  line-height: 1.3;
  font-weight: 500;
  text-align: center;
  max-width: 100%;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 4px;
}

.compare-product-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #333333;
  color: #ffffff;
  font-size: 11px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  z-index: 5;
  line-height: 1;
}

.compare-product-remove:hover {
  background: #3D7DC9;
}

/* Compare action buttons */
.compare-actions-wrapper {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-shrink: 0;
}

.compare-status-text {
  font-size: 14px;
  color: #444;
  font-weight: 500;
}

.compare-buttons {
  display: flex;
  gap: 10px;
}

.btn-compare-collapse {
  background: #ffffff;
  color: #333333;
  border: 1px solid #dddddd;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-compare-collapse:hover {
  background-color: #f7f7f7;
  border-color: #cccccc;
}

.btn-compare-submit {
  background: #3D7DC9;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 10px 22px;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-compare-submit:hover {
  background: #2F6CB5;
  box-shadow: 0 2px 8px rgba(61, 125, 201, 0.3);
}

/* Collapsed Comparison Bar State */
.compare-bar.collapsed {
  height: 55px;
}

.compare-bar.collapsed .compare-slots-wrapper {
  display: none;
}

.compare-bar.collapsed .compare-bar-container {
  padding: 10px 20px;
}

/* Comparison Search Modal Overlay & Box */
.compare-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10010;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out;
}

.compare-modal-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.compare-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}

.compare-modal-container {
  position: relative;
  background: #ffffff;
  width: 600px;
  max-width: 92%;
  max-height: 80vh;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  z-index: 1101;
  overflow: hidden;
  animation: compareModalSlide 0.25s ease-out;
}

@keyframes compareModalSlide {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.compare-modal-close {
  position: absolute;
  top: 12px;
  right: 15px;
  background: none;
  border: none;
  font-size: 28px;
  font-weight: 300;
  color: #888;
  cursor: pointer;
  line-height: 1;
  z-index: 10;
  padding: 0;
}

.compare-modal-close:hover {
  color: #3D7DC9;
}

.compare-modal-header {
  padding: 20px 20px 12px;
  border-bottom: 1px solid #f0f0f0;
}

.compare-search-input-wrapper {
  position: relative;
  width: 100%;
}

.compare-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #888;
  display: flex;
  align-items: center;
}

#compare-search-input {
  width: 100%;
  height: 42px;
  padding: 10px 20px 10px 42px;
  border: 1px solid #dddddd;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

#compare-search-input:focus {
  border-color: #3D7DC9;
  box-shadow: 0 0 0 3px rgba(61, 125, 201, 0.1);
}

.compare-modal-body {
  padding: 15px 20px;
  overflow-y: auto;
  flex-grow: 1;
  min-height: 200px;
  max-height: 50vh;
}

/* Search results list */
.compare-search-placeholder {
  text-align: center;
  color: #777;
  padding: 40px 0;
  font-size: 14px;
}

.compare-search-empty {
  text-align: center;
  color: #3D7DC9;
  font-weight: bold;
  padding: 30px 0;
  font-size: 14px;
}

.compare-search-results-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.compare-search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid #f5f5f5;
  gap: 15px;
}

.compare-search-item:last-child {
  border-bottom: none;
}

.compare-search-item-img {
  width: 50px;
  height: 50px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.compare-search-item-img img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.compare-search-item-info {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.compare-search-item-title {
  font-size: 13.5px;
  color: #333333;
  font-weight: 500;
  line-height: 1.4;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compare-search-item-prices {
  display: flex;
  align-items: center;
  gap: 8px;
}

.compare-search-item-price-current {
  font-size: 13px;
  font-weight: bold;
  color: #3D7DC9;
}

.compare-search-item-price-compare {
  font-size: 11px;
  color: #999999;
  text-decoration: line-through;
}

.compare-search-item-select-btn {
  background: #eef5fc;
  color: #3D7DC9;
  border: none;
  border-radius: 6px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.compare-search-item-select-btn:hover {
  background: #3D7DC9;
  color: #ffffff;
}

/* Loading spinner in search */
.compare-search-loading {
  text-align: center;
  padding: 40px 0;
  color: #888;
}

.compare-spinner {
  display: inline-block;
  width: 25px;
  height: 25px;
  border: 3px solid rgba(61, 125, 201, 0.15);
  border-radius: 50%;
  border-top-color: #3D7DC9;
  animation: compareSpin 1s ease-in-out infinite;
}

@keyframes compareSpin {
  to { transform: rotate(360deg); }
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
  .compare-bar-container {
    flex-direction: column;
    padding: 10px 15px;
    gap: 10px;
  }
  
  .compare-slots-wrapper {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 5px;
    justify-content: flex-start;
  }
  
  .compare-slot {
    width: 140px;
    height: 80px;
  }
  
  .compare-product-img {
    height: 35px;
  }
  
  .compare-actions-wrapper {
    width: 100%;
    justify-content: space-between;
  }
  
  .compare-bar.collapsed {
    height: 50px;
  }
}

/* Floating Pill when collapsed */
.compare-collapsed-pill {
  position: fixed;
  left: 20px;
  bottom: 20px;
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 30px;
  padding: 10px 20px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  font-size: 14px;
  font-weight: bold;
  color: #333333;
  cursor: pointer;
  z-index: 10005;
  transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s ease;
  user-select: none;
}

.compare-collapsed-pill:hover {
  transform: scale(1.05);
  border-color: #3D7DC9;
}

.compare-pill-count {
  color: #3D7DC9;
  margin-left: 2px;
}

.compare-pill-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(20px);
}

@media (max-width: 768px) {
  .compare-collapsed-pill {
    padding: 8px 16px;
    font-size: 12px;
    left: 15px;
    bottom: 15px;
  }
}

/* Xem thêm Load More Button Styling */
.compare-load-more-wrapper {
  text-align: center;
  margin-top: 20px;
  margin-bottom: 10px;
}

.btn-compare-load-more {
  background: #ffffff;
  color: #3D7DC9;
  border: 1px solid #3D7DC9;
  border-radius: 24px;
  padding: 8px 32px;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease-in-out;
  display: inline-block;
  min-width: 180px;
}

.btn-compare-load-more:hover {
  background: #3D7DC9;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(61, 125, 201, 0.25);
}

.btn-compare-load-more:disabled {
  background: #f7f7f7;
  color: #999;
  border-color: #ddd;
  cursor: not-allowed;
  box-shadow: none;
}

/* Search Modal Redesign (Width expansion & layout for PAGE only) */
#page-compare-search-modal .compare-modal-container {
  max-width: 1200px;
  width: 90%;
  height: 85vh;
  background: #f7f9fa; /* Sleek light background */
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#page-compare-search-modal .compare-modal-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 24px;
  background: #ffffff;
  border-bottom: 1px solid #eaeaea;
}

#page-compare-search-modal .compare-modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: bold;
  color: #333333;
}

#page-compare-search-modal .compare-modal-close {
  position: static;
  background: #eeeeee;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 16px;
  color: #666666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  line-height: 1;
}

#page-compare-search-modal .compare-modal-close:hover {
  background: #3D7DC9;
  color: #ffffff;
}

#page-compare-search-modal .compare-modal-header {
  background: #ffffff;
  padding: 15px 24px;
  border-bottom: 1px solid #eaeaea;
}

#page-compare-search-modal .compare-search-input-wrapper {
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  padding: 0 15px;
  height: 40px;
  display: flex;
  align-items: center;
  max-width: 400px;
}

#page-compare-search-modal #page-compare-search-input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  margin-left: 10px;
  width: 100%;
}

#page-compare-search-modal .compare-modal-body {
  padding: 24px;
  overflow-y: auto;
  flex-grow: 1;
}

/* Grid layout for page search results */
.page-compare-search-results-list {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 15px;
  padding: 0;
  margin: 0;
  list-style: none;
  align-items: stretch; /* equal heights for all cards */
}

.page-compare-search-item {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
  transition: all 0.2s ease-in-out;
  position: relative;
  height: 100%;
  text-align: center;
}

.page-compare-search-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border-color: #3D7DC9;
}

/* Star/Sparkles icon on top-left of cards replaced by a clean blue '+' symbol */
.page-compare-search-item::before {
  content: '+';
  position: absolute;
  top: 10px;
  left: 12px;
  font-size: 16px;
  font-weight: bold;
  color: #2f80ed;
  line-height: 1;
}

.page-compare-search-item-img {
  width: 100%;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.page-compare-search-item-img img {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
}

.page-compare-search-item-info {
  width: 100%;
  text-align: center;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.page-compare-search-item-title {
  font-size: 13px;
  font-weight: bold;
  color: #333333;
  line-height: 1.4;
  height: 38px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-bottom: 8px;
  text-align: center;
}

.page-compare-search-item-prices {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-bottom: 12px;
  width: 100%;
}

.page-compare-search-item-price-compare {
  font-size: 11px;
  color: #888888;
  text-decoration: line-through;
}

.page-compare-search-item-price-current {
  font-size: 13px;
  font-weight: bold;
  color: #3D7DC9;
}

/* Button stylings */
.page-btn-select-compare-product {
  width: 100%;
  background: #3D7DC9;
  color: #ffffff;
  border: none;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  outline: none;
  transition: background 0.2s;
  text-align: center;
  box-sizing: border-box;
}

.page-btn-select-compare-product:hover {
  background: #2F6CB5;
}

.page-btn-select-compare-product.btn-selected {
  background: #e5e5e5 !important;
  color: #888888 !important;
  cursor: not-allowed;
}

/* Responsive grid for search list */
@media (max-width: 1024px) {
  .page-compare-search-results-list {
    grid-template-columns: repeat(4, 1fr);
  }
}
@media (max-width: 768px) {
  .page-compare-search-results-list {
    grid-template-columns: repeat(2, 1fr);
  }
  #page-compare-search-modal .compare-modal-container {
    width: 95%;
    height: 90vh;
  }
}

html body > #compare-bar.compare-bar {
    z-index: 999;
}
