/***** Tables – Responsive System *****
 *  Visual style: Redmine 7.0 legacy (table.list with --oc-* variables)
 *  Responsive: labpro_init system (data-th, sticky headers, breakpoints)
 *  Dependencies: open-color.css (--oc-* variables)
 */

/* === BASE TABLE === */
table.labpro_responsive {
  text-rendering: optimizeLegibility;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  border-block-start: 1px solid var(--oc-gray-4);
  border-block-end: 1px solid var(--oc-gray-4);
  border-collapse: collapse;
  width: 100%;
  margin-block-end: 4px;
  overflow: visible;
  box-sizing: border-box;
}

table.labpro_responsive thead th {
  text-align: center;
  background-color: var(--oc-gray-2);
  padding: 4px;
  white-space: nowrap;
  font-weight: bold;
  border-block-end: 2px solid var(--oc-gray-4);
}

table.labpro_responsive td {
  text-align: center;
  vertical-align: middle;
  padding-block: 3px;
  padding-inline-start: 8px;
  padding-inline-end: 10px;
  border-block-start: 1px solid var(--oc-gray-4);
  font-weight: normal;
  box-sizing: border-box;
}

/* Column alignment variants */
table.labpro_responsive td.id { width: 2%; text-align: center; }
table.labpro_responsive td.name,
table.labpro_responsive td.description,
table.labpro_responsive td.subject,
table.labpro_responsive td.parent-subject,
table.labpro_responsive td.comments,
table.labpro_responsive td.roles,
table.labpro_responsive td.attachments,
table.labpro_responsive td.text,
table.labpro_responsive td.short_description { text-align: start; }

table.labpro_responsive td.estimated_hours,
table.labpro_responsive td.total_estimated_hours,
table.labpro_responsive td.estimated_remaining_hours,
table.labpro_responsive td.spent_hours,
table.labpro_responsive td.total_spent_hours { text-align: right; }

table.labpro_responsive td.tick { width: 15%; }
table.labpro_responsive td.checkbox,
table.labpro_responsive th.checkbox { width: 36px; padding-block: 2px 0; padding-inline: 6px; }
table.labpro_responsive .checkbox input { width: 18px; height: 18px; padding: 0; margin: 0; block-size: initial; box-sizing: border-box; }

/* Attachments */
table.labpro_responsive td.attachments span { display: block; block-size: 16px; }
table.labpro_responsive td.attachments span a.icon-download { visibility: hidden; }
table.labpro_responsive td.attachments span:hover a.icon-download { visibility: visible; }

/* Buttons column */
table.labpro_responsive td.buttons, div.buttons { white-space: nowrap; text-align: end; }
table.labpro_responsive td.buttons a,
div.buttons a,
table.labpro_responsive td.buttons span.icon-only { margin-inline-end: 0.6em; }
table.labpro_responsive td.buttons a:last-child,
div.buttons a:last-child { margin-inline-end: 0; }
table.labpro_responsive td.buttons img,
div.buttons img { vertical-align: middle; }

/* Reorder */
table.labpro_responsive td.reorder { width: 15%; white-space: nowrap; text-align: center; }

/* Progress inside tables */
table.labpro_responsive table.progress td { padding-inline-end: 0; border-block-start: none; height: 0.5rem; vertical-align: middle; }

/* Caption */
table.labpro_responsive caption { text-align: start; padding-block: 0.5em; padding-inline: 0 0.5em; }

/* Overdue */
table.labpro_responsive tr.overdue td.due_date { color: var(--oc-red-9); }

/* Enumerations */
table.labpro_responsive.enumerations { table-layout: fixed; margin-block-end: 2em; }

/* Group rows */
table.labpro_responsive tr.group td {
  padding-block: 0.8em 0.5em;
  padding-inline: 0.3em 0;
  border-block-end: 2px solid var(--oc-gray-4);
  text-align: start;
  background-color: var(--oc-white);
}
table.labpro_responsive tr.group span.name { font-weight: bold; }
table.labpro_responsive tr.group span.count { inset-block-start: -1px; }
table.labpro_responsive tr.group span.totals { color: var(--oc-gray-5); font-size: 93%; }
table.labpro_responsive tr.group span.totals .value { font-weight: bold; color: var(--oc-gray-6); }
table.labpro_responsive tr.group a.toggle-all { color: var(--oc-gray-5); font-size: 93%; display: none; float: inline-end; margin-inline-end: 4px; }
table.labpro_responsive tbody tr.group:hover { background-color: inherit; }
table.labpro_responsive tr.group:hover a.toggle-all { display: inline; }

/* Striped rows (legacy Redmine) */
table.labpro_responsive:not(.odd-even) tbody tr:nth-child(odd),
.odd { background-color: var(--oc-white); }
table.labpro_responsive:not(.odd-even) tbody tr:nth-child(even),
.even { background-color: var(--oc-gray-0); }

/* Hover (legacy Redmine) */
table.labpro_responsive:not(.odd-even) tbody tr:nth-child(odd):hover,
.odd:hover,
table.labpro_responsive:not(.odd-even) tbody tr:nth-child(even):hover,
.even:hover { background-color: var(--oc-yellow-0); }

/* === STICKY HEADERS === */
.labpro_responsive thead tr:last-child th {
  position: sticky;
  top: -2px;
  z-index: 2;
}
.labpro_responsive tr.group td {
  position: sticky;
  top: 0px;
}
.labpro_responsive tr.group td::after,
.labpro_responsive thead tr:last-child th::after {
  border-bottom: 1px solid var(--oc-gray-4);
  content: '';
  position: absolute;
  width: 100%;
  bottom: -1px;
  left: 0;
}

/* === RESPONSIVE: MOBILE ≤ 600px === */
@media screen and (max-width: 600px) {
  table.labpro_responsive caption { background-image: none; }
  table.labpro_responsive thead { display: none; }
  table.labpro_responsive tbody td { display: block; padding: 0.6rem; }
  table.labpro_responsive tbody tr td:first-child { background: var(--oc-gray-2); color: var(--oc-gray-9); }
  table.labpro_responsive tbody td:before {
    content: attr(data-th);
    font-weight: bold;
    display: inline-block;
    float: left;
  }
}

/* === RESPONSIVE: TABULAR VARIANT (≤ 899px) === */
@media screen and (max-width: 899px) {
  table.labpro_responsive.tabular tbody td:not(:first-child) {
    position: relative;
    padding-left: 45%;
  }
  table.labpro_responsive.tabular tbody td:not(:first-child)::before {
    position: absolute;
    left: 0;
    width: 45%;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  table.labpro_responsive.tabular tbody td:not(:first-child) {
    text-align: left;
    margin-left: 10px;
  }
  table.labpro_responsive.tabular tbody td:after { content: '\00a0'; }
}

/* === AVATAR INSIDE TABLE === */
table.labpro_responsive avatar {
  vertical-align: middle;
  border-top: 4px solid var(--oc-gray-4);
  border-bottom: 4px solid var(--oc-gray-4);
}

/* === LABPRO FRONT TABLE === */
.labpro_front_table {
  border-collapse: collapse;
  background-color: transparent;
  font-family: var(--fonts-main, Arial, sans-serif);
  font-size: 14px;
  width: 100%;
  margin-inline: 4px;
}
.labpro_front_table th {
  font-weight: bold;
  text-align: center;
  padding: 4px 10px;
  background-color: var(--oc-gray-2);
}
.labpro_front_table tbody td {
  text-align: center;
  padding: 8px;
}
.labpro_front_table tbody tr:hover td {
  background-color: rgba(0, 255, 255, 0.1);
  border-radius: 50px;
}
.labpro_front_table tbody td:first-child {
  text-align: left;
  padding: 8px;
  padding-left: 24px;
  display: flex;
  align-items: flex-start;
}
.labpro_front_table tbody td:first-child a {
  display: flex;
  flex-direction: column;
  font-weight: bold;
}
