/*
 * Growth Partner — Vergunningen index (UX overhaul phase 4a)
 *
 * Spec: docs/ux-overhaul/mockup/Vergunningen.dc.html, left column + filter
 * card. Components (.gp-seg, .gp-card, .gp-chip) come from ux_components.css;
 * this file only lays out the permits index. Rows stay a <table> with
 * <tr id=dom_id> (turbo-stream target + bulk select): on a phone the same rows
 * are restyled into stacked cards below, there is no second markup.
 *
 * Text colours via tokens only (test/assets/color_contrast_test.rb).
 */

/* ── Header: title + count, status tabs on the right ── */
.gp-permits-header { align-items: center; margin-bottom: 1rem; }
.gp-status-tabs { margin-left: auto; }
.gp-status-tabs > a { display: inline-flex; align-items: center; gap: 6px; }
.gp-status-tab-count { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ── Filter card ── */
.gp-filter-card { gap: 10px; padding: 14px 16px; margin-bottom: 1rem; }
/* The legacy .filters panel (grey box) is the card itself here. */
.gp-filter-card .filters {
  margin-bottom: 0; align-items: center; padding: 0;
  background: transparent; border: 0; border-radius: 0;
}
.gp-filter-card .icp-chips { margin: 0; }
.gp-filter-card .filter-chips { margin: 0; }
.gp-filter-card .details-section { margin-top: 0; }
.gp-filter-card .filters-search { max-width: 360px; }

/* Segmented radios: the label carries the look, the radio is visually hidden.
   The current segment follows :checked so it repaints on click, before the
   auto-submit round trip. */
.gp-filter-seg > label { cursor: pointer; display: inline-flex; align-items: center; }
.gp-filter-seg > label:hover { background: var(--gp-surface); color: var(--gp-navy); }
.gp-filter-seg > label:has(input:checked) { background: var(--gp-navy); color: #fff; }
.gp-filter-seg > label:has(input:focus-visible) { outline: 2px solid var(--gp-navy); outline-offset: 1px; }

/* ── Rows ── */
.gp-permit-table th .sort-link { white-space: nowrap; }
.gp-permit-sort-sep { color: var(--gp-body); }
.gp-permit-table td { vertical-align: top; }
.gp-permit-main { min-width: 22rem; }
.gp-permit-title { margin: 0; line-height: 1.4; overflow-wrap: anywhere; }
.gp-permit-name { font-weight: 700; color: var(--gp-navy); }
.gp-permit-sentence { margin: 0; color: var(--gp-body); line-height: 1.4; }
.gp-permit-quote {
  margin: 6px 0 0; padding: 2px 0 2px 10px;
  border-left: 3px solid var(--gp-line); border-inline-start: 3px solid var(--gp-line);
  color: var(--gp-ink); font-size: 0.85rem; font-style: italic; line-height: 1.4;
}
.gp-permit-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.gp-permit-chips .gp-chip { white-space: normal; }
.gp-permit-address { color: var(--gp-body); font-size: 0.8rem; }
/* The status select must fit its longest label ("Goedgekeurd"). */
.gp-permit-status { white-space: nowrap; }
.gp-permit-status select { width: auto; min-width: 8.5rem; }

/* ── Preview pane (UX overhaul phase 4b) ──
   Spec: the right-hand <aside> in Vergunningen.dc.html. Desktop only: below
   1240px the pane and the Bekijk column are display:none and the page is the
   plain list (the frame has no src, so a hidden pane fetches nothing).
   1240, not 1100: the pane takes >= 320px, and below 1240 the list column left
   beside it is narrower than the table's minimum — the table scrolled inside
   its box and hid Status and Bekijk off the right edge (2026-11-17). In split
   mode the table also slims down: the Sector column folds into the row (the
   pane does not show the sector) and the main cell may shrink to 12rem.
   Guard: test/system/permit_preview_test.rb measures the fit per width. */
/* Two classes: must outrank the phone card rule `.gp-permit-row > td`. */
.gp-permit-preview-pane, .gp-permit-table .gp-permit-peek-cell { display: none; }
.gp-permit-sector-inline { display: none; }

@media (min-width: 1240px) {
  .gp-permits-split {
    display: grid; align-items: start; gap: 18px;
    grid-template-columns: minmax(0, 1fr) clamp(320px, 34%, 440px);
  }
  .gp-permits-list { min-width: 0; }
  .gp-permit-preview-pane {
    display: block; position: sticky; top: 1rem;
    max-height: calc(100vh - 2rem); overflow-y: auto;
  }
  .gp-permit-table .gp-permit-peek-cell { display: table-cell; white-space: nowrap; }
  .gp-permit-table .gp-permit-sector { display: none; }
  .gp-permit-sector-inline { display: inline; color: var(--gp-body); font-size: 0.8rem; }
  .gp-permit-main { min-width: 12rem; }
}

.gp-permit-peek { margin: 0; }
.gp-permit-peek[aria-current="true"] { background: var(--gp-navy); border-color: var(--gp-navy); color: #fff; }
.gp-permit-row-selected > td { background: var(--gp-surface); }
.gp-permit-row-selected > td:first-child { box-shadow: inset 3px 0 0 var(--gp-navy); }

.gp-preview-hint p { margin: 0; color: var(--gp-body); }

.gp-preview { gap: 14px; }
.gp-preview-head { display: flex; align-items: flex-start; gap: 12px; }
.gp-preview-identity { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.gp-preview-title {
  margin: 0; font-family: var(--gp-font-heading); font-size: 1.25rem; line-height: 1.25;
  color: var(--gp-navy); overflow-wrap: anywhere;
}
.gp-preview-ref { color: var(--gp-body); font-size: 0.85rem; overflow-wrap: anywhere; }
.gp-preview-head .show-score { flex: none; }
.gp-preview-sentence { margin: 0; color: var(--gp-ink); line-height: 1.45; }
.gp-preview .gp-permit-quote { margin: 0; }
.gp-preview .gp-permit-chips { margin-top: 0; }
.gp-preview-address {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  color: var(--gp-ink); font-size: 0.9rem;
}
.gp-preview-label {
  margin: 0 0 6px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--gp-body);
}
.gp-preview-company { border-top: 1px solid var(--gp-line); padding-top: 12px; }
.gp-preview-company-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.gp-preview-company-name { font-weight: 700; color: var(--gp-navy); overflow-wrap: anywhere; }

.gp-preview-actions { display: flex; flex-direction: column; gap: 8px; }
.gp-preview-verdict { display: flex; gap: 8px; }
.gp-preview-form { flex: 1 1 0; margin: 0; }
.gp-preview-form .gp-btn { width: 100%; }
.gp-preview-status { margin: 0; font-size: 0.85rem; color: var(--gp-body); }
.gp-preview-links { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.gp-preview-links > a { margin-left: auto; }

/* ── Phone: each <tr> becomes a stacked card ──
   Checkbox, list button and score share the top line; the sentence takes the
   full width; sector and the status select close the card. Touch targets
   >= 40px. */
@media (max-width: 640px) {
  /* Segments wrap rather than scroll: a clipped "Alles" or "1 jaar" reads as
     missing. */
  .gp-status-tabs { margin-left: 0; flex-wrap: wrap; }
  .gp-filter-card .filters-search { max-width: none; }
  .gp-filter-card .gp-filter-seg { flex: 1 1 100%; flex-wrap: wrap; }

  .gp-permit-table, .gp-permit-table thead, .gp-permit-table tbody { display: block; width: 100%; }
  .gp-permit-table thead tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
  .gp-permit-table thead th { display: block; border: 0; padding: 4px 0; }
  /* Only the controls survive in the header: select-all and the two sorts. */
  .gp-permit-table thead th:not(:has(a, input)) { display: none; }

  .gp-permit-table tr.gp-permit-row {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
    padding: 12px 4px; border-bottom: 1px solid var(--gp-line);
  }
  .gp-permit-row > td { display: block; border: 0; padding: 0; background: transparent; }
  .gp-permit-row > .bulk-td { width: auto; min-width: 40px; min-height: 40px; display: flex; align-items: center; justify-content: center; padding: 0 !important; }
  .gp-permit-row > .bulk-td input[type="checkbox"] { width: 1.4rem; height: 1.4rem; }
  .gp-permit-row .list-add-btn { min-width: 40px; min-height: 40px; }
  .gp-permit-row > .gp-permit-main { flex: 1 1 100%; min-width: 0; order: 1; }
  .gp-permit-row > .gp-permit-sector { flex: 1 1 auto; order: 2; }
  .gp-permit-row > .gp-permit-status { flex: 0 0 auto; order: 3; margin-left: auto; }
  .gp-permit-row > .gp-permit-status form { margin: 0; }
  .gp-permit-row > .gp-permit-status select { min-height: 40px; margin: 0; }
}
