/* =====================================================================
   SRTTS fit.css  -  everything on screen, no sideways scrolling.
   Loaded after mono.css (see includes/header.php).

   Rules of this file
   1. Tables never get a horizontal scrollbar. Long text wraps inside its cell.
   2. When a table is too wide for the space it has, each row becomes a card
      (label on the left, value on the right) instead of scrolling.
   3. Nothing here sets colours except through the mono theme tokens.
   ===================================================================== */

/* ---------- 1. No sideways scrollbar anywhere in the app ---------- */
body.page-app .table-responsive { overflow-x: visible; }
body.page-app .app-content,
body.page-app .app-main { min-width: 0; max-width: 100%; }
body.page-app .app-content img,
body.page-app .app-content svg,
body.page-app .app-content video { max-width: 100%; }
body.page-app .app-content pre { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- 2. Compact tables that wrap instead of stretching ---------- */
body.page-app .data-table { width: 100%; table-layout: auto; }
body.page-app .data-table th,
body.page-app .data-table td { padding: 10px 8px; overflow-wrap: anywhere; }
body.page-app .data-table th { white-space: normal; overflow-wrap: normal; word-break: normal; hyphens: manual; }
body.page-app .data-table th:first-child,
body.page-app .data-table td:first-child { padding-left: 14px; }
body.page-app .data-table th:last-child,
body.page-app .data-table td:last-child { padding-right: 14px; }
body.page-app .data-table .badge { white-space: nowrap; }

/* Requests table (admin and staff): ticket number on two short lines, title wraps */
body.page-app .data-table.tt-table th,
body.page-app .data-table.tt-table td { padding: 10px 6px; }
body.page-app .data-table.tt-table th:first-child,
body.page-app .data-table.tt-table td:first-child { padding-left: 12px; }
body.page-app .data-table.tt-table th:last-child,
body.page-app .data-table.tt-table td:last-child { padding-right: 12px; }
body.page-app .tt-tkt { white-space: normal; }
body.page-app .tt-tkt-no { display: flex; flex-direction: column; line-height: 1.2; }
body.page-app .tt-tkt-prefix { font-size: 11px; white-space: nowrap; }
body.page-app .tt-tkt-id { white-space: nowrap; }
body.page-app .tt-subject { max-width: none; overflow-wrap: anywhere; }
body.page-app .tt-unassigned { white-space: normal; padding: 1px 8px; }
body.page-app .data-table.tt-table td.actions-cell { white-space: nowrap; }
body.page-app .tt-icon-btn { width: 30px; height: 30px; }
body.page-app .tt-actions { gap: 2px; }
body.page-app .tt-sort { margin: 0; padding: 2px 0; }

/* ---------- 3. Card mode: rows become cards when the table cannot fit ---------- */
/* Generic tables (audit logs, reports, categories, ...) below 1100px */
@media (max-width: 1100px) {
  body.page-app .data-table:not(.users-table):not(.tt-table) thead { display: none; }
  body.page-app .data-table:not(.users-table):not(.tt-table),
  body.page-app .data-table:not(.users-table):not(.tt-table) tbody,
  body.page-app .data-table:not(.users-table):not(.tt-table) tr,
  body.page-app .data-table:not(.users-table):not(.tt-table) td { display: block; width: 100%; }
  body.page-app .data-table:not(.users-table):not(.tt-table) tr {
    margin-bottom: 12px; overflow: hidden;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  }
  body.page-app .data-table:not(.users-table):not(.tt-table) td {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
    text-align: right; padding: 9px 14px; border-bottom: 1px solid var(--border);
    background: transparent;
  }
  body.page-app .data-table:not(.users-table):not(.tt-table) td:last-child { border-bottom: 0; }
  body.page-app .data-table:not(.users-table):not(.tt-table) td::before {
    content: attr(data-label); flex: 0 0 38%; text-align: left;
    font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted);
  }
}

/* Requests table needs more room, so it becomes cards a little earlier */
@media (max-width: 1320px) {
  body.page-app .data-table.tt-table thead { display: none; }
  body.page-app .data-table.tt-table,
  body.page-app .data-table.tt-table tbody,
  body.page-app .data-table.tt-table tr,
  body.page-app .data-table.tt-table td { display: block; width: 100%; }
  body.page-app .data-table.tt-table tr {
    margin-bottom: 12px; overflow: hidden;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  }
  body.page-app .data-table.tt-table td {
    display: flex; justify-content: space-between; align-items: center; gap: 16px;
    text-align: right; padding: 9px 14px; border-bottom: 1px solid var(--border); background: transparent;
  }
  body.page-app .data-table.tt-table td:last-child { border-bottom: 0; }
  body.page-app .data-table.tt-table td::before {
    content: attr(data-label); flex: 0 0 38%; text-align: left;
    font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted);
  }
  body.page-app .data-table.tt-table td.tt-col-check { padding: 10px 14px 0; justify-content: flex-start; }
  body.page-app .data-table.tt-table td.tt-col-check::before { display: none; }
  body.page-app .data-table.tt-table td.actions-cell { width: 100%; }
  body.page-app .tt-tkt-no { flex-direction: row; gap: 4px; align-items: baseline; }
  body.page-app .tt-copy { opacity: .7; }
  body.page-app .tt-icon-btn { width: 36px; height: 36px; }
}

/* ---------- 4. Phones: action buttons wrap instead of running off the card ---------- */
@media (max-width: 1320px) {
  body.page-app .data-table td { flex-wrap: wrap; }
  body.page-app .data-table td form { display: inline-flex; max-width: 100%; }
}
@media (max-width: 768px) {
  body.page-app .data-table td { flex-wrap: wrap; row-gap: 6px; }
  body.page-app .data-table td .btn,
  body.page-app .data-table td .tt-actions { flex-wrap: wrap; justify-content: flex-end; }
  body.page-app .data-table td[data-label="Actions"] { justify-content: flex-end; }
}

/* ---------- 5. Staff and student dashboard tables (.dx-table): cards below 1280px ---------- */
@media (max-width: 1280px) {
  .dx-panel--table { background: transparent; border: 0; border-radius: 0; }
  .dx-panel--table .dx-panel-head { padding: 0 0 12px; }
  .dx-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .dx-table, .dx-table tbody, .dx-table tr, .dx-table td { display: block; width: 100%; }
  .dx-table tr {
    margin-bottom: 12px; padding: 10px 16px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  }
  .dx-table td { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; padding: 6px 0; border: 0; }
  .dx-table td::before { content: attr(data-label); font-size: .8125rem; font-weight: 600; color: var(--text-muted); padding-top: 2px; }
  .dx-table td.col-act { display: block; padding-top: 10px; text-align: left; white-space: normal; }
  .dx-table td.col-act::before { content: none; }
  .dx-table .col-act .btn { width: 100%; }
  .dx-table td .badge { justify-self: start; }
  .dx-scroll { overflow-x: visible; }
}
