/* =====================================================
   Custom Table Builder — Frontend Styles v1.8.0
   Responsive with touch-friendly horizontal scroll
   ===================================================== */

/* Wrapper: enables horizontal scroll on overflow */
.ctb-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch; /* smooth scroll on iOS */
  overscroll-behavior-x: contain;   /* prevent parent scroll hijacking */
  overscroll-behavior-y: auto;
  margin: 0.5em 0;
  /* Subtle scrollbar */
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,.18) transparent;
  /* Fade hint on right edge when overflow exists */
  position: relative;
}
.ctb-table-wrap::-webkit-scrollbar        { height: 5px; }
.ctb-table-wrap::-webkit-scrollbar-track  { background: transparent; }
.ctb-table-wrap::-webkit-scrollbar-thumb  { background: rgba(0,0,0,.18); border-radius: 10px; }
.ctb-table-wrap::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.32); }

/* Scroll hint shadow on right when overflowing */
.ctb-table-wrap::after {
  content: '';
  position: sticky;
  top: 0;
  right: 0;
  bottom: 0;
  width: 28px;
  pointer-events: none;
  background: linear-gradient(to right, transparent, rgba(255,255,255,.5));
  display: block;
  float: right;
  height: 100%;
  margin-top: -100%; /* overlay without affecting layout */
}

/* Table itself */
.ctb-public-table {
  width: 100%;
  border-collapse: collapse;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  /* Prevent table from compressing below a reasonable minimum */
  min-width: 400px;
  table-layout: auto;
}

/* Header */
.ctb-public-table thead th {
  font-weight: 700;
  letter-spacing: .4px;
  line-height: 1.35;
  white-space: nowrap; /* headers stay on one line */
  vertical-align: middle;
}

/* Cells */
.ctb-public-table tbody td {
  vertical-align: middle;
  line-height: 1.45;
  /* Prevent single cells from becoming enormous */
  max-width: 320px;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Buttons */
.ctb-public-table .ctb-btn {
  display: inline-block;
  font-weight: 700;
  text-decoration: none;
  text-align: center;
  line-height: 1.45;
  white-space: normal;
  word-break: break-word;
  box-sizing: border-box;
  max-width: 100%;
  transition: opacity .2s ease;
}
.ctb-public-table .ctb-btn:hover { opacity: .82; }

/* Images */
.ctb-public-table .ctb-img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

/* Dynamic / Aggregate cells */
.ctb-dyn-text, .ctb-agg-value { display: inline-block; }
.ctb-dyn-html  { line-height: 1.6; }
.ctb-dyn-link  { text-decoration: underline; word-break: break-all; }
.ctb-dyn-img   { display: block; margin: 0 auto; max-width: 100%; height: auto; }

/* Title headings inside cells */
.ctb-public-table .ctb-title { margin: 0; padding: 0; line-height: 1.3; }

/* Rich text */
.ctb-public-table .ctb-rich { line-height: 1.6; }

/* ─────────────────────────────────────────────────────
   RESPONSIVE — breakpoints matching Elementor defaults
   Desktop:  > 1024px  — full size
   Tablet:   768–1024px — slightly smaller
   Mobile L: 480–767px — compact, horizontal scroll
   Mobile S: < 480px   — most compact
───────────────────────────────────────────────────── */

/* ── Tablet (≤ 1024px) ── */
@media screen and (max-width: 1024px) {
  .ctb-public-table thead th,
  .ctb-public-table tbody td {
    font-size: .9em;
    padding: 10px 12px !important;
  }
  .ctb-public-table .ctb-btn {
    font-size: .8em;
    padding: 7px 12px !important;
  }
  .ctb-public-table tbody td { max-width: 240px; }
}

/* ── Mobile Landscape (≤ 768px) ── */
@media screen and (max-width: 768px) {
  .ctb-table-wrap { margin: 0.25em 0; }

  .ctb-public-table {
    font-size: .82em;
    min-width: 480px; /* force horizontal scroll below this */
  }
  .ctb-public-table thead th,
  .ctb-public-table tbody td {
    padding: 8px 10px !important;
    font-size: 1em; /* relative to table font-size = .82em */
  }
  .ctb-public-table .ctb-btn {
    font-size: .85em;
    padding: 6px 10px !important;
    letter-spacing: .2px;
  }
  .ctb-public-table .ctb-img,
  .ctb-public-table .ctb-dyn-img {
    max-width: 80px !important;
    max-height: 60px !important;
    object-fit: cover;
  }
  .ctb-public-table tbody td { max-width: 180px; }
}

/* ── Mobile Portrait (≤ 480px) ── */
@media screen and (max-width: 480px) {
  .ctb-public-table {
    font-size: .78em;
    min-width: 400px;
  }
  .ctb-public-table thead th,
  .ctb-public-table tbody td {
    padding: 7px 8px !important;
    line-height: 1.35;
  }
  .ctb-public-table .ctb-btn {
    font-size: .8em;
    padding: 5px 8px !important;
  }
  .ctb-public-table .ctb-img,
  .ctb-public-table .ctb-dyn-img {
    max-width: 60px !important;
    max-height: 45px !important;
  }
  .ctb-public-table tbody td { max-width: 140px; }
}

/* ─────────────────────────────────────────────────────
   TOUCH SCROLL HANDLING
   Prevents vertical scroll hijack when finger moves
   more horizontally than vertically inside the wrap.
───────────────────────────────────────────────────── */
/* Applied via JS — see touch handler added by plugin */
.ctb-table-wrap.ctb-touching-h {
  overflow-x: scroll;
  touch-action: pan-x;
}
.ctb-table-wrap.ctb-touching-v {
  overflow-x: hidden;
  touch-action: pan-y;
}
