/* Connection → Import templates (docs/05-views.md; the mockup's import templates view) */

/* The template list: a search field above one table (name, columns, last import), sortable by its
   headers. */
.template-list__filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.template-list__search {
  display: flex;
  flex: 1 1 220px;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 360px;
  height: 38px;
  padding: 0 10px;
  border: var(--border);
  border-radius: var(--radius);
}

.template-list__search .ms {
  color: var(--muted);
  font-size: 20px;
}

.template-list__search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  color: var(--fg);
  font: inherit;
  font-size: 14px;
}

.template-list__search:has(input:focus-visible) {
  outline: 2px solid var(--blue);
  outline-offset: -1px;
}

table.t.template-list {
  min-width: 0;
}

.template-list__sort {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: inherit;
  text-decoration: none;
}

.template-list__sort .ms {
  font-size: 16px;
}

.template-list__name {
  color: inherit;
  font-weight: 600;
  text-decoration: none;
}

.template-list__sort:hover,
.template-list__name:hover {
  color: var(--blue);
}

.template-list__sort:focus-visible,
.template-list__name:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.template-list__none {
  color: var(--muted);
}

/* The column filter by use, inside the columns panel above its table: one pill per use, wrapping. */
.seg.column-filter {
  display: flex;
  gap: 6px;
  margin: 12px 20px;
  border: 0;
  border-radius: 0;
  overflow: visible;
}

.seg.column-filter a {
  border: var(--border);
  border-radius: var(--radius-pill);
}

.column-map__hint,
.value-map__hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.column-map__empty {
  color: var(--muted);
}

/* The pager below the template list, inside its panel. */
.panel > .pager {
  margin: 0;
  padding: 12px 16px 14px;
}

/* The mapping tables' select (and the value mapping's fields) in each row (§4.4). */
.column-map td select,
.value-map td select,
.value-map td input[type="text"] {
  max-width: 100%;
  padding: 5px 8px;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
}

.column-map td select:focus-visible,
.value-map td :focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.column-map__invalid td select {
  border-color: var(--red);
}

/* A dropdown whose options carry a muted explanation line (option_picker_controller.js): the button
   in place of the hidden select, and its listbox, fixed on the page so no table clips it. */
.pick {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-width: 0;
  max-width: 320px;
  padding: 5px 6px 5px 8px;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

/* As tall as the native selects of the form (.field select). */
.field .pick {
  max-width: none;
  padding: 10px 8px 10px 12px;
  font-size: inherit;
  line-height: inherit;
}

.field .pick .ms {
  font-size: 18px;
  line-height: 1;
}

.pick__value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pick .ms {
  flex: none;
  color: var(--muted);
  font-size: 20px;
}

.pick[aria-expanded="true"] {
  border-color: var(--blue);
}

.pick[aria-invalid="true"] {
  border-color: var(--red);
}

.pick:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.pick__list {
  position: fixed;
  z-index: 1000;
  margin: 0;
  padding: 4px 0;
  overflow-y: auto;
  border: var(--border);
  border-radius: var(--radius);
  outline: none;
  background: var(--bg);
  box-shadow: 0 8px 24px rgb(0 0 0 / 14%);
  color: var(--fg);
  list-style: none;
}

.pick__list [role="option"] {
  display: block;
  padding: 7px 12px;
  cursor: pointer;
}

.pick__list .pick__option--active {
  background: var(--surface);
}

.pick__list [aria-selected="true"] .pick__label {
  font-weight: 600;
}

.pick__label {
  display: block;
  font-size: 14px;
}

.pick__description {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.35;
}

/* Phone: file column and field (value and unified value) on one line, the use (the remove box)
   below them, so nothing scrolls sideways. */
@container app (max-width: 599px) {
  table.t.column-map,
  table.t.value-map {
    min-width: 0;
  }

  .column-map thead,
  .value-map thead {
    display: none;
  }

  .column-map tbody tr,
  .value-map tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-bottom: var(--border);
  }

  .column-map tbody tr:last-child,
  .value-map tbody tr:last-child {
    border-bottom: 0;
  }

  .column-map td,
  .value-map td {
    padding: 10px 16px 0;
    border-bottom: 0;
    overflow-wrap: anywhere;
  }

  .column-map td:last-child,
  .value-map td:last-child {
    grid-column: 1 / -1;
    padding-bottom: 12px;
  }

  .column-map td select,
  .column-map td .pick,
  .value-map td select {
    width: 100%;
    max-width: none;
  }
}

/* "Create template" (docs/design.md §4.1 back link and lead, §5 drop zone). */
.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}

.back:hover {
  color: var(--blue);
}

.back:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.ph .lead {
  max-width: 62ch;
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

/* The whole zone opens the file picker (a label of the input). */
.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  padding: 26px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
}

.drop[hidden] {
  display: none;
}

.drop .ms {
  color: var(--blue);
  font-size: 32px;
}

.drop b {
  color: var(--fg);
}

.drop .small {
  font-size: 13px;
}

.drop input[type="file"] {
  max-width: 100%;
  margin-top: 6px;
  color: var(--fg);
  font: inherit;
  font-size: 14px;
}

.drop input[type="file"]:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.drop:has(input[aria-invalid="true"]) {
  border-color: var(--red);
}

/* Import settings (docs/05-views.md): the field search and the choice when a
   changed mapping applies. */
.value-fields__search {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

/* The hint below the name on "Create field". */
.value-field__hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.value-fields__search input[type="search"] {
  flex: 1 1 220px;
  min-width: 0;
  padding: 7px 10px;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
}

.value-map__apply {
  margin: 0 0 12px;
  padding: 0;
  border: 0;
}

.value-map__apply legend {
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 600;
}
