/**
 * Responsive editor tables for Vantage.
 * Tables are wrapped in .entry-table-scroll (PHP hook + JS fallback).
 */

.entry-table-scroll {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0 0 1.5em;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: #00bcff #eef3f6;
  border: 1px solid #e4e8eb;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.entry-table-scroll::-webkit-scrollbar {
  height: 8px;
}

.entry-table-scroll::-webkit-scrollbar-track {
  background: #eef3f6;
  border-radius: 0 0 8px 8px;
}

.entry-table-scroll::-webkit-scrollbar-thumb {
  background: #00bcff;
  border-radius: 8px;
}

.entry-table-scroll.is-scrollable::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 28px;
  pointer-events: none;
  background: linear-gradient(to left, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0));
}

.entry-table-scroll.is-scrollable.is-scrolled-end::after {
  opacity: 0;
}

.entry-content .wp-block-table {
  margin: 0 0 1.5em;
  overflow: visible;
}

.entry-content .wp-block-table .entry-table-scroll,
.entry-content .wp-block-table figcaption + .entry-table-scroll {
  margin-bottom: 0;
}

.entry-content .wp-block-table figcaption {
  margin: 0.6em 0 0;
  color: #777;
  font-size: 13px;
}

.entry-table-scroll table,
.entry-content .entry-table-scroll table,
.entry-content table,
.panel-grid table,
.siteorigin-widget-tinymce table {
  width: max-content;
  min-width: 100%;
  margin: 0;
  border: 0;
  border-collapse: collapse;
  border-spacing: 0;
  font-size: 14px;
  line-height: 1.45;
  background: #fff;
  color: #444;
}

.entry-table-scroll table th,
.entry-table-scroll table td,
.entry-content table th,
.entry-content table td,
.panel-grid table th,
.panel-grid table td {
  padding: 12px 16px;
  text-align: left;
  vertical-align: middle;
  border: 0;
  border-bottom: 1px solid #eef1f3;
  border-right: 1px solid #f2f4f6;
}

.entry-table-scroll table th:last-child,
.entry-table-scroll table td:last-child,
.entry-content table th:last-child,
.entry-content table td:last-child {
  border-right: 0;
}

.entry-table-scroll table thead th,
.entry-table-scroll table tr:first-child th,
.entry-content table thead th,
.entry-content table tr:first-child th,
.panel-grid table thead th,
.panel-grid table tr:first-child th {
  background: #f4f8fb;
  color: #2b2b2b;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  border-bottom: 2px solid #00bcff;
}

.entry-table-scroll table tbody th,
.entry-content table tbody th {
  background: #fafcfd;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
}

.entry-table-scroll table tbody tr:nth-child(even) td,
.entry-table-scroll table tbody tr:nth-child(even) th,
.entry-content table tbody tr:nth-child(even) td,
.entry-content table tbody tr:nth-child(even) th {
  background: #f8fbfd;
}

.entry-table-scroll table tbody tr:hover td,
.entry-table-scroll table tbody tr:hover th,
.entry-content table tbody tr:hover td,
.entry-content table tbody tr:hover th {
  background: #eef8ff;
}

.entry-table-scroll table tbody tr:last-child td,
.entry-table-scroll table tbody tr:last-child th,
.entry-content table tbody tr:last-child td,
.entry-content table tbody tr:last-child th {
  border-bottom: 0;
}

.entry-table-scroll table caption,
.entry-content table caption {
  caption-side: bottom;
  padding: 10px 4px 0;
  color: #777;
  font-size: 13px;
  text-align: left;
}

/* Keep WooCommerce / calendar tables untouched */
.woocommerce .entry-table-scroll,
.woocommerce-page .entry-table-scroll {
  overflow: visible;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

.woocommerce table.shop_table,
.woocommerce table.variations,
.woocommerce-page table.shop_table,
#wp-calendar,
.wp-calendar-table {
  width: 100%;
  min-width: 0;
}

@media (max-width: 768px) {
  .entry-table-scroll {
    margin-left: 0;
    margin-right: 0;
  }

  .entry-table-scroll table th,
  .entry-table-scroll table td,
  .entry-content table th,
  .entry-content table td {
    padding: 10px 12px;
    font-size: 13px;
  }
}

/* Gutenberg editor preview */
.editor-styles-wrapper table,
.block-editor-page .wp-block-table table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #e4e8eb;
  border-radius: 8px;
  overflow: hidden;
  font-size: 14px;
}

.editor-styles-wrapper table th,
.block-editor-page .wp-block-table th {
  background: #f4f8fb;
  border-bottom: 2px solid #00bcff;
  padding: 12px 16px;
  font-weight: 600;
}

.editor-styles-wrapper table td,
.block-editor-page .wp-block-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #eef1f3;
}
