/* Showcase Section */
.showcase-section {
  position: relative;
  margin-top: var(--space-4);
}

/* Gallery: collapsed indicator bar + expanded main viewer with thumbnail strip */

/* Collapsed indicator bar — slim, no remote media is rendered until expanded */
.gallery-indicator-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  background: var(--lora-surface);
  border: 1px solid var(--lora-border);
  border-radius: var(--border-radius-sm);
}

.gallery-preview-thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius-xs);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-color);
}

.gallery-preview-thumb img,
.gallery-preview-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-indicator-bar .gallery-show-btn {
  flex: 1;
  justify-content: flex-start;
}

.gallery-indicator-bar .gallery-import-btn {
  margin-left: auto;
}

/* Expanded gallery toolbar */
.gallery-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

/* Position badge floats over the main media, bottom-right */
.gallery-position-badge {
  position: absolute;
  right: var(--space-2);
  bottom: var(--space-2);
  z-index: 6;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.8em;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* While the gallery is expanded the thumbnail strip sits in the modal's
   bottom-right corner, where the back-to-top button would overlap it */
.modal-content.showcase-expanded .back-to-top {
  display: none;
}

.gallery-toolbar .gallery-import-btn {
  margin-left: auto;
}

.gallery-show-btn,
.gallery-import-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-xs);
  color: var(--text-color);
  font-size: 0.9em;
  cursor: pointer;
  transition: var(--transition-base);
}

.gallery-show-btn:hover,
.gallery-import-btn:hover {
  border-color: var(--lora-accent);
  color: var(--lora-accent);
}

.nsfw-filter-notification {
  font-size: 0.85em;
  color: var(--text-color);
  opacity: 0.7;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Main viewer — the container hugs the active media's aspect ratio
   (--media-aspect = width/height, set per item) so no dead space remains.
   overflow: hidden also clips the hoisted metadata panel while it is
   translated below the bottom edge, so it never extends the modal's
   scrollable height (which caused a scroll jump when it appeared) */
.gallery-main {
  position: relative;
  overflow: hidden;
  border-radius: var(--border-radius-sm);
}

.main-media-container {
  position: relative;
  margin: 0 auto;
  width: min(100%, calc(min(75vh, 800px) * var(--media-aspect, 1.3333)));
  aspect-ratio: var(--media-aspect, 1.3333);
  max-height: min(75vh, 800px);
  background: var(--lora-surface);
  border-radius: var(--border-radius-sm);
  overflow: hidden;
}

.main-media-container .media-wrapper {
  width: 100%;
  height: 100%;
  margin-bottom: 0;
}

.main-media-container .media-wrapper img,
.main-media-container .media-wrapper video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: zoom-in;
}

/* Nav buttons float over the media, visible on hover */
.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 6;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  color: var(--text-color);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  opacity: 0;
  transition: opacity 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  pointer-events: none;
}

.gallery-nav.prev {
  left: var(--space-2);
}

.gallery-nav.next {
  right: var(--space-2);
}

.gallery-main:hover .gallery-nav,
.gallery-nav:focus-visible {
  opacity: 0.9;
  pointer-events: auto;
}

.gallery-nav:hover {
  opacity: 1;
  border-color: var(--lora-accent);
  color: var(--lora-accent);
}

/* Thumbnail strip */
.gallery-strip {
  display: flex;
  gap: var(--space-1);
  margin-top: var(--space-2);
  overflow-x: auto;
  padding-bottom: var(--space-1);
}

.gallery-thumb {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius-xs);
  overflow: hidden;
  background: var(--lora-surface);
  cursor: pointer;
  padding: 0;
  transition: border-color 0.15s ease;
}

.gallery-thumb:hover {
  border-color: var(--text-color);
}

.gallery-thumb.active {
  border-color: var(--lora-accent);
}

.gallery-thumb .thumb-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-thumb .thumb-media.blurred {
  filter: blur(8px);
}

.gallery-thumb .thumb-video-badge,
.gallery-thumb .thumb-nsfw-badge {
  position: absolute;
  bottom: 3px;
  right: 3px;
  font-size: 10px;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  border-radius: var(--border-radius-xs);
  padding: 1px 4px;
  pointer-events: none;
}

.gallery-thumb .thumb-nsfw-badge {
  top: 3px;
  bottom: auto;
}

.gallery-strip::-webkit-scrollbar {
  height: 6px;
}

.gallery-strip::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: 3px;
}

/* Inline import zone toggled from the toolbar */
.gallery-import-zone {
  margin-top: var(--space-2);
}

.gallery-import-zone.hidden {
  display: none;
}

.gallery-import-zone .example-import-area {
  margin-top: 0;
}

.media-wrapper {
  position: relative;
  width: 100%;
  background: var(--lora-surface);
  margin-bottom: var(--space-2);
  overflow: hidden; /* Ensure metadata panel is contained */
}

.media-wrapper:last-child {
  margin-bottom: 0;
}

.no-examples {
  text-align: center;
  padding: var(--space-3);
  color: var(--text-color);
  opacity: 0.7;
}

/* Add styles for blurred showcase content */
.nsfw-media-wrapper {
  position: relative;
}

.media-wrapper img.blurred,
.media-wrapper video.blurred {
  filter: blur(25px);
}

.media-wrapper .nsfw-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  pointer-events: none;
}

/* Position the toggle button at the top left of showcase media */
.showcase-toggle-btn {
  position: absolute;
  z-index: 3;
}

/* Add styles for showcase media controls */
.media-controls {
  position: absolute;
  display: flex;
  gap: 6px;
  z-index: 4;
  opacity: 0;
  transform: translateY(-5px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.media-controls.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.media-control-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  color: var(--text-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-base);
  box-shadow: var(--shadow-md);
  padding: 0;
  position: relative;
  overflow: hidden;
}

.media-control-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.media-control-btn.set-preview-btn:hover {
  background: var(--lora-accent);
  color: white;
  border-color: var(--lora-accent);
}

.media-control-btn.set-nsfw-btn:hover {
  background: var(--warning-color, #f0ad4e);
  color: #fff;
  border-color: var(--warning-color, #f0ad4e);
}

.media-control-btn.example-delete-btn:hover:not(.disabled) {
  background: var(--lora-error);
  color: white;
  border-color: var(--lora-error);
}

/* Disabled state for delete and create-recipe buttons */
.media-control-btn.example-delete-btn.disabled,
.media-control-btn.create-recipe-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Two-step confirmation for delete button */
.media-control-btn.example-delete-btn .confirm-icon {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--lora-error);
  color: white;
  font-size: 1em;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.media-control-btn.example-delete-btn.confirm .fa-trash-alt {
  opacity: 0;
}

.media-control-btn.example-delete-btn.confirm .confirm-icon {
  opacity: 1;
}

.media-control-btn.example-delete-btn.confirm {
  background: var(--lora-error);
  color: white;
  border-color: var(--lora-error);
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
  }
  70% {
    box-shadow: 0 0 0 5px rgba(220, 53, 69, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(220, 53, 69, 0);
  }
}

/* Image Metadata Panel Styles */
.image-metadata-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-color);
  border-top: 1px solid var(--border-color);
  padding: var(--space-2);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.25s ease;
  z-index: 5;
  max-height: 50%; /* Reduced to take less space */
  overflow-y: auto;
  box-shadow: var(--shadow-inset-top);
  opacity: 0;
  pointer-events: none;
}

/* Show metadata panel only when the 'visible' class is added */
.media-wrapper .image-metadata-panel.visible {
  transform: translateY(0);
  opacity: 0.98;
  pointer-events: auto;
}

/* Hoisted panel: pinned to the bottom of .gallery-main at full column width */
.gallery-main > .image-metadata-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 7;
  max-height: 60%;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-color);
}

.gallery-main > .image-metadata-panel.visible {
  transform: translateY(0);
  opacity: 0.98;
  pointer-events: auto;
}

/* Adjust to dark theme */
[data-theme="dark"] .image-metadata-panel {
  background: var(--card-bg);
  box-shadow: var(--shadow-inset-top);
}

.metadata-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Header row for params section */
.metadata-row.params-row {
    flex-direction: column;
}

.metadata-row.params-row .param-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

/* Styling for parameters tags */
.params-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: var(--space-1);
  padding-bottom: var(--space-1);
  border-bottom: 1px solid var(--lora-border);
}

.param-tag {
  display: inline-flex;
  align-items: center;
  background: var(--lora-surface);
  border: 1px solid var(--lora-border);
  border-radius: var(--border-radius-xs);
  padding: 2px 6px;
  font-size: 0.8em;
  line-height: 1.2;
  white-space: nowrap;
}

.param-tag .param-name {
  font-weight: 600;
  color: var(--text-color);
  margin-right: 4px;
  opacity: 0.8;
}

.param-tag .param-value {
  color: var(--lora-accent);
}

/* Special styling for prompt row */
.metadata-row.prompt-row {
  flex-direction: column;
  padding-top: 0;
}

.metadata-row.prompt-row + .metadata-row.prompt-row {
  margin-top: var(--space-2);
}

.metadata-row.prompt-row .param-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.metadata-row.prompt-row .param-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.metadata-label {
  font-weight: 600;
  color: var(--text-color);
  opacity: 0.8;
  font-size: 0.85em;
}

.metadata-prompt-wrapper {
  position: relative;
  background: var(--lora-surface);
  border: 1px solid var(--lora-border);
  border-radius: var(--border-radius-xs);
  padding: 6px 8px;
  margin-top: 2px;
  max-height: 80px; /* Reduced from 120px */
  overflow-y: auto;
  word-break: break-word;
  width: 100%;
  box-sizing: border-box;
}

.metadata-prompt {
  color: var(--text-color);
  font-family: var(--font-mono);
  font-size: 0.85em;
  white-space: pre-wrap;
}

.copy-prompt-btn,
.send-prompt-btn,
.send-params-btn {
  background: transparent;
  border: none;
  color: var(--text-color);
  opacity: 0.6;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: var(--border-radius-xs);
  transition: var(--transition-base);
  font-size: 0.9em;
}

.copy-prompt-btn:hover,
.send-prompt-btn:hover,
.send-params-btn:hover {
  opacity: 1;
  color: var(--lora-accent);
  background: var(--lora-surface);
}

/* Scrollbar styling for metadata panel */
.image-metadata-panel::-webkit-scrollbar {
  width: 6px;
}

.image-metadata-panel::-webkit-scrollbar-track {
  background: transparent;
}

.image-metadata-panel::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: 3px;
}

/* For Firefox */
.image-metadata-panel {
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

/* No metadata message styling */
.no-metadata-message {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2);
  color: var(--text-color);
  opacity: 0.7;
  text-align: center;
  font-style: italic;
  gap: 8px;
}

.no-metadata-message i {
  font-size: 1.1em;
  color: var(--lora-accent);
  opacity: 0.8;
}

.lazy {
  opacity: 0;
  transition: opacity 0.3s;
}

.lazy[src] {
  opacity: 1;
}

/* Example Import Area */
.example-import-area {
  margin-top: var(--space-4);
  padding: var(--space-2);
}

.example-import-area.empty {
  margin-top: var(--space-2);
  padding: var(--space-4) var(--space-2);
}

.import-container {
  border: 2px dashed var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: var(--space-4);
  text-align: center;
  transition: var(--transition-slow);
  background: var(--lora-surface);
  cursor: pointer;
}

.import-container.highlight {
  border-color: var(--lora-accent);
  background: oklch(var(--lora-accent-l) var(--lora-accent-c) var(--lora-accent-h) / 0.1);
  transform: scale(1.01);
}

.import-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding-top: var(--space-1);
}

.import-placeholder i {
  font-size: 2.5rem;
  /* color: var(--lora-accent); */
  opacity: 0.8;
  margin-bottom: var(--space-1);
}

.import-placeholder h3 {
  margin: 0 0 var(--space-1);
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--text-color);
}

.import-placeholder p {
  margin: var(--space-1) 0;
  color: var(--text-color);
  opacity: 0.8;
}

.import-placeholder .sub-text {
  font-size: 0.9em;
  opacity: 0.6;
  margin: var(--space-1) 0;
}

.import-formats {
  font-size: 0.8em;
  opacity: 0.6;
  margin-top: var(--space-2);
}

.select-files-btn {
  background: var(--lora-accent);
  color: var(--lora-text);
  border: none;
  border-radius: var(--border-radius-xs);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  font-size: 0.9em;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition-base);
}

.select-files-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* For dark theme */
[data-theme="dark"] .import-container {
  background: var(--surface-subtle);
}

/* Setup Guidance State - When example images path is not configured */
.import-container--needs-setup {
  cursor: default;
  border-style: solid;
  border-color: var(--border-color);
  background: var(--lora-surface);
}

.import-container--needs-setup:hover {
  border-color: var(--border-color);
  transform: none;
}

.import-setup-guidance {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-2);
  text-align: center;
}

.setup-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: oklch(var(--lora-accent-l) var(--lora-accent-c) var(--lora-accent-h) / 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-1);
}

.setup-icon i {
  font-size: 1.75rem;
  color: var(--lora-accent);
}

.import-setup-guidance h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-color);
}

.setup-description {
  margin: 0;
  color: var(--text-color);
  opacity: 0.9;
  max-width: 320px;
  line-height: 1.5;
}

.setup-usage {
  margin: 0;
  font-size: 0.85em;
  color: var(--text-color);
  opacity: 0.6;
  font-style: italic;
}

.setup-settings-btn {
  margin-top: var(--space-2);
  background: var(--lora-accent) !important;
  color: var(--lora-text) !important;
}

.setup-settings-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}
