/**
 * @file content-table.css
 * The signature content listing table — modern zebra/hover styles.
 * Columns: साहित्य प्रकार | शीर्षक | लेखक | प्रतिक्रिया
 */

/* ── Table Wrapper ────────────────────────────────────────────────────────── */
.mp-content-table-wrapper {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--mp-radius-lg);
  box-shadow: var(--mp-table-shadow);
  border: 1px solid var(--mp-table-border);
  background: var(--mp-bg-card);
  -webkit-overflow-scrolling: touch;
}

/* ── Table Base ───────────────────────────────────────────────────────────── */
.mp-content-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--mp-text-sm);
  table-layout: auto;
}

/* ── Table Header ─────────────────────────────────────────────────────────── */
.mp-content-table thead th {
  background: var(--mp-table-header-bg);
  color: var(--mp-table-header-text);
  font-weight: 700;
  font-size: var(--mp-text-sm);
  letter-spacing: var(--mp-tracking-wide);
  padding: var(--mp-space-3) var(--mp-space-5);
  text-align: left;
  white-space: nowrap;
  border-bottom: 2px solid var(--mp-primary);
  position: relative;
}

/* Sortable column indicator */
.mp-content-table thead th a {
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--mp-space-2);
}

.mp-content-table thead th a::after {
  content: '⇅';
  font-size: 0.8em;
  opacity: 0.5;
}

.mp-content-table thead th.is-active a::after {
  content: '↓';
  opacity: 1;
  color: var(--mp-accent);
}

/* First and last header cell radius */
.mp-content-table thead th:first-child {
  border-radius: var(--mp-radius-lg) 0 0 0;
}

.mp-content-table thead th:last-child {
  border-radius: 0 var(--mp-radius-lg) 0 0;
}

/* ── Table Body ───────────────────────────────────────────────────────────── */
.mp-content-table tbody tr {
  border-bottom: 1px solid var(--mp-table-border);
  transition: background-color var(--mp-transition-fast),
              transform var(--mp-transition-fast);
}

/* Zebra striping */
.mp-content-table tbody tr:nth-child(odd) {
  background: var(--mp-table-row-odd);
}

.mp-content-table tbody tr:nth-child(even) {
  background: var(--mp-table-row-even);
}

/* Hover effect */
.mp-content-table tbody tr:hover {
  background: var(--mp-table-row-hover);
  transform: translateX(2px);
  box-shadow: inset 4px 0 0 var(--mp-primary);
}

/* Last row — remove bottom border for clean edge */
.mp-content-table tbody tr:last-child {
  border-bottom: none;
}

/* ── Table Cells ──────────────────────────────────────────────────────────── */
.mp-content-table td,
.mp-content-table th {
  padding: var(--mp-space-3) var(--mp-space-5);
  vertical-align: middle;
  border-right: 1px solid var(--mp-border-light);
}

.mp-content-table td:last-child,
.mp-content-table th:last-child {
  border-right: none;
}

/* ── Column Widths ────────────────────────────────────────────────────────── */
/* साहित्य प्रकार (Content Type) */
.mp-content-table .views-field-type,
.mp-content-table .col-type {
  width: 15%;
  min-width: 110px;
}

/* शीर्षक (Title) */
.mp-content-table .views-field-title,
.mp-content-table .col-title {
  width: 55%;
}

/* लेखक (Author) */
.mp-content-table .views-field-name,
.mp-content-table .col-author {
  width: 18%;
  min-width: 100px;
}

/* प्रतिक्रिया (Comments) */
.mp-content-table .views-field-comment-count,
.mp-content-table .col-comments {
  width: 12%;
  min-width: 80px;
  text-align: center;
}

/* ── Cell Styles ──────────────────────────────────────────────────────────── */
/* Content type badge */
.mp-content-table .views-field-type span,
.mp-type-badge {
  display: inline-block;
  padding: 2px var(--mp-space-2);
  background: var(--mp-primary-50);
  color: var(--mp-primary);
  border-radius: var(--mp-radius-full);
  font-size: var(--mp-text-xs);
  font-weight: 600;
  white-space: nowrap;
}

/* Title link */
.mp-content-table .views-field-title a {
  color: var(--mp-secondary);
  font-weight: 600;
  line-height: var(--mp-leading-snug);
  display: block;
}

.mp-content-table .views-field-title a:hover {
  color: var(--mp-primary);
  text-decoration: none;
}

/* Author */
.mp-content-table .views-field-name a {
  color: var(--mp-text-secondary);
  font-weight: 500;
  font-size: var(--mp-text-sm);
}

.mp-content-table .views-field-name a:hover {
  color: var(--mp-primary);
}

/* Comment count — pill style */
.mp-comment-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 var(--mp-space-2);
  background: var(--mp-bg-alt);
  color: var(--mp-text-secondary);
  border-radius: var(--mp-radius-full);
  font-size: var(--mp-text-xs);
  font-weight: 700;
  border: 1px solid var(--mp-border);
}

.mp-comment-count.has-comments {
  background: var(--mp-primary-50);
  color: var(--mp-primary);
  border-color: var(--mp-primary-100);
}

/* ── Table Caption / Title ────────────────────────────────────────────────── */
.mp-content-table caption {
  caption-side: top;
  padding: var(--mp-space-4) var(--mp-space-5);
  font-size: var(--mp-text-xl);
  font-weight: 700;
  color: var(--mp-secondary);
  text-align: left;
  background: var(--mp-bg-alt);
  border-radius: var(--mp-radius-lg) var(--mp-radius-lg) 0 0;
  border-bottom: 1px solid var(--mp-border);
}

/* ── Responsive: Collapse on Small Screens ────────────────────────────────── */
@media (max-width: 575.98px) {
  .mp-content-table thead {
    display: none; /* hide headers, show as data-label */
  }

  .mp-content-table,
  .mp-content-table tbody,
  .mp-content-table tr,
  .mp-content-table td {
    display: block;
    width: 100%;
  }

  .mp-content-table tr {
    margin-bottom: var(--mp-space-3);
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius);
    overflow: hidden;
    box-shadow: var(--mp-shadow-sm);
    transform: none !important;
  }

  .mp-content-table tr:hover {
    box-shadow: var(--mp-shadow);
    transform: none !important;
  }

  .mp-content-table td {
    padding: var(--mp-space-2) var(--mp-space-4);
    border-right: none;
    border-bottom: 1px solid var(--mp-border-light);
    display: flex;
    align-items: center;
    gap: var(--mp-space-3);
  }

  .mp-content-table td:last-child { border-bottom: none; }

  .mp-content-table td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: var(--mp-text-xs);
    color: var(--mp-text-muted);
    min-width: 80px;
    flex-shrink: 0;
  }

  /* Title cell — full width, more prominent */
  .mp-content-table .views-field-title {
    flex-direction: column;
    align-items: flex-start;
    padding: var(--mp-space-3) var(--mp-space-4);
    background: var(--mp-bg-alt);
  }

  .mp-content-table .views-field-title::before { display: none; }

  .mp-content-table .views-field-type { width: 100%; }
  .mp-content-table .views-field-name { width: 100%; }
  .mp-content-table .views-field-comment-count { width: 100%; }
}
