/* =========================================================
   Qubic System — Compare v2
   - Custom dropdown (consistent cross-browser)
   - Card-based desktop header with animations
   - Modal-only tooltips (click "i")
   ========================================================= */

/* ---------------- Base layout ---------------- */

.qs-compare-root {
  display: block !important;
  /* Prevent footnote flash: reserve space until JS renders the table */
  min-height: 80vh;
}

/* Remove min-height once JS has populated the table */
.qs-compare-root:has(table) {
  min-height: 0;
}

.qs-compare-footnote {
  margin: 16px 0 0 24px !important;
  font-size: 13px;
  color: #666;
}

.qs-compare-table table {
  display: table;
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

.qs-compare-table th,
.qs-compare-table td {
  border: 1px solid #e0e0e0;
  padding: 10px;
  vertical-align: top;
}

/* ---------------- Table look & feel ---------------- */

.qs-compare-table {
  overflow-x: visible;
  width: 100%;
  contain: layout style;
}

.qs-compare-table .label {
  width: auto;
  vertical-align: middle;
  text-align: left;
}

.qs-section-row {
  font-size: var(--h3_typography-font-size);
  font-family: var(--h3_typography-font-family);
  font-weight: var(--h3_typography-font-weight);
  line-height: var(--h3_typography-line-height);
  letter-spacing: var(--h3_typography-letter-spacing);
  background-color: #ebeaea;
  color: black;
  text-transform: uppercase;
}

.qs-section-row td {
  border: 0;
}

.qs-section-row td.qs-add-col-spacer {
  background: #fff !important;
}

/* ---------------- Switch (Show differences — mobile only) ---------------- */

.qs-compare-table .qs-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border: none;
  background: transparent;
  font-size: var(--h3_typography-font-size);
  font-family: var(--h3_typography-font-family);
  font-weight: var(--h3_typography-font-weight);
  line-height: var(--h3_typography-line-height);
  letter-spacing: var(--h3_typography-letter-spacing);
  padding: 4px 0;
  width: 100%;
}

/* Switch — shared base (desktop + mobile) */
.qs-switch .sw {
  position: relative;
  width: 42px;
  height: 22px;
  border-radius: 22px;
  background: #ebeaea;
  transition: background 0.18s ease;
}

.qs-switch .thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  transition: transform 0.18s ease;
}

.qs-switch[aria-checked="true"] .sw {
  background: #C20019;
}

.qs-switch[aria-checked="true"] .thumb {
  transform: translateX(20px);
}

/* ---------------- Combobox (native — mobile only) ---------------- */

.qs-compare-table .qs-combobox {
  width: 100%;
  max-width: 260px;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #f7f7f8;
}

/* ---------------- Product visuals ---------------- */

.qs-compare-table .prod-visual {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.qs-compare-table .prod-visual img {
  max-height: 200px;
  height: auto;
  width: auto;
  display: block;
  transition: transform 0.3s ease;
}

.qs-compare-table .prod-visual img:hover {
  transform: scale(1.03);
}

.qs-compare-table .prod-name {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
}

.qs-compare-table .prod-title {
  font-size: var(--h3_typography-font-size);
  line-height: 1;
  color: white;
  text-decoration: none;
}

.qs-compare-table a.prod-title:hover {
  color: #ccc;
}


/* ---------------- Differences highlight ---------------- */

.qs-compare-table td.diff {
  background: #eef5ff;
}

.qs-compare-table th.label.diff {
  background: #e8f0ff;
}

/* ---------------- Empty state (no products selected) ---------------- */

.qs-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  gap: 16px;
}

.qs-empty-text {
  color: #999;
  font-size: 15px;
  margin: 0;
}

/* ---------------- Add-product column spacer (desktop) ---------------- */

@media (min-width: 769px) {
  .qs-compare-table td.qs-add-col-spacer,
  .qs-compare-table th.qs-add-col-spacer {
    background: #fff !important;
    border: none !important;
  }
}

/* ---------------- Best value highlight ---------------- */

.qs-compare-table td.best-value {
  font-weight: 700;
  color: #000000;
}

/* ---------------- Mobile layout (UNCHANGED) ---------------- */

@media (max-width: 768px) {

  .qs-compare-table thead tr:nth-child(2) th {
    text-align: center;
    font-weight: 700;
    background: transparent !important;
    border: 0;
  }

  .qs-compare-table thead tr:nth-child(3) th {
    text-align: center;
    font-weight: 700;
    background: #C20019;
    color: white;
    border-radius: 6px 6px 0 0;
  }

  .qs-compare-table thead tr:first-child {
    display: none;
  }

  .qs-compare-table tbody tr.m-param-head th {
    background: #f5f5f5;
    text-align: left;
    font-weight: 700;
    padding: 10px;
    border: 1px solid #e0e0e0;
  }

  .qs-compare-table tbody tr.m-param-head .m-param-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
  }

  .qs-compare-table tbody tr.m-param-values td {
    padding: 10px;
    border: 1px solid #e0e0e0;
  }

  .qs-compare-table table.qs-diff-active tr[data-diff].m-param-values td {
    background: #eef5ff;
  }

  .qs-compare-table thead tr:nth-child(2) th.label,
  .qs-compare-table thead tr:nth-child(3) th.label,
  .qs-compare-table tbody tr.m-param-values th.label {
    display: none !important;
  }

  .qs-compare-table tbody tr.m-param-head th,
  .qs-compare-table tbody tr.m-param-values td,
  .qs-compare-table thead tr:nth-child(2) th,
  .qs-compare-table thead tr:nth-child(3) th {
    text-align: center;
  }

  .qs-mobile-bar {
    width: 100%;
    margin: 0 0 12px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }

  .qs-mobile-bar .qs-mobile-diff {
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .qs-mobile-bar .qs-mobile-selects {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .qs-mobile-bar .qs-combobox {
    width: 100%;
    max-width: none;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #ebeaea;
    font-size: 14px;
    cursor: pointer;
  }

  .qs-mobile-bar .qs-switch {
    padding: 4px 6px;
    width: auto;
  }


  .qs-tip-modal {
    width: 94vw;
    max-width: 94vw;
    padding: 40px;
    border-radius: 12px;
  }

  .qs-tip-content {
    font-size: 15px;
    line-height: 1.6;
  }

  .qs-tip-close {
    top: 6px;
    right: 6px;
  }

  .qs-compare-table tbody tr.m-param-head th.label {
    text-align: left;
    padding-left: 12px;
    padding-right: 12px;
    background: #f5f5f5;
    border-left: 1px solid #e0e0e0;
    border-right: 1px solid #e0e0e0;
  }

  .qs-compare-table tbody tr.m-param-values td {
    width: 50%;
    text-align: center;
  }

  .qs-compare-table table {
    table-layout: auto;
  }

}

@media (max-width: 380px) {
  .qs-mobile-bar .qs-mobile-selects {
    grid-template-columns: 1fr;
  }
}

/* ---------------- Tooltip trigger (modal-only) ---------------- */

.qs-compare-table .qs-tip-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: 0;
  background: #bfbfbf;
  color: white;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  vertical-align: middle;
  margin-left: 10px;
  font-weight: bold;
}

.qs-compare-table .qs-tip-trigger:focus {
  outline: 2px solid #0b5ed7;
  outline-offset: 2px;
}

/* ---------------- Tooltip modal ---------------- */

.qs-tip-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17,24,39,0.55);
  display: none;
  z-index: 9999;
}

.qs-tip-overlay[aria-hidden="false"] {
  display: block;
}

.qs-tip-modal {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: 720px;
  width: min(92vw, 720px);
  background: #000;
  color: #fff;
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.35);
  padding: 40px;
}

.qs-tip-content {
  font-size: var(--h4_typography-font-size);
  line-height: var(--h3_typography-line-height);
  word-break: break-word;
}

.qs-tip-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.qs-tip-close:hover {
  background: rgba(255,255,255,0.14);
}

/* =========================================================
   Product Spec Table — [qs_product_spec]
   ========================================================= */

.qs-compare-spec-heading {
  text-align: center;
  margin-bottom: 40px;
}

.qs-compare-spec-heading h2 {
  font-size: 60px;
  font-family: var(--h2_typography-font-family);
  font-weight: var(--h2_typography-font-weight);
  line-height: var(--h2_typography-line-height);
  letter-spacing: var(--h2_typography-letter-spacing);
  text-transform: var(--h2_typography-text-transform);
  font-style: var(--h2_typography-font-style, normal);
  margin: 0;
}

.qs-compare-spec {
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  width: 60%;
  margin: 0 auto;
  padding: 20px;
}

.qs-compare-spec table {
  width: 100%;
  border-collapse: collapse;
}

.qs-compare-spec th,
.qs-compare-spec td {
  border-top: 1px solid #e0e0e0;
  border-bottom: 1px solid #e0e0e0;
  border-left: none;
  border-right: none;
}

.qs-compare-spec tbody tr:nth-child(even) {
  background: transparent;
}

.qs-compare-spec tbody tr:not(.qs-compare-spec-no-hover):hover {
  background-color: #f2f2f2 !important;
}

/* Cells */
.qs-compare-spec-cell {
  text-align: left !important;
  white-space: normal !important;
  word-break: break-word !important;
  padding: 10px 14px;
}

.qs-compare-spec-cell-label {
  font-weight: bold !important;
}

.qs-compare-spec-red {
  color: #C20019;
}

/* Note row under GENERAL SPECIFICATION */
.qs-compare-spec-note {
  font-size: var(--body_typography-font-size, 16px);
  font-family: var(--body_typography-font-family, inherit);
  font-weight: var(--body_typography-font-weight, normal);
  line-height: var(--body_typography-line-height, 1.6);
  color: var(--body_typography-color, #333);
  border-top: none !important;
  border-bottom: none !important;
}

/* Main title row */
.qs-compare-spec-title {
  color: black !important;
  text-align: left !important;
  font-size: 30px;
  font-family: var(--h2_typography-font-family);
  font-weight: var(--h2_typography-font-weight);
  line-height: var(--h2_typography-line-height);
  letter-spacing: var(--h2_typography-letter-spacing);
  text-transform: var(--h2_typography-text-transform);
  font-style: var(--h2_typography-font-style, normal);
  border-top: none !important;
  border-bottom: none !important;
  padding-bottom: 0 !important;
}

/* Remove border between section header and first data row */
.qs-compare-spec-no-hover + tr td {
  border-top: none !important;
}

/* Remove border on last data row before a section */
.qs-compare-spec tbody tr:has(+ .qs-compare-spec-no-hover) td {
  border-bottom: none !important;
}

/* Sub-section header rows */
.qs-compare-spec-section {
  color: black !important;
  text-align: left !important;
  font-size: 26px;
  font-family: var(--h2_typography-font-family);
  font-weight: var(--h2_typography-font-weight);
  line-height: var(--h2_typography-line-height);
  letter-spacing: var(--h2_typography-letter-spacing);
  text-transform: var(--h2_typography-text-transform);
  font-style: var(--h2_typography-font-style, normal);
  padding-top: 20px !important;
  border-top: none !important;
  border-bottom: none !important;
}

.qs-compare-spec-section-first {
  padding-top: 8px !important;
}

/* No hover on any headers */
.qs-compare-spec td.qs-compare-spec-title:hover,
.qs-compare-spec td.qs-compare-spec-section:hover {
  color: black !important;
  transform: none !important;
  cursor: default;
}

/* Buttons (Product Card, User Manual etc.) */
.qs-compare-spec-buttons {
  text-align: left !important;
  border-bottom: none !important;
}

.qs-compare-spec-button {
  display: inline-block;
  margin-top: 5px;
  margin-bottom: 5px;
}

.qs-compare-spec-button i {
  margin-right: 10px;
  text-align: center !important;
}

/* Hover effect on label column (not on section headers) */
.qs-compare-spec td.qs-compare-spec-cell-label:not(.qs-compare-spec-section):hover {
  color: #c20019;
  transform: translateX(5px);
  transition: transform 0.2s ease, color 0.2s ease;
}

/* Tablet */
@media (max-width: 1024px) {
  .qs-compare-spec {
    width: 100%;
  }

  .qs-compare-spec-button {
    margin: 3px !important;
  }
}

/* Mobile only (phones) */
@media (max-width: 480px) {
  .qs-compare-spec {
    width: 100%;
    overflow: hidden;
  }

  .qs-compare-spec table {
    table-layout: auto;
  }

  .qs-compare-spec-heading h2 {
    font-size: 36px;
  }

  .qs-compare-spec th,
  .qs-compare-spec td {
    padding: 8px 10px;
    font-size: 16px;
    white-space: normal;
    word-break: break-word;
  }

  .qs-compare-spec-title {
    font-size: 22px !important;
    text-align: center !important;
  }

  .qs-compare-spec-section {
    font-size: 20px !important;
    text-align: center !important;
  }

  .qs-compare-spec td.qs-compare-spec-cell-label:hover {
    color: inherit;
    transform: none;
  }

  .qs-compare-spec-button {
    display: flex;
  }

  .qs-compare-spec-cell-label {
    padding-left: 5% !important;
  }

  .qs-compare-spec p {
    margin: 8px 10px 10px 10px !important;
    font-size: 12px;
  }
}

/* =========================================================
   End Product Spec Table
   ========================================================= */

/* ---------------- General table cells ---------------- */

.qs-compare-table td,
.qs-compare-table th {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.4;
  padding-top: 12px;
  padding-bottom: 12px;
}

.qs-compare-table td:not(:first-child) {
  text-align: center;
  vertical-align: middle;
}

/* ---------------- Desktop header — card design ---------------- */

@media (min-width: 769px) {

  /* Fixed label column width on desktop */
  .qs-compare-table .label {
    width: 250px;
    min-width: 250px;
  }

  .qs-col-label {
    width: 250px;
  }

  /* Row 1: product cards */
  .qs-compare-table thead tr.row-cards th {
    background: transparent !important;
    border: none !important;
    vertical-align: top;
    padding: 12px;
  }

  .qs-compare-table thead tr.row-cards th[data-col] {
    position: relative;
    transition: box-shadow 0.2s ease;
  }

  /* Card hover shadow */
  .qs-compare-table thead tr.row-cards th[data-col]:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  }

  /* Row 2: names (red background, sticky on scroll) */
  .qs-compare-table thead tr.row-names th {
    text-align: center;
    font-weight: 700;
    position: sticky;
    top: calc(var(--qs-sticky-offset, 0px) + 10px);
    z-index: 10;
  }

  /* White backdrop — pseudo-element on label cell covers full row width + gap above */
  .qs-compare-table thead tr.row-names th.label {
    position: sticky;
    background: #fff !important;
    overflow: visible;
  }

  .qs-compare-table thead tr.row-names th.label::after {
    content: '';
    position: absolute;
    top: -10px;
    left: -9999px;
    right: -9999px;
    width: auto;
    height: calc(100% + 10px);
    background: #fff;
    z-index: -1;
    pointer-events: none;
  }

  .qs-compare-table thead tr.row-names th[data-col] {
    background: #C20019;
    border-radius: 6px;
    color: white;
    border-top: none !important;
  }

  /* Add-column cell in name row */
  .qs-compare-table thead tr.row-names th.qs-add-col-names {
    background: #fff !important;
    border: none !important;
    vertical-align: middle;
    z-index: 10;
  }

  /* Hide sticky controls by default — show only when cards row is out of view */
  .qs-compare-table thead tr.row-names th.qs-add-col-names .qs-add-wrap,
  .qs-compare-table thead tr.row-names .qs-remove-name {
    display: none;
  }

  .qs-compare-table.is-sticky-active thead tr.row-names th.qs-add-col-names .qs-add-wrap,
  .qs-compare-table.is-sticky-active thead tr.row-names .qs-remove-name {
    display: flex;
    justify-content: center;
  }

  .qs-compare-table.is-sticky-active thead tr.row-names .qs-remove-name {
    display: inline-flex;
  }


  /* Label column — no background/borders in thead only */
  .qs-compare-table thead th.label {
    background: transparent !important;
    border: none !important;
  }

  /* Tbody label cells — keep horizontal borders */
  .qs-compare-table tbody th.label {
    background: transparent;
    border-left: none;
    border-right: none;
  }

  /* ✕ remove button — top-right corner of card */
  .qs-remove-col {
    position: absolute;
    top: 6px;
    right: 6px;
    background: transparent;
    border: 0;
    color: #C20019;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    cursor: pointer;
    font-size: 24px;
    z-index: 2;
    padding: 0;
    transition: opacity 0.15s;
  }

  .qs-remove-col:hover {
    opacity: 0.5;
  }

  /* ✕ remove button in name row (th is already position: sticky which creates containing block) */
  .qs-remove-name {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    cursor: pointer;
    color: rgba(255,255,255,0.75);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    transition: color 0.15s;
  }

  .qs-remove-name svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    fill: none;
  }

  .qs-remove-name:hover {
    color: #fff;
  }

  /* ---- Add-product "+" button column ---- */

  .qs-add-col {
    border: none !important;
    background: transparent !important;
    vertical-align: middle !important;
    text-align: center;
    padding: 0 !important;
  }

  .qs-add-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
  }

  .qs-add-btn {
    width: 60px;
    height: 60px;
    border-radius: 10px;
    border: none;
    background: #C20019;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s;
  }

  .qs-add-btn svg {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
  }

  .qs-add-label {
    display: none;
  }

  .qs-add-btn:hover {
    background: #a30015;
  }

  .qs-add-popover {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    padding: 8px;
    z-index: 100;
    min-width: 220px;
    max-height: 400px;
    overflow-y: auto;
  }

  .qs-add-wrap.is-open .qs-add-popover {
    display: block;
  }

  .qs-add-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 8px;
    text-align: left;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    color: #222;
    transition: background 0.15s;
    white-space: nowrap;
  }

  .qs-add-option:hover {
    background: #f5f5f5;
  }

  .qs-add-option img {
    width: 48px;
    height: 48px;
    object-fit: contain;
  }

  /* Sticky name row: smaller "+" button, no label */
  .qs-compare-table thead tr.row-names .qs-add-btn {
    width: 40px;
    height: 40px;
    min-height: 0;
    padding: 0;
    border-radius: 8px;
    border: none;
    background: #C20019;
    color: #fff;
    gap: 0;
  }

  .qs-compare-table thead tr.row-names .qs-add-btn:hover {
    background: #a30015;
    color: #fff;
  }

  .qs-compare-table thead tr.row-names .qs-add-btn svg {
    width: 22px;
    height: 22px;
  }

  .qs-compare-table thead tr.row-names .qs-add-popover {
    top: calc(100% + 8px);
    right: 0;
    transform: none;
  }

  /* --- Card animations --- */

  /* Enter animation */
  .qs-compare-table thead th[data-col] .prod-visual,
  .qs-compare-table thead th[data-col] .qs-remove-col {
    transition: opacity 0.25s ease-out, transform 0.25s ease-out;
  }

  .qs-card-enter .prod-visual,
  .qs-card-enter .qs-remove-col {
    opacity: 0;
    transform: scale(0.95);
  }

  .qs-card-enter.qs-card-entered .prod-visual,
  .qs-card-enter.qs-card-entered .qs-remove-col {
    opacity: 1;
    transform: scale(1);
  }

  /* Exit animation */
  .qs-card-exit {
    opacity: 0 !important;
    transform: scale(0.95);
    transition: opacity 0.2s ease-in, transform 0.2s ease-in;
  }
}
