/* ==========================================================================
   KNEST Tenders table — CAK-style columns + e-GP ID, brand-themed, responsive.
   Desktop (>1100px): a clean table. Phones and tablets (<=1100px): each row
   becomes a card (two per row on tablets).
   ========================================================================== */

/* A wider measure than the standard wide container (1320px): a 7-column
   data table needs the room, and the masthead above still aligns to the
   normal grid. Together with the column rules below, the table fits
   without horizontal scrolling from ~1150px viewports up. */
.tenders-container { max-width: 1440px; }

.tenders-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  -webkit-overflow-scrolling: touch;
}
.tenders-table-wrap:focus-visible { outline: var(--focus-ring); outline-offset: 2px; }

.tenders-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-400);
}

/* Headers may wrap onto two lines ("Tender Closing / Date") rather than
   forcing their column wider than its content needs. */
.tenders-table thead th {
  background: var(--brand);
  color: var(--on-brand);
  font-weight: 700;
  text-align: left;
  vertical-align: bottom;
  padding: var(--sp-3);
  line-height: 1.25;
  font-size: var(--fs-300);
  letter-spacing: .02em;
}

.tenders-table tbody td {
  padding: var(--sp-4) var(--sp-3);
  border-top: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.5;
}
/* Desktop table only. At 1100px and below rows become cards (see the end of file). */
@media (min-width: 1101px) {
  .tenders-table thead th:first-child,
  .tenders-table tbody td:first-child { padding-left: var(--sp-5); }
  .tenders-table thead th:last-child,
  .tenders-table tbody td:last-child { padding-right: var(--sp-5); }

  /* Column proportions: the description and notes get the room to wrap
     comfortably; codes, tags and dates stay compact. */
  .tenders-table thead th:nth-child(1) { width: 20%; min-width: 9.5rem; }
  .tenders-table thead th:nth-child(5) { width: 22%; min-width: 12rem; }
  .tenders-table thead th:nth-child(7) { min-width: 9rem; }
}

.tenders-table tbody tr:nth-child(even) { background: var(--surface); }
.tenders-table tbody tr:hover { background: var(--green-050); }
.tenders-table tbody tr.is-closed td { color: var(--text-muted); }
/* Closed rows read as past, but every word stays AA: muted colour, no
   opacity (which was pushing links and IDs down to ~2:1). */
.tenders-table tbody tr.is-closed .tender-egp { color: var(--muted); }
.tenders-table tbody tr.is-closed .tender-download,
.tenders-table tbody tr.is-closed .tender-link { color: var(--muted); }

.tender-ref { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: var(--fs-200, .76rem); letter-spacing: -0.01em; white-space: nowrap; }

/* Eligibility tags */
.tender-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: var(--fs-200, .72rem);
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
  background: var(--green-050);
  color: var(--brand);
  border: 1px solid currentColor;
}
.tender-tag--open-to-all { color: var(--green-ink); }
.tender-tag--women       { color: var(--accent-ink); }
.tender-tag--youth       { color: var(--knest-green); }
.tender-tag--pwd         { color: var(--ink-soft); }

/* Addendum links wrap (they were nowrap, which alone made the "Additional
   Information" column ~340px wide and pushed the table into a scroll). */
.tender-link {
  display: inline;
  font-weight: 700;
  color: var(--accent-ink);
  text-decoration: none;
  line-height: 1.4;
}
.tender-download { white-space: nowrap; }
.tender-link:hover { text-decoration: underline; }
.tender-size { font-size: var(--fs-200, .72rem); color: var(--text-muted); font-weight: 400; white-space: nowrap; }

.tender-egp { font-weight: 700; color: var(--brand); white-space: nowrap; }
.tender-dash { color: var(--text-muted); }
.tender-label { display: none; }   /* shown only in the card layout (≤1100px) */

/* Closing date on one line, time beneath it — instead of the single
   "30th June 2026, 10:00 AM" string breaking mid-phrase. */
.tender-closing-date { display: block; font-size: var(--fs-300); font-weight: 600; color: var(--ink); line-height: 1.35; }
.tender-closing-time { display: block; font-size: var(--fs-300); color: var(--text-muted); line-height: 1.35; }
.tenders-table tbody tr.is-closed .tender-closing-date { color: var(--text-muted); }

.tender-closed-badge {
  display: block;
  width: fit-content;
  margin-top: 5px;
  padding: 2px 8px; border-radius: var(--r-pill);
  background: var(--surface-3); color: var(--muted);
  font-size: var(--fs-200, .72rem); font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em;
}

/* ---- Filament-style paginator (brand green) ---- */
.tpager {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-top: var(--sp-4);
  padding: var(--sp-2) 0;
  font-size: var(--fs-300);
  flex-wrap: wrap;
}
.tpager__left {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-right: auto;
}
.tpager__label {
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}
.tpager__select {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 4px 8px;
  font-size: var(--fs-300);
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}
.tpager__select:focus { outline: var(--focus-ring); outline-offset: 2px; }
.tpager__info {
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 500;
}
.tpager__nav {
  display: flex;
  align-items: center;
  gap: 4px;
}
.tpager__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 var(--sp-2);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--brand);
  font-size: var(--fs-300);
  font-weight: 500;
  text-decoration: none;
  line-height: 1;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.tpager__btn:hover:not(.is-active):not(.is-disabled) {
  background: var(--green-050);
  border-color: var(--brand);
}
.tpager__btn.is-active {
  background: var(--brand);
  color: var(--on-brand);
  border-color: var(--brand);
  pointer-events: none;
}
.tpager__btn.is-disabled {
  opacity: .35;
  pointer-events: none;
}
.tpager__ellipsis {
  display: inline-flex;
  align-items: center;
  padding: 0 var(--sp-1);
  color: var(--text-muted);
  user-select: none;
}
@media (max-width: 720px) {
  .tpager { flex-direction: column; align-items: flex-start; }
  .tpager__left { margin-right: 0; }
}

.tenders-empty {
  padding: var(--sp-6); text-align: center;
  border: 1px dashed var(--border); border-radius: var(--r-lg);
  color: var(--text-muted);
}

/* ---- Phones and tablets: rows become cards ----
   Up to 1100px the 7-column table would need sideways scrolling (worse in
   Kiswahili, whose headers and dates run longer), so it becomes cards. */
@media (max-width: 1100px) {
  .tenders-table-wrap { border: none; overflow: visible; }
  .tenders-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tenders-table, .tenders-table tbody, .tenders-table tr, .tenders-table td { display: block; width: 100%; }
  .tenders-table tr {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    margin-bottom: var(--sp-4);
    padding: var(--sp-2);
    background: var(--surface);
  }
  .tenders-table tbody tr:nth-child(even) { background: var(--surface); }
  .tenders-table td {
    border: none;
    padding: var(--sp-2) var(--sp-3);
    display: flex; justify-content: space-between; gap: var(--sp-4);
    text-align: right;
  }
  /* Field labels are real text (not CSS content) so the site translator
     can translate them along with the values. */
  .tenders-table .tender-label {
    display: block;
    font-weight: 700;
    color: var(--brand);
    text-align: left;
    font-size: var(--fs-300);
  }
  .tenders-table td[data-label="Tender Description"] {
    flex-direction: column; text-align: left;
    border-bottom: 1px solid var(--border); padding-bottom: var(--sp-3);
  }
  /* Addenda: one block beside the label, so links and sizes wrap inside it
     instead of each becoming a side-by-side flex item off the card edge. */
  .tender-addl { min-width: 0; overflow-wrap: anywhere; }
}

/* Download icon link (Tender Document + uploaded Additional Info) */
.tender-download {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 700; color: var(--accent-ink);   /* text-safe orange: brand orange is 2.7:1 on white */
  text-decoration: none; white-space: nowrap;
}
.tender-download:hover { text-decoration: underline; }
.tender-download svg { flex-shrink: 0; }
.tender-info-text { display: inline-block; line-height: 1.5; }

/* Kiswahili column headers are longer; a touch smaller keeps the header row
   to two lines like English. */
html[lang="sw"] .tenders-table thead th { font-size: 0.74rem; letter-spacing: 0; }

/* ---- Card layout (<=1100px): label | value grid ----
   Each cell's content sits in one .tender-cell wrapper, so long notes and
   addendum links wrap inside the value column instead of laying out as
   separate flex items in a single row (which pushed the page 174px wide). */
@media (max-width: 1100px) {
  .tenders-table td {
    display: grid;
    grid-template-columns: minmax(6.5rem, 38%) minmax(0, 1fr);
    column-gap: var(--sp-4);
    align-items: start;
  }
  .tenders-table .tender-label { grid-column: 1; }
  .tender-cell { grid-column: 2; min-width: 0; text-align: right; overflow-wrap: anywhere; }
  .tender-cell .tender-closed-badge { margin-left: auto; }
  .tender-cell .tender-link,
  .tender-cell .tender-size { white-space: normal; }
  .tenders-table td[data-label="Tender Description"] { grid-template-columns: minmax(0, 1fr); }
  .tenders-table td[data-label="Tender Description"] .tender-cell { grid-column: 1; text-align: left; }
}

/* Tablets: two cards per row */
@media (min-width: 721px) and (max-width: 1100px) {
  .tenders-table tbody { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
  .tenders-table tr { margin-bottom: 0; }
}
