/*
  Shared look for the toolbox tools' sections, tables, boxes and buttons
  (the fishbone's "Prioritize Causes" and the 5 Whys check table and
  temporary actions), so the tools look like one family. Loaded after
  home.css and before each tool's own stylesheet; tokens come from home.css.

  Tables: short columns (numbers, scores, dates, dropdowns) are centred,
  sentence columns (class tool-col-text on their th and td) are left-aligned.
  Rows: is-highlighted for the rows that matter (top causes, confirmed causes),
  is-muted for rows kept only for the record (ruled-out causes).
*/

.tool-section {
  margin-bottom: var(--space-md);
  padding: var(--space-sm) 20px var(--space-md);
  border: 1px solid var(--light-gray);
  border-radius: 6px;
  background: var(--white);
}

.tool-section h2 {
  margin: 0 0 var(--space-xs);
  color: var(--black);
  text-align: center;
}

.tool-explainer {
  max-width: 900px;
  margin: 0 auto var(--space-sm);
  color: var(--muted);
  font-size: 1rem;
  text-align: center;
}

/* "On this page" links to a long tool's sections, like the OEE tracker's tabs (which keep their own copy) */
.tool-page-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-3xs) var(--space-2xs);
  margin-bottom: var(--space-sm);
  padding: var(--space-2xs) var(--space-xs);
  border: 1px solid var(--light-gray);
  border-radius: 6px;
  background: var(--white);
  font-size: 0.9rem;
}

.tool-page-nav > span:first-child {
  color: var(--muted);
  font-weight: 600;
}

.tool-page-nav a {
  color: var(--primary-blue);
  font-weight: 600;
}

/* ---------- tables ---------- */

.tool-table-wrapper {
  overflow-x: auto;
}

.tool-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
}

.tool-table th,
.tool-table td {
  padding: 8px 10px;
  border: 1px solid var(--light-gray);
  color: var(--black);
  font-size: 1rem;
  text-align: center;
  vertical-align: middle;
}

.tool-table th {
  background: var(--white);
  font-weight: 600;
}

.tool-table .tool-col-text {
  text-align: left;
}

.tool-table tr.is-highlighted td {
  background: var(--red-tint);
  color: var(--primary-blue);
  font-weight: 700;
}

.tool-table tr.is-muted td {
  background: var(--bg-light);
  color: var(--muted);
}

.tool-table tr.is-muted .tool-col-text {
  text-decoration: line-through;
}

/* ---------- boxes inside tables ---------- */

.tool-input {
  width: 100%;
  min-width: 0;
  padding: 5px 6px;
  border: 1px solid var(--light-gray);
  border-radius: 4px;
  background: var(--white);
  color: var(--black);
  font: inherit;
  font-weight: 400;
  line-height: 1.3;
}

textarea.tool-input {
  display: block;
  resize: none;
  overflow: hidden;
}

.tool-input:focus {
  border-color: var(--primary-blue);
  outline: 0;
  box-shadow: 0 0 0 2px rgba(4, 75, 166, 0.16);
}

/* ---------- buttons under a table or at the end of a tool ---------- */

.tool-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: var(--space-sm);
}

.tool-buttons button {
  padding: 7px 13px;
  border: 0;
  border-radius: 4px;
  background: var(--primary-blue);
  color: var(--white);
  font-family: inherit;
  font-size: 1.125rem;
  line-height: 1.2;
  cursor: pointer;
}

.tool-buttons button:hover {
  opacity: 0.9;
}

.tool-buttons button:focus-visible {
  outline: 3px solid rgba(4, 75, 166, 0.28);
  outline-offset: 2px;
}

.tool-buttons button:disabled {
  cursor: wait;
  opacity: 0.6;
}

/*
  Tablets and phones: each table row becomes a card, every box with its
  heading above it (from the cell's data-label). The fishbone is hidden at
  these widths, so this only shows in tools that work on phones.
*/
@media (max-width: 900px) {
  .tool-table.tool-table--cards,
  .tool-table--cards tbody,
  .tool-table--cards tr,
  .tool-table--cards td {
    display: block;
    width: 100%;
  }

  .tool-table--cards thead {
    display: none;
  }

  .tool-table--cards tr {
    margin-bottom: var(--space-xs);
    padding: var(--space-2xs);
    border: 1px solid var(--light-gray);
    border-radius: 6px;
  }

  .tool-table--cards td,
  .tool-table--cards tr.is-highlighted td,
  .tool-table--cards tr.is-muted td {
    padding: 4px 0;
    border: 0;
    background: transparent;
    text-align: left;
  }

  .tool-table--cards td[data-label]:not([data-label=""])::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
  }

  .tool-table--cards tr.is-highlighted {
    border-color: var(--primary-red);
    background: var(--red-tint);
  }

  .tool-table--cards tr.is-muted {
    background: var(--bg-light);
  }
}
