/* CSS styles for the metadata drawer */
/* ===== FILE INFO BANNER ===== */
.filename-banner {
  position: relative;
  width: 100%;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 0;
  box-sizing: border-box;
  text-align: left;
  border-radius: 8px 0 0 8px;
  margin: 0;
  order: 1;
  pointer-events: auto;
  overflow: visible;
}

/* Draggable Titlebar */
.filename-titlebar {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.5em;
  background: rgba(50, 50, 50, 0.9);
  padding: 0.6em 1em;
  border-bottom: 1px solid rgba(128, 128, 128, 0.3);
  cursor: move;
  user-select: none;
}

.filename-titlebar:hover {
  background: rgba(60, 60, 60, 0.9);
}

.filename-banner:hover {
  /* No hover effect on the banner itself anymore */
}

.filenameDescContainer {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  margin-bottom: 0;
  padding: 1em 2em 0;
}

.filenameRow {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5em;
  flex-wrap: wrap;
}

#descriptionText {
  color: #ccc;
  font-size: 1em;
  margin: 0.5em 0;
  max-width: 100%;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-height: 40vh;
  overflow-y: auto;
  text-align: left;
  cursor: auto;
}

#filepathText {
  color: #ccc;
  font-size: 0.8em;
  margin-top: 0.5em;
  margin-bottom: 0.5em;
  text-align: left;
  word-break: break-word;
  white-space: pre-line;
  cursor: auto;
}

#filenameText {
  display: inline-block;
  max-width: 100%;
  font-weight: bold;
  font-size: 1em;
  color: #fff700;
  overflow-wrap: anywhere;
  word-break: break-all;
  white-space: normal;
  vertical-align: middle;
  flex: 1;
  cursor: move;
}

.exif-metadata {
  white-space: normal !important;
}

.exif-metadata table {
  border-collapse: collapse;
  border: 1px solid #bbb;
  width: 100%;
  margin: 0;
}

.exif-metadata th,
.exif-metadata td {
  border: 1px solid #555;
  padding: 6px 10px;
  vertical-align: top;
}

.metadata-link {
  color: #faea0e;
  text-decoration: none;
  font-weight: bold;
  font-size: 14px;
}

.cluster-info-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.9em;
  font-weight: bold;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.cluster-info-badge:hover {
  opacity: 0.9;
  transform: scale(1.05);
}

.invoke-metadata,
.invoke-tuples {
  border-collapse: collapse;
  border: 1px solid #bbb;
  width: 100%;
  margin: 0.5em 0 0;
}

.invoke-metadata th,
.invoke-metadata td,
.invoke-tuples th,
.invoke-tuples td {
  border: 1px solid #555;
  padding: 6px 10px;
}

.ref-image-thumb {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  max-width: 140px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.ref-image-thumb img {
  display: block;
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #555;
  background: #1a1a1a;
}

.ref-image-thumb:hover img {
  border-color: #faea0e;
}

.ref-image-thumb-caption {
  font-size: 0.78em;
  color: #ccc;
  text-align: center;
  word-break: break-all;
  max-width: 100%;
  line-height: 1.2;
}

.ref-image-thumb:hover .ref-image-thumb-caption {
  color: #faea0e;
}

.details-link-cell {
  text-align: left;
  /* Pin the link to the bottom of the scrollable description area so it
     remains visible even when reference-image thumbnails push the table
     past the 40vh scroll cap. Solid background keeps preceding rows from
     showing through as they scroll under the sticky cell. */
  position: sticky;
  bottom: 0;
  background: #1a1a1a;
}

/* ===== Recall / Remix buttons (pinned outside scrollable area) ===== */
#recallButtonsContainer:empty {
  display: none;
}

#recallButtonsContainer {
  padding: 0 2em;
}

#metadataLinkContainer {
  padding: 0.4em 2em 0.8em;
  text-align: left;
}

/* The recall controls are a two-row table styled to match the Image Details
   table (.invoke-metadata): an "InvokeAI" header row above a row of buttons.
   The borders/width/padding are mirrored here rather than via the shared class
   because the drawer's "Path" row injection targets .invoke-metadata. The
   table is relocated out of #descriptionText (see metadata-drawer.js), so the
   foreground color the field headers inherit (#ccc) is set explicitly. */
.invoke-recall-controls {
  border-collapse: collapse;
  border: 1px solid #bbb;
  width: 100%;
  margin: 0.5em 0 4px;
}

.invoke-recall-controls th,
.invoke-recall-controls td {
  border: 1px solid #555;
  padding: 6px 10px;
}

/* Header cell ("InvokeAI"): bold and left-aligned to match the Image Details
   field headers (e.g. "Path"). */
.invoke-recall-heading {
  color: #ccc;
  font-weight: bold;
  text-align: left;
}

/* A button row: lay the buttons out horizontally inside the cell. Image
   tables have two rows (Send / Append Image, then Remix / Recall). */
.invoke-recall-buttons {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.invoke-recall-buttons + .invoke-recall-buttons {
  margin-top: 8px;
}

/* "as a reference for <image generation|video generation>": which InvokeAI
   tab Send / Append Image feed. Only InvokeAI 7 can place an image in its
   Video panel, so the choice stays hidden until the backend confirms it. */
.invoke-ref-target {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: #ccc;
  font-size: 14px;
}

body.invoke-video-image-supported .invoke-ref-target {
  display: inline-flex;
}

.invoke-ref-target-select {
  background: #2a2a2a;
  color: #faea0e;
  border: 1px solid #555;
  border-radius: 4px;
  height: 32px;
  padding: 0 6px;
  font-size: 14px;
  cursor: pointer;
}

.invoke-ref-target-select:hover,
.invoke-ref-target-select:focus-visible {
  border-color: #faea0e;
}

/* Capability gating (see invoke-capabilities.js): every recall button stays
   hidden until the backend confirms the configured InvokeAI instance
   supports the recall API; the Append button additionally requires the
   append option, which older backends would silently treat as replace. */
body:not(.invoke-recall-supported) .invoke-recall-controls:not(.invoke-video-controls) {
  display: none;
}

/* The video group rides on InvokeAI 7's video recall API, which is newer
   than (and independent of) the image recall API. */
body:not(.invoke-video-recall-supported) .invoke-video-controls {
  display: none;
}

body:not(.invoke-append-supported) .invoke-recall-btn[data-recall-mode="append_ref"] {
  display: none;
}

/* The image-recall append option is irrelevant to the Video panel, whose
   image placement route always understands append. */
body.invoke-video-image-supported
  .invoke-recall-controls[data-ref-target="video"]
  .invoke-recall-btn[data-recall-mode="append_ref"] {
  display: inline-flex;
}

.invoke-recall-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #2a2a2a;
  color: #faea0e;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  height: 32px;
  box-sizing: border-box;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.invoke-recall-btn:hover:not(:disabled) {
  background: #3a3a3a;
  border-color: #faea0e;
}

.invoke-recall-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.invoke-recall-btn svg {
  flex-shrink: 0;
}

.invoke-recall-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 14px;
  height: 14px;
  font-size: 14px;
  font-weight: bold;
  line-height: 1;
  overflow: hidden;
}

.invoke-recall-status:empty {
  display: none;
}

.invoke-recall-status.success {
  color: #4caf50;
}

.invoke-recall-status.error {
  color: #e53935;
}

.invoke-recall-error {
  color: #e53935;
  font-size: 12px;
  margin-top: 4px;
  word-break: break-word;
}

/* A request that worked, with a caveat (e.g. parameters InvokeAI skipped). */
.invoke-recall-error.invoke-recall-note {
  color: #f0b429;
}

/* ===== BANNER DRAWER CONTAINER ===== */
.banner-drawer-container {
  position: fixed;
  left: 0;
  /* Pre-initialization default only: metadata-drawer.js measures the album
     badge and sets `top` inline (DRAWER_TOP_FALLBACK matches this value). */
  top: 78px;
  transform: translateX(-100%);
  width: auto;
  max-width: 50vw;
  z-index: 4001;
  transition: transform 0.4s ease, top 0.2s;
  pointer-events: auto;
  display: flex;
  flex-direction: row;
}

.banner-drawer-container.visible {
  transform: translateX(0);
}

.banner-drawer-container.dragging {
  transition: none;
}

.banner-drawer-container.hidden-fullscreen {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.banner-drawer-container:not(.visible) {
  transform: translateX(calc(-100% + 20px));
}

.overlay-drawer {
  position: relative;
  width: 20px;
  height: 100px;
  cursor: pointer;
  transition: all 0.3s ease;
  order: 2;
  display: flex;
  align-items: center;
}

.drawer-handle {
  width: 100%;
  height: 100%;
  background: rgba(209, 209, 0, 0.5);
  clip-path: polygon(0% 0%, 80% 20%, 80% 80%, 0% 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
}

.drawer-handle:hover {
  background: rgba(255, 255, 255, 0.6);
}

/* .banner-drawer-container.visible .drawer-handle {
  background: rgba(0, 0, 0, 0.5);
} */

.drawer-arrow {
  transition: transform 0.3s ease;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
  transform: rotate(90deg);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: black;
  fill: black;
}

.banner-drawer-container.visible .drawer-arrow {
  transform: rotate(-90deg) translateY(-5px);
}

#copyTextBtn,
#copyMetadataBtn {
  background: transparent !important;
  border: none;
  color: #fff;
  padding: 0.2em;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s ease, transform 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
  min-width: 24px;
  min-height: 24px;
  flex-shrink: 0;
}

#copyTextBtn:hover,
#copyMetadataBtn:hover,
.copy-icon:hover {
  opacity: 1;
  transform: scale(1.1);
}

#copyTextBtn svg,
#copyMetadataBtn svg {
  color: #fff;
  fill: currentColor;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
  #filenameBanner {
    min-width: 180px;
    padding: 0.5em 1em;
    font-size: 0.95em;
    overflow-wrap: anywhere;
    word-break: break-all;
  }

  #descriptionText {
    font-size: 1em;
  }
}

@media (max-width: 480px) {
  #filenameBanner {
    min-width: 180px;
    padding: 0.5em 1em;
    font-size: 0.95em;
  }

  #descriptionText {
    font-size: 1em;
  }
}

.copy-icon {
  cursor: pointer;
  margin-left: 0.5em;
  color: white;
  font-size: 1em;
  vertical-align: middle;
  opacity: 0.7;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.copy-icon:hover {
  opacity: 1;
  filter: brightness(1.2);
}

/* Per-image vocabulary label, lazy-fetched from /image_label and rendered
   beneath the cluster info badge. Distinct from the cluster label (which
   describes the cluster's overall centroid). Smaller and dimmer because
   it's secondary information. */
.image-label-row {
  margin-top: 0.35em;
  font-size: 0.9em;
  font-weight: bold;
}

.tag-value {
  font-style: italic;
  font-weight: normal;
}

.image-label-row .tag-value:first-of-type {
  font-weight: bold;
}

/* Visual frame mirrors .settings-accordion from settings.css but without
   the class — settings.js setupAccordions() binds a competing click handler
   to anything matching `.settings-accordion .accordion-header`, which
   cancelled this drawer's own toggle. */
.metadata-fields-accordion {
  margin-top: 1em;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  overflow: hidden;
}
