/* ==========================================================================
   RatesTable — filter card + term tabs + sort dropdown (new),
   table itself matches the original Webflow design.
   ========================================================================== */

.rt-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.rt {
  --rt-table-bg: #e3eff4;        /* original light-blue card */
  --rt-row-stripe: #f2f5f8;
  --rt-row-hover: #cedee8;
  --rt-head-bg: #f8f9fa;
  --rt-head-border: #dee2e6;
  --rt-row-border: #dee2e6;
  --rt-text: #495057;
  --rt-text-strong: #333;
  --rt-text-muted: #6c757d;
  --rt-rate: #007bff;
  --rt-rate-hover: #0056b3;
  --rt-accent: #d70019;
  --rt-accent-hover: #a82222;
  --rt-details-bg: #fcfdfe;
  --rt-details-text: #002e4d;

  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-family: 'Inter Display', sans-serif;
  color: var(--rt-text);
}

/* ─── Filter Card (new) ─────────────────────────────────────────────── */

.rt-filters {
  background: #fff;
  border: 1px solid var(--color-neutral-200);
  border-radius: 16px;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Hide default disclosure marker; always show contents above the breakpoint. */
.rt-filters > summary {
  list-style: none;
  cursor: default;
}

.rt-filters > summary::-webkit-details-marker {
  display: none;
}

.rt-filters__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.rt-filters__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  margin-left: 8px;
  border-radius: 999px;
  background: var(--rt-accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  vertical-align: middle;
}

.rt-filters__header-end {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.rt-filters__title {
  color: var(--color-primary-300);
  margin: 0;
}

.rt-filters__updated {
  color: var(--rt-text-muted);
  display: inline-flex;
  align-items: center;
}

.rt-filters__reset {
  border: 1px solid var(--color-neutral-200);
  background: #fff;
  color: var(--rt-text-strong);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.rt-filters__reset:hover:not(:disabled) {
  background: var(--color-neutral-150);
  border-color: var(--color-neutral-300);
}

.rt-filters__reset:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.rt-filters__updated::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2bb673;
  display: inline-block;
  margin-right: 8px;
  box-shadow: 0 0 0 0 rgba(43, 182, 115, 0.5);
  animation: rt-pulse 2s ease-out infinite;
}

@keyframes rt-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(43, 182, 115, 0.5); }
  70%  { box-shadow: 0 0 0 6px rgba(43, 182, 115, 0); }
  100% { box-shadow: 0 0 0 0 rgba(43, 182, 115, 0); }
}

.rt-filters__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

/* ─── Active filter chips ───────────────────────────────────────────── */

.rt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rt-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--color-neutral-150);
  color: var(--rt-text-strong);
  border: 1px solid var(--color-neutral-200);
  border-radius: 999px;
  padding: 5px 10px 5px 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.rt-chip:hover {
  background: var(--rt-row-hover);
  border-color: var(--color-neutral-300);
}

.rt-chip svg {
  width: 10px;
  height: 10px;
  color: var(--rt-text-muted);
  flex-shrink: 0;
}

.rt-chip:hover svg {
  color: var(--rt-accent);
}

.rt-filters__grid .wf-field {
  margin: 0;
  gap: 4px;
}

.rt-filters__grid .wf-field__label {
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--rt-text-muted);
  font-weight: 600;
}

/* ─── Term Tabs (new) ───────────────────────────────────────────────── */

.rt-tabs {
  background: var(--color-neutral-150);
  border-radius: 12px;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 4px;
}

.rt-tab {
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--rt-text-muted);
  font: inherit;
  font-family: 'Inter Display', sans-serif;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
  white-space: nowrap;
  min-height: 48px;
}

.rt-tab:hover {
  background: rgba(255, 255, 255, 0.6);
  color: var(--rt-text-strong);
}

.rt-tab--active {
  background: #fff;
  color: var(--color-primary-300);
  box-shadow: 0 1px 3px rgba(0, 46, 77, 0.08);
}

.rt-tab__label {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}

.rt-tab__stats {
  font-size: 15px;
  color: var(--rt-text-muted);
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  padding-left: 8px;
  border-left: 1px solid currentColor;
  opacity: 1;
}

.rt-tab .rt-tab__stats {
  border-left-color: rgba(108, 117, 125, 0.35);
}

.rt-tab--active .rt-tab__stats {
  color: var(--rt-accent);
  border-left-color: rgba(0, 46, 77, 0.2);
}

@media (prefers-reduced-motion: no-preference) {
  .rt-tab:hover {
    transform: translateY(-1px);
  }
}

/* ─── Toolbar (new) ─────────────────────────────────────────────────── */

.rt-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 0 4px;
}

.rt-toolbar__count {
  color: var(--rt-text-muted);
  font-size: 14px;
}

.rt-toolbar__count strong {
  color: var(--color-primary-300);
  font-weight: 600;
}

.rt-toolbar__sort {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rt-toolbar__sort .wf-field {
  margin: 0;
  min-width: 240px;
}

.rt-toolbar__sort-label {
  color: var(--rt-text-muted);
  font-size: 14px;
  white-space: nowrap;
}

/* ─── Table — original Webflow design ───────────────────────────────── */

.rt-wrapper {
  position: relative;
  isolation: isolate;
}

.rt-wrapper--gated {
  max-height: 520px;
  overflow: hidden;
}

.rt-table-shell {
  background: var(--rt-table-bg);
  border-radius: 16px;
  overflow-x: auto;
}

.rt-wrapper--gated .rt-table-shell {
  pointer-events: none;
  user-select: none;
}

.rt-table {
  width: 100%;
  min-width: 800px;
  border-collapse: collapse;
  table-layout: fixed;
}

.rt-table thead th {
  background: var(--rt-head-bg);
  color: var(--rt-text-strong);
  font-weight: 600;
  padding: 16px;
  text-align: center;
  border-bottom: 2px solid var(--rt-head-border);
  white-space: nowrap;
  font-size: 14px;
  letter-spacing: 0.01em;
  position: sticky;
  top: 0;
  z-index: 1;
}

.rt-table thead th:nth-child(1) { width: 22%; }
.rt-table thead th:nth-child(2) { width: 11%; }
.rt-table thead th:nth-child(3) { width: 27%; }
.rt-table thead th:nth-child(4) { width: 12%; }
.rt-table thead th:nth-child(5) { width: 10%; }
.rt-table thead th:nth-child(6) { width: 18%; }

.rt-table thead th:first-child {
  text-align: left;
  border-top-left-radius: 16px;
}

.rt-table thead th:last-child {
  border-top-right-radius: 16px;
}

.rt-table tbody td {
  padding: 16px;
  border-bottom: 1px solid var(--rt-row-border);
  color: var(--rt-text);
  text-align: center;
  font-size: 15px;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rt-table tbody td.rt-cell-left {
  text-align: left;
  font-weight: 500;
  color: var(--rt-text-strong);
}

.rt-table tbody td.rt-cell-rate {
  font-weight: 700;
  color: var(--rt-rate);
  font-size: 16px;
}

.rt-table tbody td.rt-cell-rate--best {
  color: var(--rt-accent);
  font-size: 18px;
}

.rt-table tbody tr:last-child td {
  border-bottom: none;
}

.rt-row--main {
  cursor: pointer;
}

.rt-row--main:focus-visible {
  outline: 2px solid var(--rt-rate);
  outline-offset: -2px;
}

.rt-row--main:focus:not(:focus-visible) {
  outline: none;
}

.rt-row--main td {
  transition: background-color 0.18s ease, box-shadow 0.18s ease;
}

.rt-row--main.rt-row--stripe td {
  background: var(--rt-row-stripe);
}

.rt-row--main:hover td {
  background: var(--rt-row-hover);
}

.rt-row--main:hover td:first-child {
  box-shadow: inset 3px 0 0 var(--rt-accent);
}

.rt-row--main[aria-expanded="true"] td {
  background: var(--rt-row-hover);
}

.rt-row--main[aria-expanded="true"] td:first-child {
  box-shadow: inset 3px 0 0 var(--rt-accent);
}

.rt-toggle {
  color: var(--rt-rate);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s ease;
}

.rt-toggle__chevron {
  display: inline-block;
  width: 10px;
  height: 10px;
  transition: transform 0.25s ease;
}

.rt-row--main[aria-expanded="true"] .rt-toggle__chevron {
  transform: rotate(180deg);
}

.rt-row--main:hover .rt-toggle {
  color: var(--rt-rate-hover);
}

.rt-cell-actions {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  justify-content: center;
}

/* ─── Rating tiers (text color only) ────────────────────────────────── */

.rt-pill {
  font-weight: 600;
  white-space: nowrap;
}

.rt-pill--top    { color: #0e6b32; font-weight: 700; }
.rt-pill--strong { color: #3aa45c; }
.rt-pill--mid    { color: #1a5d99; }
.rt-pill--weak   { color: #9a5a14; }
.rt-pill--unknown { color: var(--rt-text-muted); }

.rt-row-cta {
  background: var(--rt-accent);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  border-radius: 999px;
  padding: 7px 14px;
  white-space: nowrap;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.rt-row-cta:hover {
  background: var(--rt-accent-hover);
}

@media (prefers-reduced-motion: no-preference) {
  .rt-row-cta:hover {
    transform: translateY(-1px);
  }
}

.rt-state__reset {
  margin-top: 16px;
  border: 1px solid var(--color-neutral-200);
  background: #fff;
  color: var(--rt-text-strong);
  border-radius: 999px;
  padding: 8px 18px;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.rt-state__reset:hover {
  background: var(--color-neutral-150);
  border-color: var(--color-neutral-300);
}

/* ─── Details row ─── */

.rt-table tbody tr.rt-row--details > td {
  padding: 0;
  background: var(--rt-details-bg) !important;
  border-bottom: 0;
  overflow: visible;
  white-space: normal;
  text-overflow: clip;
}

.rt-details-wrap {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.28s ease, opacity 0.2s ease;
  border-bottom: 0 solid var(--rt-row-border);
}

.rt-details-wrap--open {
  grid-template-rows: 1fr;
  opacity: 1;
  border-bottom-width: 1px;
}

.rt-details-inner {
  overflow: hidden;
  min-height: 0;
}

.rt-details {
  padding: 16px 16px 40px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
  position: relative;
  text-align: left;
}

@media (prefers-reduced-motion: reduce) {
  .rt-details-wrap {
    transition: none;
  }
}

.rt-details__item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rt-details__label {
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--rt-text-muted);
  font-weight: 700;
}

.rt-details__value {
  font-size: 15px;
  color: var(--rt-details-text);
  font-weight: 500;
}

.rt-details__value--muted {
  font-size: 13px;
  color: var(--rt-text-muted);
}

.rt-details__ratings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  background: #f1f6f9;
  padding: 12px;
  border-radius: 8px;
}

.rt-details__date {
  position: absolute;
  bottom: 10px;
  right: 12px;
  font-size: 13px;
  color: var(--rt-text-muted);
}

/* ─── Loading / Error / Empty ───────────────────────────────────────── */

.rt-state {
  background: #fff;
  border: 1px solid var(--color-neutral-200);
  border-radius: 16px;
  padding: 56px 24px;
  text-align: center;
  color: var(--color-primary-300);
}

.rt-state--error {
  border-color: rgba(197, 39, 39, 0.3);
  color: var(--color-secondary-400);
  background: rgba(197, 39, 39, 0.06);
}

.rt-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--color-neutral-200);
  border-bottom-color: var(--rt-rate);
  border-radius: 50%;
  display: inline-block;
  animation: rt-rotate 0.9s linear infinite;
  margin-bottom: 12px;
}

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

/* ─── Gating overlay ────────────────────────────────────────────────── */

.rt-overlay {
  display: none;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 2;
}

.rt-wrapper--gated .rt-overlay {
  display: block;
}

.rt-overlay__gradient {
  height: 120px;
  background: linear-gradient(to bottom, rgba(227, 239, 244, 0) 0%, var(--rt-table-bg) 100%);
}

.rt-overlay__solid {
  height: 60px;
  background: var(--rt-table-bg);
  border-radius: 0 0 16px 16px;
}

.rt-cta-wrapper {
  display: none;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 3;
}

.rt-wrapper--gated .rt-cta-wrapper {
  display: block;
}

.rt-cta-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: #d70019;
  padding: 16px 24px;
  border-radius: 12px 12px 0 0;
  max-width: 460px;
  margin: 0 auto;
  pointer-events: auto;
  cursor: pointer;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 18px;
  border: 0;
  font-family: inherit;
  transition: background-color 0.15s;
}

.rt-cta-bar:hover {
  background: #a82222;
}

.rt-cta-bar__icon {
  width: 24px;
  height: 24px;
}

/* ─── Responsive ────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  /* ── Filter card becomes collapsible on mobile ── */
  .rt-filters {
    padding: 16px 18px;
  }

  .rt-filters > summary {
    cursor: pointer;
  }

  .rt-filters > summary::after {
    content: '';
    width: 10px;
    height: 10px;
    border-right: 2px solid var(--rt-text-muted);
    border-bottom: 2px solid var(--rt-text-muted);
    transform: rotate(45deg);
    transition: transform 0.2s ease;
    margin-left: auto;
    margin-right: 4px;
    align-self: center;
  }

  .rt-filters[open] > summary::after {
    transform: rotate(-135deg);
    margin-top: 6px;
  }

  .rt-filters__grid {
    grid-template-columns: 1fr;
  }

  .rt-filters__updated {
    display: none;
  }

  /* ── Toolbar stays — wraps if needed ── */
  .rt-toolbar__sort .wf-field {
    min-width: 0;
  }

  /* ── Table becomes a stack of cards ── */
  .rt-table-shell {
    background: transparent;
    overflow-x: visible;
    border-radius: 0;
  }

  .rt-table {
    min-width: 0;
    table-layout: auto;
  }

  .rt-table thead {
    display: none;
  }

  .rt-table tbody,
  .rt-table tbody tr.rt-row--main,
  .rt-table tbody tr.rt-row--details {
    display: block;
    width: 100%;
  }

  .rt-table tbody tr.rt-row--main {
    background: var(--rt-table-bg);
    border-radius: 12px;
    margin-bottom: 12px;
    padding: 14px 16px 16px;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "company rate"
      "product rate"
      "ratings term"
      "details details";
    gap: 4px 12px;
    align-items: baseline;
  }

  .rt-table tbody tr.rt-row--main td {
    display: block;
    padding: 0;
    border: 0;
    background: transparent !important;
    text-align: left;
    white-space: normal;
    overflow: visible;
    font-size: 14px;
  }

  /* Hide labels by default — show only where useful */
  .rt-table tbody tr.rt-row--main td::before {
    content: attr(data-label);
    display: block;
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--rt-text-muted);
    margin-bottom: 2px;
  }

  .rt-table tbody tr.rt-row--main td[data-label="Company"] {
    grid-area: company;
    font-weight: 600;
    color: var(--rt-text-strong);
    font-size: 15px;
  }

  .rt-table tbody tr.rt-row--main td[data-label="Company"]::before {
    display: none;
  }

  .rt-table tbody tr.rt-row--main td[data-label="Product"] {
    grid-area: product;
    color: var(--rt-text);
  }

  .rt-table tbody tr.rt-row--main td[data-label="Product"]::before {
    display: none;
  }

  .rt-table tbody tr.rt-row--main td[data-label="Ratings"] {
    grid-area: ratings;
  }

  .rt-table tbody tr.rt-row--main td[data-label="Rate"] {
    grid-area: rate;
    text-align: right;
    font-size: 22px;
    align-self: center;
  }

  .rt-table tbody tr.rt-row--main td[data-label="Rate"]::before {
    display: none;
  }

  .rt-table tbody tr.rt-row--main td[data-label="Term"] {
    grid-area: term;
    text-align: right;
    color: var(--rt-text-muted);
    font-size: 12px;
  }

  .rt-table tbody tr.rt-row--main td[data-label="Term"]::before {
    display: none;
  }

  .rt-table tbody tr.rt-row--main td[data-label="Details"] {
    grid-area: details;
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--rt-row-border);
  }

  .rt-table tbody tr.rt-row--main td[data-label="Details"]::before {
    display: none;
  }

  .rt-cell-actions {
    width: 100%;
    justify-content: space-between;
  }

  /* Details row sits flush under its card */
  .rt-table tbody tr.rt-row--details {
    background: transparent;
  }

  .rt-table tbody tr.rt-row--details > td {
    background: transparent !important;
    padding: 0;
  }

  .rt-details-wrap--open {
    margin: -8px 0 12px;
    border-radius: 0 0 12px 12px;
    background: var(--rt-details-bg);
  }

  .rt-details {
    padding: 12px 16px 32px;
  }

  /* Hover state on touch isn't useful */
  .rt-table tbody tr.rt-row--main:hover td:first-child {
    box-shadow: none;
  }

  .rt-row--main[aria-expanded="true"] td:first-child {
    box-shadow: none;
  }
}

