/* ----------------------------------------------------------------------------
   genfiles.css — Files the assistant MADE: the card under an answer carrying a
   format icon, the filename, and Preview / Download.
   Slice 11 of 17 (see css/tokens.css for the full load order) — after
   citations.css, because a generated file sits above the citation chips in the
   same region under the bubble and shares their spacing rhythm.
   ------------------------------------------------------------------------- */
.gen-files {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  /* The card is the deliverable — it gets the bubble's full width up to a
     comfortable reading measure, rather than the chip row's inline flow. */
  max-width: 420px;
}

.gen-file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.gen-file:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

/* The card itself is not focusable (its two buttons are — see chatview.js), so
   it gets no focus ring; keyboard focus lands on Preview/Download instead. */
/* Keep the card lit while either of its buttons has focus, so a keyboard user
   can see which file they are on. */
.gen-file:focus-within {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.gen-file:active {
  transform: scale(0.995);
}

/* Format colour lives here, not in the glyph: one icon set, tinted per family,
   so a Word document and a workbook are told apart at a glance the way they are
   in a file manager. --fmt is also the icon tile's wash. */
.gen-file-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: var(--fmt, var(--muted));
  background: color-mix(in srgb, var(--fmt, var(--muted)) 14%, transparent);
}

.gen-file-icon svg {
  width: 20px;
  height: 20px;
}

.gen-file[data-family='doc'] { --fmt: #5b8def; }
.gen-file[data-family='sheet'] { --fmt: #2fa36b; }
.gen-file[data-family='pdf'] { --fmt: #e0565b; }
.gen-file[data-family='slides'] { --fmt: #e08b3c; }
.gen-file[data-family='web'] { --fmt: #4cb6ae; }
.gen-file[data-family='text'] { --fmt: #9aa0a6; }

.gen-file-meta {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* A model-chosen filename can be long, and the extension is the half that says
   what the file IS — so the STEM truncates and the extension is always shown.
   (The rtl-direction trick does the same in one element, but reorders leading
   punctuation and digits, which filenames are full of.) */
.gen-file-name {
  display: flex;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
}

.gen-file-stem {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gen-file-ext {
  flex: 0 0 auto;
}

.gen-file-sub {
  font-size: 11.5px;
  color: var(--muted);
  /* On a phone "Word document · 9 KB" wraps onto a second line and every card
     ends up a different height. It is secondary information — keep it on one
     line and let it clip. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gen-file-actions {
  flex: 0 0 auto;
  display: inline-flex;
  gap: 2px;
}

.gen-file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.gen-file-btn svg {
  width: 16px;
  height: 16px;
}

.gen-file-btn:hover,
.gen-file-btn:focus-visible {
  background: var(--surface-3);
  color: var(--text);
}

.gen-file-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

@media (prefers-reduced-motion: reduce) {
  .gen-file,
  .gen-file-btn {
    transition: none;
  }

  .gen-file:active {
    transform: none;
  }
}
