/* ═══════════════════════════════════════════════════════════════════
   Zahy Comparison Table — adapted for zahy_website theme
   Colors: heading #023b59 · accent #76ca8c · gray-bg #F5F5F5
   Font: Montserrat (matches site body/heading font)
   Icons: FontAwesome (fa-solid) — no Tabler Icons dependency
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --zahy-comp-radius-sm: 6px;
  --zahy-comp-radius-md: 8px;
  --zahy-comp-radius-lg: 12px;
  --zahy-comp-transition: 200ms ease-in-out;
  --zahy-comp-transition-filter: 280ms ease-in-out;
}

/* ─── Theme tokens — mapped to zahy site palette ─────────────────── */

.zahy-comparison {
  --zahy-navy:            #023b59;
  --zahy-green:           #76ca8c;
  --zahy-surface:         #ffffff;
  --zahy-surface-muted:   #F5F5F5;
  --zahy-surface-elevated:#ffffff;
  --zahy-border:          #e5e7eb;
  --zahy-text-primary:    #023b59;
  --zahy-text-secondary:  #788094;
  --zahy-text-tertiary:   #adb5bd;
  --zahy-heading:         #023b59;
  --zahy-navy-light:      rgba(2, 59, 89, 0.07);
  --zahy-green-light:     rgba(118, 202, 140, 0.15);
  --zahy-row-hover:       rgba(245, 245, 245, 0.8);
  --zahy-filter-hover:    rgba(255, 255, 255, 0.6);
  --zahy-border-accent:   rgba(2, 59, 89, 0.12);
  --zahy-border-strong:   rgba(2, 59, 89, 0.18);
  --zahy-featured-cell:   rgba(2, 59, 89, 0.09);
  --zahy-highlight-hover: rgba(118, 202, 140, 0.18);
  --zahy-focus-ring:      #023b59;

  /* Legacy aliases */
  --zahy-white:   var(--zahy-surface);
  --zahy-bg-light:var(--zahy-surface-muted);

  --zahy-sticky-offset: 0px;

  font-family: "Montserrat", sans-serif;
  color: var(--zahy-text-primary);
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 24px;
  direction: rtl;        /* default; JS overrides via [dir] attribute */
  text-align: start;
  background: var(--zahy-surface);
  transition:
    background-color var(--zahy-comp-transition),
    color var(--zahy-comp-transition);
}

/* Viewport reveal */
.zahy-comparison--reveal-pending {
  opacity: 0;
  transform: translateY(20px);
}

.zahy-comparison--reveal-in {
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 520ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 520ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* ─── Header ────────────────────────────────────────────────────── */

.zahy-comparison .zahy-comparison__header {
  text-align: center;
  margin-bottom: 32px;
}

.zahy-comparison .zahy-comparison__title {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--zahy-heading);
  text-align: center !important;
}

.zahy-comparison .zahy-comparison__subtitle {
  margin: 0;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--zahy-text-secondary);
  text-align: center !important;
}

/* ─── Product filter tabs ─────────────────────────────────────────── */

.zahy-comparison__filters {
  display: flex;
  gap: 4px;
  max-width: 480px;
  margin-top: 0;
  margin-bottom: 24px;
  margin-left: auto;
  margin-right: auto;
  padding: 6px;
  background: var(--zahy-bg-light);
  border-radius: 100px;
  border: 0.5px solid var(--zahy-border);
}

.zahy-comparison__filter-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  border: none;
  border-radius: 100px;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  color: var(--zahy-text-secondary);
  cursor: pointer;
  transition:
    background var(--zahy-comp-transition),
    color var(--zahy-comp-transition),
    transform var(--zahy-comp-transition);
  white-space: nowrap;
}

.zahy-comparison__filter-btn:hover:not(.zahy-comparison__filter-btn--active) {
  color: var(--zahy-text-primary);
  background: var(--zahy-filter-hover);
}

.zahy-comparison__filter-btn:focus-visible {
  outline: 2px solid var(--zahy-focus-ring);
  outline-offset: 2px;
}

.zahy-comparison__filter-btn--active {
  background: var(--zahy-surface-elevated);
  font-weight: 600;
  color: var(--zahy-text-primary);
  box-shadow: 0 2px 8px rgba(2, 59, 89, 0.12);
}

.zahy-comparison__filter-btn:active {
  transform: scale(0.98);
}

.zahy-comparison__filter-icon {
  font-size: 16px;
  line-height: 1;
  color: var(--zahy-heading);
}

/* ─── Product cards ─────────────────────────────────────────────── */

.zahy-comparison__products {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 40px;
  position: relative;
  min-height: 100px;
  transition: grid-template-columns var(--zahy-comp-transition);
}

.zahy-comparison__products--filtered {
  grid-template-columns: 1fr;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

.zahy-product-card {
  padding: 16px;
  text-align: center;
  background: var(--zahy-bg-light);
  border-radius: var(--zahy-comp-radius-md);
  border: 0.5px solid transparent;
  transition:
    opacity var(--zahy-comp-transition-filter),
    transform var(--zahy-comp-transition-filter),
    background var(--zahy-comp-transition);
}

.zahy-product-card.zahy-filter--out {
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
}

.zahy-product-card.zahy-filter--hidden {
  display: none;
}

.zahy-product-card.zahy-product-card--visible {
  border-color: var(--zahy-border-accent);
}

/* ─── Price table filter transitions ──────────────────────────────── */

.zahy-comparison__table-panel {
  transition: opacity var(--zahy-comp-transition-filter);
}

.zahy-comparison__table-panel--fading {
  opacity: 0.55;
}

.zahy-comparison__section--prices tbody tr[data-product-id] {
  transition: opacity var(--zahy-comp-transition-filter);
}

.zahy-comparison__section--prices tbody tr[data-product-id].zahy-filter--enter { opacity: 0; }
.zahy-comparison__section--prices tbody tr[data-product-id].zahy-filter--out   { opacity: 0; }
.zahy-comparison__section--prices tbody tr[data-product-id].zahy-filter--hidden { display: none; }

.zahy-product-card__icon {
  font-size: 22px;
  line-height: 1;
  color: var(--zahy-heading);
  margin-bottom: 8px;
}

.zahy-product-card__name {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
  color: var(--zahy-text-primary);
}

.zahy-product-card__desc {
  margin: 0;
  font-size: 12px;
  font-weight: 400;
  color: var(--zahy-text-secondary);
}

/* ─── Sections ──────────────────────────────────────────────────── */

.zahy-comparison__section {
  margin-bottom: 40px;
}

.zahy-comparison__section-title {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 600;
  color: var(--zahy-heading);
}

/* ─── Table wrapper (horizontal scroll) ─────────────────────────── */

.zahy-table-wrapper {
  overflow-x: auto;
  overflow-y: clip;
  -webkit-overflow-scrolling: touch;
  border: 0.5px solid var(--zahy-border);
  border-radius: var(--zahy-comp-radius-md);
  background: var(--zahy-surface);
}

.zahy-comparison__section--scrollable .zahy-table-wrapper {
  max-height: min(70vh, 560px);
  overflow-y: auto;
  overflow-x: auto;
}

.zahy-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  font-size: 14px;
  font-weight: 400;
  min-width: 560px;
}

.zahy-table caption.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;
}

/* ─── Table head ──────────────────────────────────────────────────── */

.zahy-table thead th {
  position: sticky;
  top: var(--zahy-sticky-offset, 0px);
  z-index: 2;
  padding: 12px;
  font-weight: 600;
  font-size: 14px;
  text-align: center;
  background: var(--zahy-bg-light);
  color: var(--zahy-text-primary);
  border-bottom: 0.5px solid var(--zahy-border);
}

.zahy-table thead th:first-child {
  width: 32%;
  text-align: start;
}

.zahy-table thead th.zahy-table__col--featured {
  background: var(--zahy-navy-light);
  color: var(--zahy-navy);
  border-start-end-radius: var(--zahy-comp-radius-md);
  border-start-start-radius: var(--zahy-comp-radius-md);
}

/* ─── Table body ──────────────────────────────────────────────────── */

.zahy-table tbody tr {
  border-bottom: 0.5px solid var(--zahy-border);
  transition: background var(--zahy-comp-transition);
}

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

.zahy-table tbody tr:hover {
  background: var(--zahy-row-hover);
}

.zahy-table tbody tr.zahy-table__row--highlight {
  background: var(--zahy-green-light);
}

.zahy-table tbody tr.zahy-table__row--highlight:hover {
  background: var(--zahy-highlight-hover);
}

.zahy-table tbody th,
.zahy-table tbody td {
  padding: 12px;
  vertical-align: middle;
}

.zahy-table tbody th {
  font-weight: 400;
  text-align: start;
  color: var(--zahy-text-primary);
}

.zahy-table tbody td {
  text-align: center;
}

.zahy-table tbody td.zahy-table__col--featured {
  background: var(--zahy-navy-light);
  color: var(--zahy-navy);
  font-weight: 600;
}

.zahy-table tbody tr.zahy-table__row--highlight td.zahy-table__col--featured {
  background: var(--zahy-featured-cell);
}

/* ─── Cell types ──────────────────────────────────────────────────── */

.zahy-cell--checked {
  color: var(--zahy-green);
}

.zahy-cell--checked .fa-solid {
  font-size: 16px;
}

.zahy-cell--unchecked {
  color: var(--zahy-text-tertiary);
}

.zahy-cell--unchecked .fa-solid {
  font-size: 16px;
}

.zahy-cell--price {
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: embed;
}

.zahy-cell--price .zahy-cell__currency {
  font-size: 12px;
  color: var(--zahy-text-secondary);
  margin-inline-start: 4px;
  direction: rtl;
  unicode-bidi: normal;
}

.zahy-cell__currency-icon {
  height: 13px;
  width: auto;
  vertical-align: middle;
  display: inline-block;
  margin-inline-end: 2px;
  opacity: 0.7;
}

.zahy-cell__period {
  font-size: 12px;
  color: var(--zahy-text-secondary);
}

.zahy-cell--empty {
  color: var(--zahy-text-tertiary);
}

.zahy-cell--text {
  font-size: 13px;
  color: var(--zahy-text-primary);
}

.zahy-badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--zahy-navy);
  background: var(--zahy-green-light);
  border-radius: 999px;
  white-space: nowrap;
}

/* ─── Highlight boxes ───────────────────────────────────────────── */

.zahy-comparison__upgrade {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 24px;
  padding: 16px 20px;
  background: var(--zahy-navy-light);
  border-radius: var(--zahy-comp-radius-lg);
  border: 0.5px solid var(--zahy-border-accent);
}

.zahy-comparison__upgrade-icon {
  flex-shrink: 0;
  font-size: 18px;
  color: var(--zahy-navy);
  margin-inline-end: 8px;
}

.zahy-comparison__upgrade-label {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--zahy-navy);
  width: 100%;
}

.zahy-comparison__upgrade-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0; padding: 0;
  list-style: none;
}

.zahy-comparison__upgrade-item {
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 400;
  color: var(--zahy-navy);
  background: var(--zahy-surface-elevated);
  border-radius: var(--zahy-comp-radius-sm);
  border: 0.5px solid var(--zahy-border-strong);
}

.zahy-comparison__launch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 20px;
  text-align: center;
  background: var(--zahy-bg-light);
  border-radius: var(--zahy-comp-radius-lg);
  border: 0.5px solid var(--zahy-border);
}

.zahy-comparison__launch-icon {
  flex-shrink: 0;
  font-size: 16px;
  color: var(--zahy-green);
  margin-inline-end: 8px;
}

.zahy-comparison__launch-text {
  margin: 0;
  font-size: 14px;
  font-weight: 400;
  color: var(--zahy-text-secondary);
}

/* ─── Accessibility ─────────────────────────────────────────────── */

.zahy-table-wrapper:focus-within {
  outline: 2px solid var(--zahy-focus-ring);
  outline-offset: 2px;
}

.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;
}

/* ─── Tablet ──────────────────────────────────────────────────────── */

@media (max-width: 1279px) {
  .zahy-comparison { padding: 32px 20px; }
}

/* ─── Mobile ──────────────────────────────────────────────────────── */

@media (max-width: 767px) {
  .zahy-comparison { padding: 24px 16px; }
  .zahy-comparison__title  { font-size: 22px; }
  .zahy-comparison__subtitle { font-size: 14px; }
  .zahy-comparison__filters { max-width: 100%; border-radius: 16px; }
  .zahy-comparison__filter-btn { padding: 8px 6px; font-size: 13px; border-radius: 12px; }
  .zahy-comparison__products { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .zahy-comparison__products--filtered { max-width: 100%; }
  .zahy-product-card { padding: 12px 8px; }
  .zahy-product-card__icon  { font-size: 18px; }
  .zahy-product-card__name  { font-size: 13px; }
  .zahy-product-card__desc  { font-size: 11px; }
  .zahy-comparison__section-title { font-size: 16px; }
  .zahy-table { font-size: 13px; min-width: 480px; }
  .zahy-table thead th,
  .zahy-table tbody th,
  .zahy-table tbody td { padding: 10px 8px; }

  .zahy-table thead th:first-child,
  .zahy-table tbody th {
    position: sticky;
    right: 0;
    background: var(--zahy-bg-light);
    border-inline-start: 0.5px solid var(--zahy-border);
  }
  .zahy-table tbody th { z-index: 1; background: var(--zahy-surface); }
  .zahy-table thead th:first-child { top: var(--zahy-sticky-offset, 0px); z-index: 4; }
  .zahy-table tbody td.zahy-table__col--featured { background: var(--zahy-navy-light); }
}

@media (max-width: 480px) {
  .zahy-comparison__products { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .zahy-comparison *,
  .zahy-comparison *::before,
  .zahy-comparison *::after {
    transition-duration: 0.01ms !important;
  }
  .zahy-comparison--reveal-pending { opacity: 1; transform: none; }
}

/* ─── LTR override — applied when JS sets dir="ltr" (English mode) ── */
.zahy-comparison[dir="ltr"] {
  direction: ltr;
}
.zahy-comparison[dir="ltr"] .zahy-comparison__section-title {
  text-align: left;
}
.zahy-comparison[dir="ltr"] .zahy-comparison__upgrade,
.zahy-comparison[dir="ltr"] .zahy-comparison__launch {
  text-align: left;
}
/* Price cells: keep numbers LTR always, but currency label stays native */
.zahy-comparison[dir="ltr"] .zahy-cell--price .zahy-cell__currency {
  direction: ltr;
}
