/**
 * Tenders module
 * -------------------------------------------------------------------------
 * Loaded only on the tender listing, after bcc-pages.css which supplies the
 * shared hero, headings and CTA shell.
 *
 * Tenders have no page of their own — the listing row is the whole record — so
 * this file covers the search box, the dashboard table and the archive only.
 *
 * Built from the existing tokens (--color-primary, --color-title, --bcc-cream,
 * --bcc-line, Gantari / Inter). Red stays an accent: status pills, the request
 * button, rules and icons.
 */

/* ================================================================== board */

.tender-board {
  background: var(--color-white);
  padding: 100px 0;
}

.tender-board__head {
  max-width: 760px;
  margin-bottom: 46px;
}

.tender-board__disc {
  color: var(--color-body);
  font-size: 16px;
  line-height: 1.8;
  margin: 0;
}

/* ================================================================= search */

.tender-search {
  margin-bottom: 22px;
}

.tender-search__field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 560px;
  padding: 0 16px;
  border: 1px solid var(--bcc-line);
  border-radius: 6px;
  background: var(--color-white);
  transition: border-color var(--transition) ease, box-shadow var(--transition) ease;
}

.tender-search__field:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(137, 0, 0, 0.08);
}

.tender-search__field > i {
  color: var(--color-primary);
  font-size: 15px;
  flex: 0 0 auto;
}

.tender-search__field input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 14px 0;
  font-family: "Inter", serif;
  font-size: 15px;
  color: var(--bcc-ink);
}

.tender-search__field input::placeholder {
  color: #A2A2A2;
}

/* The browser's own clear affordance would sit alongside ours. */
.tender-search__field input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.tender-search__clear {
  flex: 0 0 auto;
  appearance: none;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #F0EEEC;
  color: var(--color-body);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--transition) ease, color var(--transition) ease;
}

.tender-search__clear:hover {
  background: var(--color-primary);
  color: var(--color-white);
}

.tender-search__count {
  margin: 12px 0 0;
  font-family: "Inter", serif;
  font-size: 13px;
  color: var(--color-body);
}

.tender-search__count:empty {
  display: none;
}

.tender-empty--search {
  margin-top: 0;
}

/* ================================================================== table */

/*
 * A CSS grid rather than a <table>, so the same markup can be four columns on
 * desktop and stacked labelled rows on a phone. Roles are set in the markup so
 * it is still announced as a table.
 */
.tender-table {
  border: 1px solid var(--bcc-line);
  border-radius: 8px;
  overflow: hidden;
}

/*
 * Two columns: the tender on the left (heading, brief, tags) and its state on
 * the right (status, closing date, action). A fixed right column keeps the
 * status pills and buttons aligned down the page regardless of how long each
 * brief runs.
 */
.tender-table__head,
.tender-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 32px;
  align-items: start;
}

.tender-table__head {
  background: var(--bcc-ink);
  padding: 16px 26px;
}

.tender-table__head span {
  font-family: "Inter", serif;
  font-size: 12px;
  font-weight: var(--p-bold);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}

.tender-row {
  padding: 26px;
  border-top: 1px solid var(--bcc-line);
  transition: background var(--transition) ease;
}

.tender-table__head + .tender-row {
  border-top: 0;
}

.tender-row:hover {
  background: var(--bcc-cream);
}

/* ------------------------------------------------------------- left column */

.tender-row__title {
  display: block;
  font-family: "Gantari", serif;
  font-size: 19px;
  line-height: 1.35;
  font-weight: var(--s-bold);
  color: var(--bcc-ink);
}

/* Reference and location read as one line of identifiers under the heading. */
.tender-row__ident {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  margin-top: 10px;
}

.tender-row__ident:empty {
  display: none;
}

.tender-row__ref {
  font-family: "Inter", serif;
  font-size: 12px;
  font-weight: var(--p-bold);
  letter-spacing: 0.08em;
  color: var(--color-primary);
  padding: 3px 9px;
  border: 1px solid rgba(137, 0, 0, 0.22);
  border-radius: 3px;
}

.tender-row__meta {
  font-size: 13px;
  color: var(--color-body);
}

.tender-row__meta i {
  color: var(--color-primary);
  margin-right: 5px;
}

/* The brief is the whole record now, so line breaks in it are preserved and
   it needs room to breathe. */
.tender-row__disc {
  color: var(--color-body);
  font-size: 15px;
  line-height: 1.75;
  margin: 16px 0 0;
}

.tender-row__disc--muted {
  color: #A2A2A2;
  font-style: italic;
}

.tender-row__dates {
  margin: 12px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  font-size: 13px;
  color: var(--color-body);
}

.tender-row__dates strong {
  color: var(--bcc-ink);
  font-weight: var(--p-semi-bold);
}

/* ------------------------------------------------------------ right column */

/* Status, closing date, then the action stacked beneath. */
.tender-row__cell--side {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
}

.tender-row__due {
  display: block;
  font-family: "Gantari", serif;
  font-size: 15px;
  font-weight: var(--s-semi-bold);
  line-height: 1.5;
  color: var(--bcc-ink);
}

.tender-row__due-label {
  display: block;
  margin-bottom: 3px;
  font-family: "Inter", serif;
  font-size: 10px;
  font-weight: var(--p-bold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #9A9A9A;
}

.tender-row__cell--side .tender-btn {
  width: 100%;
}

.tender-row__closed {
  font-size: 13px;
  color: #A2A2A2;
  font-style: italic;
}

/* ============================================================ status pill */

.tender-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 4px;
  font-family: "Inter", serif;
  font-size: 11px;
  font-weight: var(--p-bold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.tender-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.tender-status.is-open {
  background: rgba(62, 183, 94, 0.12);
  color: #2C8F47;
}

.tender-status.is-closing {
  background: rgba(255, 143, 60, 0.14);
  color: #C96A1B;
}

.tender-status.is-closed {
  background: #F0EEEC;
  color: #7A7A7A;
}

.tender-status.is-awarded {
  background: rgba(137, 0, 0, 0.09);
  color: var(--color-primary);
}

/* ==================================================================== tags */

.tender-row__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.tender-tag {
  padding: 4px 11px;
  border: 1px solid var(--bcc-line);
  border-radius: 3px;
  background: var(--color-white);
  font-family: "Inter", serif;
  font-size: 12px;
  font-weight: var(--p-medium);
  color: var(--color-body);
}

/* ================================================================= buttons */

.tender-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 11px 20px;
  border-radius: 5px;
  background: var(--color-primary);
  color: var(--color-white);
  font-family: "Inter", serif;
  font-size: 13px;
  font-weight: var(--p-bold);
  white-space: nowrap;
  transition: opacity var(--transition) ease, gap var(--transition) ease;
}

.tender-btn i {
  font-size: 11px;
}

.tender-btn:hover {
  color: var(--color-white);
  opacity: 0.88;
  gap: 14px;
}

.tender-empty {
  padding: 44px 26px;
  border: 1px dashed var(--bcc-line);
  border-radius: 8px;
  text-align: center;
  color: var(--color-body);
  margin: 0;
}

/* ================================================================ archive */

.tender-archive {
  margin-top: 34px;
}

.tender-archive__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  appearance: none;
  padding: 16px 26px;
  border: 1px solid var(--bcc-line);
  border-radius: 8px;
  background: var(--bcc-cream);
  font-family: "Inter", serif;
  font-size: 14px;
  font-weight: var(--p-bold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bcc-ink);
  cursor: pointer;
  transition: border-color var(--transition) ease, color var(--transition) ease;
}

.tender-archive__toggle:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.tender-archive__toggle i {
  color: var(--color-primary);
  font-size: 13px;
  transition: transform var(--transition) ease;
}

.tender-archive__toggle.is-open i {
  transform: rotate(180deg);
}

.tender-table--archive {
  margin-top: 14px;
}

/* An archived row is deliberately quieter than a live one. */
.tender-table--archive .tender-row__title {
  color: #5C5C5C;
}

/* ========================================================= request form */

.tender-request {
  background: var(--color-white);
  padding: 90px 0 100px;
}

.tender-request__grid {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: 56px;
  align-items: start;
}

.tender-request__intro {
  color: var(--color-body);
  font-size: 16px;
  line-height: 1.8;
  margin: 0 0 32px;
}

.tender-request__flash {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 34px;
  padding: 16px 22px;
  border-radius: 6px;
  font-size: 15px;
}

.tender-request__flash.is-ok {
  background: rgba(62, 183, 94, 0.10);
  border: 1px solid rgba(62, 183, 94, 0.30);
  color: #2C8F47;
}

.tender-request__flash.is-error {
  background: rgba(137, 0, 0, 0.07);
  border: 1px solid rgba(137, 0, 0, 0.22);
  color: var(--color-primary);
}

/*
 * main.js runs $('select').niceSelect() over every select on the site, which
 * swaps the element for a div styled `float: left; width: auto`. That float was
 * pulling the following field group up alongside the dropdown and wrecking the
 * layout, so the replacement is pinned back into the grid here.
 */
.tender-form .nice-select {
  float: none;
  width: 100%;
  height: auto;
  min-height: 48px;
  line-height: 1.5;
  padding: 13px 38px 13px 16px;
  border: 1px solid var(--bcc-line);
  border-radius: 6px;
  font-family: "Inter", serif;
  font-size: 15px;
  color: var(--bcc-ink);
  white-space: normal;
}

.tender-form .nice-select .list {
  width: 100%;
}

.tender-form .nice-select .option {
  line-height: 1.5;
  padding: 10px 18px;
  min-height: 0;
  white-space: normal;
}

/* ------------------------------------------------------------- field groups */

.tender-form__set {
  border: 0;
  padding: 0;
  margin: 0 0 30px;
}

.tender-form__legend {
  display: block;
  width: 100%;
  padding: 0 0 12px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--bcc-line);
  font-family: "Inter", serif;
  font-size: 12px;
  font-weight: var(--p-bold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-primary);
}

.tender-form__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.tender-form__field {
  display: block;
  min-width: 0;
}

/* Spans the full width of the two-column group. */
.tender-form__field.is-full,
.tender-form__check.is-full {
  grid-column: 1 / -1;
}

.tender-form__note {
  color: var(--color-body);
  font-size: 14px;
  line-height: 1.7;
  margin: 0 0 18px;
}

.tender-form__field > span {
  display: block;
  margin-bottom: 8px;
  font-family: "Inter", serif;
  font-size: 13px;
  font-weight: var(--p-semi-bold);
  letter-spacing: 0.04em;
  color: var(--bcc-ink);
}

.tender-form__field > span b {
  color: var(--color-primary);
  font-weight: var(--p-bold);
}

.tender-form__field input,
.tender-form__field select,
.tender-form__field textarea {
  width: 100%;
  padding: 13px 16px;
  border: 1px solid var(--bcc-line);
  border-radius: 6px;
  background: var(--color-white);
  font-family: "Inter", serif;
  font-size: 15px;
  color: var(--bcc-ink);
  transition: border-color var(--transition) ease, box-shadow var(--transition) ease;
}

.tender-form__field textarea {
  resize: vertical;
  min-height: 120px;
}

.tender-form__field input:focus,
.tender-form__field select:focus,
.tender-form__field textarea:focus {
  outline: 0;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(137, 0, 0, 0.08);
}

.tender-form__field input::placeholder,
.tender-form__field textarea::placeholder {
  color: #A2A2A2;
}

/* ------------------------------------------------------------- checkbox */

.tender-form__check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
}

.tender-form__check input[type="checkbox"] {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.tender-form__check > span {
  font-family: "Inter", serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-body);
}

/* --------------------------------------------------------------- uploads */

.tender-form__upload {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 34px 24px;
  border: 1px dashed var(--bcc-line);
  border-radius: 8px;
  background: var(--bcc-cream);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition) ease, background var(--transition) ease;
}

.tender-form__upload:hover,
.tender-form__upload:focus-within {
  border-color: var(--color-primary);
  background: var(--color-white);
}

/* The native control is covered by the drop zone but stays keyboard reachable. */
.tender-form__upload input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.tender-form__upload > i {
  font-size: 26px;
  color: var(--color-primary);
}

.tender-form__upload-title {
  font-family: "Gantari", serif;
  font-size: 16px;
  font-weight: var(--s-semi-bold);
  color: var(--bcc-ink);
}

.tender-form__upload-hint {
  font-family: "Inter", serif;
  font-size: 13px;
  line-height: 1.6;
  color: var(--color-body);
  word-break: break-word;
}

/* ---------------------------------------------------------------- actions */

.tender-form__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 20px;
  padding-top: 6px;
}

.tender-btn--submit {
  appearance: none;
  border: 0;
  cursor: pointer;
  padding: 15px 34px;
  font-size: 14px;
}

.tender-form__feedback {
  display: block;
  margin-top: 14px;
  font-size: 14px;
}

.tender-form__feedback.is-error {
  color: var(--color-primary);
}

.tender-form__feedback.is-success {
  color: #2C8F47;
}

/* ------------------------------------------------- selected tender panel */

.tender-facts {
  border: 1px solid var(--bcc-line);
  border-left: 3px solid var(--color-primary);
  border-radius: 8px;
  background: var(--bcc-cream);
  padding: 28px 30px;
  position: sticky;
  top: 110px;
}

.tender-facts__title {
  font-family: "Gantari", serif;
  font-size: 19px;
  line-height: 1.4;
  font-weight: var(--s-bold);
  color: var(--bcc-ink);
  margin: 14px 0 20px;
}

.tender-facts__row + .tender-facts__row {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--bcc-line);
}

.tender-facts__label {
  display: block;
  font-family: "Inter", serif;
  font-size: 11px;
  font-weight: var(--p-semi-bold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-primary);
  margin-bottom: 6px;
}

.tender-facts__value {
  margin: 0;
  font-family: "Gantari", serif;
  font-size: 15px;
  font-weight: var(--s-semi-bold);
  color: var(--bcc-ink);
  line-height: 1.6;
  word-break: break-word;
}

.tender-facts__value.is-emphasis {
  color: var(--color-primary);
  font-size: 16px;
}

.tender-facts__brief {
  margin: 0;
  font-size: 14px;
  line-height: 1.75;
  color: var(--color-body);
}

.tender-request__back {
  margin-top: 24px;
}

/* ============================================================== responsive */

@media only screen and (max-width: 1199px) {
  .tender-table__head,
  .tender-row {
    grid-template-columns: minmax(0, 1fr) 210px;
    gap: 24px;
  }
}

@media only screen and (max-width: 991px) {
  .tender-board,
  .tender-request {
    padding: 72px 0;
  }

  .tender-request__grid {
    grid-template-columns: 1fr;
    gap: 40px;
  }

  /* The panel would otherwise stick past the form it describes. */
  .tender-facts {
    position: static;
    order: -1;
  }

  /*
   * Side by side stops working once the column narrows, so the two cells stack
   * and the header row is hidden — it no longer describes the layout.
   */
  .tender-table__head {
    display: none;
  }

  .tender-row {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 24px 22px;
  }

  /* Status and action sit in a row of their own beneath the brief. */
  .tender-row__cell--side {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px 20px;
    padding-top: 18px;
    border-top: 1px solid var(--bcc-line);
  }

  .tender-row__cell--side .tender-btn {
    width: auto;
    margin-left: auto;
  }
}

@media only screen and (max-width: 767px) {
  .tender-board,
  .tender-request {
    padding: 56px 0;
  }

  .tender-form__grid {
    grid-template-columns: 1fr;
  }

  .tender-btn--submit {
    width: 100%;
    justify-content: center;
  }

  .tender-facts {
    padding: 24px 22px;
  }

  .tender-btn--submit {
    width: 100%;
  }

  .tender-board__head {
    margin-bottom: 34px;
  }

  .tender-archive__toggle {
    padding: 14px 18px;
    font-size: 13px;
  }

  .tender-row__title {
    font-size: 17px;
  }

  /* At phone width the button gets its own line rather than being squeezed
     alongside the status pill. */
  .tender-row__cell--side .tender-btn {
    width: 100%;
    margin-left: 0;
  }
}
