/*
  Datasets and training.

  The one layout that matters here is the caption grid: a picture is useless for
  judging a caption unless you can see both at once, so an item is an image and
  its text side by side, sized so a row of them still fits a laptop.
*/

/* Forms ---------------------------------------------------------------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}

/* Term/definition pairs for the guidance card. */
.guide {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px var(--sp-3);
  margin: var(--sp-3) 0 0;
}

.guide dt {
  font-weight: 600;
  font-size: 12.5px;
}

.guide dd {
  margin: 0;
}

@media (max-width: 620px) {
  .guide {
    grid-template-columns: 1fr;
    gap: 2px var(--sp-3);
  }

  .guide dd {
    margin-bottom: var(--sp-2);
  }
}

/* A training log is the only place raw tool output is shown, and when a run
   fails it is the whole story, so it gets real height. */
.run-log {
  max-height: 340px;
  overflow: auto;
  margin: var(--sp-3) 0 0;
  padding: var(--sp-3);
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--fg-2);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Dataset list --------------------------------------------------------- */

.ds-tile {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--t-fast), transform var(--t-fast);
}

.ds-tile:hover {
  border-color: var(--border-2);
  transform: translateY(-1px);
}

.ds-cover {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 72px;
  height: 72px;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--s3);
  color: var(--fg-3);
}

.ds-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Caption grid --------------------------------------------------------- */

.ds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--sp-3);
}

.ds-item {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3);
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}

/* An image with no caption is the thing you are looking for in this grid. */
.ds-item.is-empty {
  border-color: rgba(251, 191, 36, .35);
}

.ds-item-img {
  flex: none;
  width: 104px;
  height: 104px;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--s3);
}

.ds-item-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ds-item-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.ds-caption {
  min-height: 76px;
  font-size: 12.5px;
}

.ds-save {
  min-width: 48px;
  text-align: right;
}

/* Tool cards (captions, drawing) ---------------------------------------
   One shape for both: a head with an icon, a title and a line of context; a
   row of settings that line up on their inputs, whatever hint sits under
   them; and a footer with the secondary action on the left and the main
   one on the right. */

.ds-tool {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.ds-tool-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.ds-tool-head h2 {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: 0 0 2px;
}

.ds-tool-head p {
  margin: 0;
}

.ds-tool-body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.ds-tool-body[hidden] {
  display: none;
}

.ds-tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-3) var(--sp-4);
  align-items: end;
}

/* A switch in this row is as wide and as tall as the dropdowns beside it,
   so the row reads as one line of controls. */
.ds-tool-grid .seg {
  display: flex;
  width: 100%;
  height: 41px;
}

.ds-tool-grid .seg-btn {
  flex: 1;
  padding: 0 10px;
  white-space: nowrap;
}

.ds-tool-hint {
  margin: calc(var(--sp-2) * -1) 0 0;
  min-height: 1em;
}

.ds-tool-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
}

/* How much of the dataset is captioned, at a glance. */
.ds-meter {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  min-width: 140px;
}

.ds-meter .bar {
  width: 140px;
}

.ds-meter .bar.ok > i {
  background: var(--ok);
}

/* Pictures to draw from: tap to pick, the number is the order they go in. */
.ds-refs {
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  padding: 3px 3px 6px;
  scrollbar-width: thin;
}

.ds-ref {
  position: relative;
  flex: none;
  width: 72px;
  height: 72px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--s3);
  cursor: pointer;
  opacity: .55;
  transition: opacity var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}

.ds-ref:hover {
  opacity: .9;
}

.ds-ref.on {
  opacity: 1;
  border-color: var(--accent);
}

.ds-ref img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ds-ref-n {
  position: absolute;
  top: 4px;
  left: 4px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.ds-draw-job {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3);
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.ds-draw-job:empty {
  display: none;
}

.ds-draw-job h3,
.ds-draw-job p {
  margin: 0;
}

@media (max-width: 620px) {
  .ds-tool-head {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .ds-tool-head .grow {
    flex: 1 1 0;
    min-width: 0;
  }

  .ds-meter {
    align-items: stretch;
    width: 100%;
  }

  .ds-meter .bar {
    width: 100%;
  }

  .ds-tool-foot .btn.primary {
    width: 100%;
    justify-content: center;
  }
}

/* The library picker this page opens is shared with the create form; its
   styles live in app.css beside the other dialogs. */
