/* ============================================================================
   Barmaso — dataset search: search bar, result cards, Excel import
   ============================================================================ */

.dataset { display: grid; gap: 16px; }

.dataset-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.dataset-meta,
.dataset-count {
  font-size: 13px;
  color: var(--ink-faint);
}

.dataset-count { font-weight: 600; color: var(--ink-soft); }

/* --- Search bar ------------------------------------------------------------ */
.dataset-search {
  display: flex;
  gap: 10px;
}

.dataset-input-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.dataset-search-icon {
  position: absolute;
  top: 50%;
  left: 13px;
  transform: translateY(-50%);
  color: var(--ink-faint);
  pointer-events: none;
}

.dataset-input {
  padding-left: 40px;
  padding-right: 38px;
}

/* Safari draws its own clear affordance on type=search; ours is the one
   that stays in the right place and matches the rest of the field. */
.dataset-input::-webkit-search-cancel-button { display: none; }

.dataset-clear {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-faint);
  font-size: 20px;
  line-height: 1;
  /* Only useful once there is something to clear. */
  display: none;
}

.dataset.has-query .dataset-clear { display: block; }
.dataset-clear:hover { background: var(--surface-alt); color: var(--ink); }

/* --- Result cards ---------------------------------------------------------- */
.card-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.card {
  display: grid;
  gap: 10px;
  /* Cards in a row stretch to the tallest; keep each one's content at the
     top instead of spreading it down the extra height. */
  align-content: start;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  min-width: 0;
  overflow-wrap: anywhere;
}

.card-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 12px;
  font-weight: 700;
}

/* --- Membership tiers ------------------------------------------------------
   Each tier is a tinted fill, a dark text colour drawn from the same hue,
   and a border. The metals themselves cannot be used as the text colour —
   silver (#C0C0C0) on white is around 1.5:1, invisible in a shop under
   fluorescent light — so the hue identifies the tier and the darkened text
   carries the contrast. Every pairing below clears 4.5:1.
   -------------------------------------------------------------------------- */
.card-badge[data-tier="gold"] {
  background: #FCF4D3;
  border-color: #E8D493;
  color: #7A5A0E;
}

/* Kept close to a true neutral, so it reads as grey next to diamond's blue
   rather than as a paler version of it. */
.card-badge[data-tier="silver"] {
  background: #F0F1F3;
  border-color: #CFD2D7;
  color: #4E5560;
}

/* Platinum is pulled toward violet rather than being another cool grey:
   sitting next to silver, two neutrals would read as the same tier. */
.card-badge[data-tier="platinum"] {
  background: #EFEBF9;
  border-color: #CDC2EE;
  color: #4C3F86;
}

.card-badge[data-tier="diamond"] {
  background: #E3F1F8;
  border-color: #A9D4E7;
  color: #145E7C;
}

/* Pushed toward red-brown. At gold's amber hue the two were 13 degrees
   apart — the same colour to anyone glancing at a list. */
.card-badge[data-tier="bronze"] {
  background: #FAE2D9;
  border-color: #E7B6A2;
  color: #8F3C17;
}

.card-rows {
  display: grid;
  grid-template-columns: minmax(96px, auto) 1fr;
  gap: 4px 12px;
  margin: 0;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}

.card-rows dt {
  color: var(--ink-faint);
  font-weight: 600;
}

.card-rows dd {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  /* break-word, not anywhere: a long value should wrap at its spaces and
     only split a word when that word alone cannot fit. */
  overflow-wrap: break-word;
}

/* A "/"-separated list rendered one entry per line. */
.card-lines {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.card-rows dt.is-block,
.card-rows dd.is-block {
  grid-column: 1 / -1;
}

/* Block rows drop the flex layout the two-column rows use: as a flex item
   the list only took its content's width, so aligning inside it did
   nothing. As a block it fills the row and its lines can reach the edge. */
.card-rows dd.is-block {
  display: block;
  text-align: right;
}

.card-rows dt.is-block { margin-top: 4px; }

.card-line {
  min-width: 0;
  /* Hanging indent, so a model name too long for one line stays visually
     attached to its own entry instead of reading as a new one. */
  padding-left: 10px;
  text-indent: -10px;
}

.is-mono,
.is-mono .card-badge-text {
  font-family: var(--font-mono);
  letter-spacing: -0.01em;
}

/* The matched substring. Tinted rather than the browser's yellow, so a row
   with several hits still reads as one card. */
.card mark {
  background: var(--highlight-bg);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

.copy-btn {
  flex: none;
  padding: 1px 5px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-faint);
  font-size: 12px;
  line-height: 1.4;
}
.copy-btn:hover { background: var(--surface-alt); color: var(--ink); }
.copy-btn.is-done { color: var(--success-ink); }

/* --- Empty / error states --------------------------------------------------- */
.state-box {
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 44px 20px;
  text-align: center;
}

.state-box--error { gap: 12px; }

.state-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  /* Same reason as .form-error: a refusal here lists what to check, one
     thing per line, and collapsed into a paragraph it reads as noise. */
  white-space: pre-line;
}

.state-sub {
  font-size: 13px;
  color: var(--ink-faint);
  max-width: 40ch;
}

/* --- Excel import ----------------------------------------------------------- */
.import-panel {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.import-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.import-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.import-message {
  margin: 0;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  white-space: pre-line;
}

.import-message.is-busy  { background: var(--surface-alt); color: var(--ink-soft); }
.import-message.is-error { background: var(--danger-soft);  color: #98241D; }
.import-message.is-ok    { background: var(--success-soft); color: #0C7150; }

.import-preview { display: grid; gap: 10px; }

.import-file {
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.import-warn {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 13px;
  font-weight: 600;
}

.import-preview-head {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-faint);
}

/* The preview is as wide as the dataset has columns; let it scroll inside
   its own box rather than pushing the page sideways. */
.import-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.import-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}

.import-table th,
.import-table td {
  padding: 7px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.import-table th {
  background: var(--surface-alt);
  font-weight: 700;
  color: var(--ink-soft);
}

.import-table tbody tr:last-child td { border-bottom: none; }

.import-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn--danger {
  background: var(--danger);
  color: #fff;
}
.btn--danger:hover { background: #C63C35; }

@media (max-width: 640px) {
  .dataset-search { flex-wrap: wrap; }
  .dataset-search .btn { width: 100%; }
  .card-grid { grid-template-columns: 1fr; }
  /* Label beside value, and a list of models as small pills that wrap: the
     card was twice as tall as what it said. */
  .card-rows { grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; }
  .card-rows dd.is-block { text-align: left; }
  .card-lines { display: flex; flex-wrap: wrap; gap: 4px; }
  .card-line { padding: 2px 8px; text-indent: 0; border-radius: 999px; background: var(--surface-alt); font-size: 12.5px; }
}
