/* Table Styles - Based on Figma Design */

/* ============================================
   TWO COLUMN TABLE (Label + Content)
   ============================================ */
.custom-table {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-radius: 6px;
  width: 100%;
  max-width: 684px;
}

.custom-table__row {
  display: flex;
  flex-direction: row;
  gap: 2px;
  border-radius: 6px;
}

/* First column - Label/Header cell */
.custom-table__cell--label {
  display: flex;
  align-items: center;
  min-width: 116px;
  width: 116px;
  padding: 14px;
  background: rgba(240, 242, 245, 0.55);
  border-radius: 6px;
  box-sizing: border-box;
}

.custom-table__cell--label span,
.custom-table__cell--label p {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text-primary, #000000);
  margin: 0;
  flex-grow: 1;
}

/* Second column - Content cell */
.custom-table__cell--content {
  display: flex;
  align-items: center;
  flex-grow: 1;
  padding: 14px;
  background: rgba(240, 242, 245, 0.25);
  border-radius: 6px;
  box-sizing: border-box;
}

.custom-table__cell--content span,
.custom-table__cell--content p {
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary, #000000);
  margin: 0;
  flex-grow: 1;
}

/* Image inside content cell */
.custom-table__cell--content img {
  max-width: 64px;
  height: auto;
  border-radius: 0;
  object-fit: cover;
}

/* Dark mode styles for two column table */
html.dark .custom-table__cell--label {
  background: rgba(255, 255, 255, 0.08);
}

html.dark .custom-table__cell--content {
  background: #343a4080;
}

html.dark .custom-table__cell--label span,
html.dark .custom-table__cell--label p,
html.dark .custom-table__cell--content span,
html.dark .custom-table__cell--content p {
  color: var(--text-primary, #ffffff);
}

/* Responsive styles for two column table */
@media (max-width: 768px) {
  .custom-table__row {
    flex-direction: row;
  }

  .custom-table__cell--label {
    min-width: 100px;
    width: 100px;
    padding: 12px;
  }

  .custom-table__cell--content {
    flex: 1;
    padding: 12px;
  }

  .custom-table__cell--content img {
    max-width: 56px;
  }
}

@media (max-width: 480px) {
  .custom-table__cell--label {
    min-width: 90px;
    width: 90px;
    padding: 10px 12px;
  }

  .custom-table__cell--content {
    padding: 10px 12px;
  }

  .custom-table__cell--content img {
    max-width: 48px;
  }
}

/* ============================================
   THREE COLUMN TABLE (Equal Width Columns)
   ============================================ */

.custom-table-3col {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-radius: 6px;
  width: 100%;
  max-width: 684px;
}

.custom-table-3col__row {
  display: flex;
  flex-direction: row;
  gap: 2px;
}

/* Header row */
.custom-table-3col__row--header .custom-table-3col__cell {
  background: rgba(240, 242, 245, 0.55);
}

.custom-table-3col__row--header .custom-table-3col__cell span,
.custom-table-3col__row--header .custom-table-3col__cell p {
  font-weight: 600;
}

/* Body row */
.custom-table-3col__row--body .custom-table-3col__cell {
  background: rgba(240, 242, 245, 0.25);
}

/* Cell - equal width for all columns */
.custom-table-3col__cell {
  display: flex;
  align-items: center;
  flex: 1;
  min-height: 52px;
  padding: 14px;
  border-radius: 6px;
  box-sizing: border-box;
}

.custom-table-3col__cell span,
.custom-table-3col__cell p {
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary, #000000);
  margin: 0;
}

/* Dark mode styles for three column table */
html.dark .custom-table-3col__row--header .custom-table-3col__cell {
  background: rgba(255, 255, 255, 0.08);
}

html.dark .custom-table-3col__row--body .custom-table-3col__cell {
  background: #343a4080;
}

html.dark .custom-table-3col__cell span,
html.dark .custom-table-3col__cell p {
  color: var(--text-primary, #ffffff);
}

/* Responsive styles for three column table */
@media (max-width: 768px) {
  /* Hide header row on mobile */
  .custom-table-3col__row--header {
    display: none;
  }

  .custom-table-3col__row--body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    margin-bottom: 8px;
  }

  .custom-table-3col__row--body:last-child {
    margin-bottom: 0;
  }

  /* First cell (label) spans full width and acts as row header */
  .custom-table-3col__row--body .custom-table-3col__cell:first-child {
    grid-column: 1 / -1;
    background: rgba(240, 242, 245, 0.55);
    font-weight: 500;
  }

  html.dark .custom-table-3col__row--body .custom-table-3col__cell:first-child {
    background: rgba(255, 255, 255, 0.08);
  }

  /* Value cells */
  .custom-table-3col__row--body .custom-table-3col__cell:nth-child(2),
  .custom-table-3col__row--body .custom-table-3col__cell:nth-child(3) {
    position: relative;
    padding-top: 32px;
    min-height: auto;
  }

  /* Mobile labels for value cells */
  .custom-table-3col__row--body .custom-table-3col__cell:nth-child(2)::before,
  .custom-table-3col__row--body .custom-table-3col__cell:nth-child(3)::before {
    position: absolute;
    top: 10px;
    left: 14px;
    color: var(--text-secondary, #6b7280);
    font-weight: 400;
  }

  .custom-table-3col__row--body .custom-table-3col__cell:nth-child(2)::before {
    content: attr(data-label-min);
  }

  .custom-table-3col__row--body .custom-table-3col__cell:nth-child(3)::before {
    content: attr(data-label-max);
  }
}

@media (max-width: 480px) {
  .custom-table-3col__cell {
    padding: 12px;
  }

  .custom-table-3col__row--body .custom-table-3col__cell:nth-child(2),
  .custom-table-3col__row--body .custom-table-3col__cell:nth-child(3) {
    padding-top: 28px;
  }

  .custom-table-3col__row--body .custom-table-3col__cell:nth-child(2)::before,
  .custom-table-3col__row--body .custom-table-3col__cell:nth-child(3)::before {
    left: 12px;
    top: 8px;
    font-size: 16px;
  }
}

/* ============================================
   NATIVE HTML TABLE (inside post content)
   Matches .custom-table-3col design from Figma
   ============================================ */

.blog table {
  width: 100%;
  max-width: 684px;
  border-collapse: separate;
  border-spacing: 2px;
  border-radius: 6px;
  table-layout: auto;
}

/* All cells base styles */
.blog table th,
.blog table td {
  padding: 14px;
  border-radius: 6px;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary, #000000);
  box-sizing: border-box;
  vertical-align: middle;
  height: 52px;
  text-align: left;
  border: none;
}

/* Header row â€” thead th AND thead td (both get header style) */
.blog table thead th,
.blog table thead td {
  background: #f0f2f5e6;
}

/* Body row cells */
.blog table tbody td {
  background: rgba(240, 242, 245, 0.35);
  font-weight: 400;
}

/* Fallback: table without thead/tbody â€” th is header, td is body */
.blog table th {
  background: #f0f2f5e6;
}

.blog table td {
  background: rgba(240, 242, 245, 0.35);
}

/* Remove default paragraph margins inside cells (CMS may wrap content in <p>) */
.blog table th p,
.blog table td p {
  margin: 0;
}

/* Image inside table cell */
.blog table img {
  max-width: 64px;
  height: auto;
  border-radius: 0;
  object-fit: cover;
}

/* ---- Dark mode ---- */
html.dark .blog table thead th,
html.dark .blog table thead td {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary, #ffffff);
}

html.dark .blog table tbody td {
  background: rgba(52, 58, 64, 0.5);
  color: var(--text-primary, #ffffff);
}

html.dark .blog table th {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary, #ffffff);
}

html.dark .blog table td {
  background: rgba(52, 58, 64, 0.5);
  color: var(--text-primary, #ffffff);
}

.post-table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 6px;
}

.post-table-scroll > table {
  min-width: 480px;
}

@media (max-width: 768px) {
  .blog table th,
  .blog table td {
    height: auto;
    padding: 12px;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
}
