/* ============================================
   Table Styling for Better Column Distribution
   Fixes squished columns in differential diagnosis tables
   ============================================ */

/* Main table styling - use fixed layout for equal column widths */
table,
table.table,
table.caption-top {
  table-layout: fixed !important;
  width: 100% !important;
  border-collapse: collapse !important;
  margin: 1.5em 0;
  font-size: 0.92em;
  line-height: 1.6;
}

/* Prevent text squishing - all cells */
table td,
table th,
table.table td,
table.table th,
table.caption-top td,
table.caption-top th {
  padding: 12px 14px !important;
  vertical-align: top !important;
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
  hyphens: auto !important;
  white-space: normal !important;
}

/* Header cells */
table th {
  font-weight: 600;
  background-color: #f8f9fa;
  border: 1px solid #1C7C54;
  border-bottom: 2px solid #1C7C54;
  text-align: left;
}

/* Body cells */
table td {
  border: 1px solid #dee2e6;
}

/* ============================================
   Column Width Distribution
   Handled by table-layout: fixed and JS cleanup
   to ensure equal distribution for all tables.
   ============================================ */


/* ============================================
   List Items Within Table Cells
   ============================================ */

table td ul,
table td ol {
  margin: 0;
  padding-left: 1.2em;
  list-style-position: outside;
}

table td li {
  margin-bottom: 0.35em;
  line-height: 1.5;
}

/* Remove bottom margin from last list item */
table td li:last-child {
  margin-bottom: 0;
}

/* ============================================
   Zebra Striping for Readability
   ============================================ */

table tbody tr:nth-child(odd) {
  background-color: rgba(0, 0, 0, 0.02);
}

table tbody tr:hover {
  background-color: rgba(28, 124, 84, 0.05);
  transition: background-color 0.2s ease;
}

/* ============================================
   Typography in Tables
   ============================================ */

/* Bold text shouldn't cause overflow */
table strong,
table b {
  font-weight: 600;
  word-break: normal;
}

/* Code in tables */
table code {
  white-space: normal;
  word-break: break-word;
  background-color: rgba(0, 0, 0, 0.05);
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 0.9em;
}

/* Em/italics */
table em,
table i {
  font-style: italic;
}

/* ============================================
   Responsive Design
   ============================================ */

/* Tablet - slightly reduce padding */
@media screen and (max-width: 992px) {
  table {
    font-size: 0.88em;
  }

  table td,
  table th {
    padding: 10px 12px !important;
  }
}

/* Mobile - even smaller text and padding */
@media screen and (max-width: 768px) {
  table {
    font-size: 0.82em;
  }

  table td,
  table th {
    padding: 8px 10px !important;
  }
}

/* Very small screens - enable horizontal scroll */
@media screen and (max-width: 600px) {
  /* Wrap table in scrollable container */
  .page-columns .column-body {
    overflow-x: auto;
  }

  table {
    min-width: 600px; /* Prevent extreme compression */
    display: table;
  }
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
  table {
    page-break-inside: avoid;
    font-size: 0.85em;
  }

  table td,
  table th {
    padding: 8px 10px !important;
  }

  /* Ensure zebra stripes print */
  table tbody tr:nth-child(odd) {
    background-color: #f5f5f5 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
