/* sg-image-card — interactive generated-image card (generate_image tool).
   Mirrors the detail panel's cover-art visuals (canvas + hover overlay +
   swatches) at chat-bubble size; also hosted inside the detail panel's
   "generated-image" artifact view. */

.sg-image-card {
  display: block;
  max-width: 320px;
  margin-top: 12px;
}

.sg-image-card__canvas {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 8px;
}

.sg-image-card__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Hover overlay with regenerate/download */
.sg-image-card__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.15s;
  border-radius: 8px;
}

.sg-image-card__canvas:hover .sg-image-card__overlay {
  opacity: 1;
}

.sg-image-card__overlay button {
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.sg-image-card__overlay button:hover {
  background: rgba(0, 0, 0, 0.85);
}

.sg-image-card__swatches {
  display: flex;
  gap: 8px;
  padding: 0 2px;
}

.sg-image-card__swatch {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.15s;
}

.sg-image-card__swatch--active {
  border-color: var(--color-text);
}

.sg-image-card__swatch:hover:not(.sg-image-card__swatch--active) {
  border-color: var(--color-text-secondary);
}

.sg-image-card__use-cover {
  margin-top: 8px;
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.15s;
}

.sg-image-card__use-cover:hover {
  background: var(--color-bg-secondary);
}

.sg-image-card__loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
}

.sg-image-card__spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: sg-image-card-spin 0.8s linear infinite;
}

@keyframes sg-image-card-spin {
  to { transform: rotate(360deg); }
}

.sg-image-card__error {
  font-size: 12px;
  color: var(--color-error);
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sg-image-card__retry {
  font-size: 12px;
  border: none;
  background: none;
  color: var(--color-text);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

/* Inside the detail panel the card can use the panel's full width. */
.sg-detail-panel__image-artifact .sg-image-card {
  max-width: none;
  margin-top: 0;
}
