/* Attachment atom: isolated recreation of the shadcn/ui Rhea attachment. */

.attachment-stage {
  align-items: flex-start;
}

.attachment-showcase {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px 24px;
  width: 100%;
  max-width: 720px;
  min-width: 0;
}

.attachment-example {
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 0;
}

.attachment-example--wide {
  grid-column: 1 / -1;
}

.attachment-example-title {
  padding-inline: 4px;
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
}

.attachment-stack {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 8px;
}

.attachment-stack--sizes {
  gap: 12px;
}

.attachment-card {
  position: relative;
  display: flex;
  width: 100%;
  max-width: 100%;
  min-width: 160px;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--card);
  color: var(--card-foreground);
  font-size: 14px;
  line-height: 20px;
  transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.attachment-card[data-state="idle"] {
  border-style: dashed;
}

.attachment-card[data-state="error"] {
  border-color: color-mix(in srgb, var(--destructive) 30%, transparent);
}

.attachment-card:focus-within {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ring) 30%, transparent);
}

.attachment-card--triggered:hover {
  background: color-mix(in srgb, var(--muted) 50%, var(--card));
}

.attachment-media {
  position: relative;
  display: flex;
  width: 40px;
  aspect-ratio: 1;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 10px;
  background: var(--muted);
  color: var(--foreground);
}

.attachment-media svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.attachment-card[data-state="error"] .attachment-media {
  background: color-mix(in srgb, var(--destructive) 10%, transparent);
  color: var(--destructive);
}

.attachment-content {
  max-width: 100%;
  min-width: 0;
  flex: 1 1 0;
  line-height: 1.25;
}

.attachment-title,
.attachment-description {
  display: block;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-title {
  font-weight: 500;
}

.attachment-description {
  margin-top: 2px;
  color: var(--muted-foreground);
  font-size: 12px;
  line-height: 16px;
}

.attachment-card[data-state="error"] .attachment-description {
  color: color-mix(in srgb, var(--destructive) 80%, transparent);
}

.attachment-card[data-state="uploading"] .attachment-title,
.attachment-card[data-state="processing"] .attachment-title {
  color: transparent;
  background-image: linear-gradient(
    110deg,
    var(--foreground) calc(50% - 68px),
    color-mix(in srgb, var(--foreground) 48%, transparent) calc(50% - 34px),
    var(--foreground) 50%,
    color-mix(in srgb, var(--foreground) 48%, transparent) calc(50% + 34px),
    var(--foreground) calc(50% + 68px)
  );
  background-size: calc(200% + 136px) 100%;
  background-clip: text;
  -webkit-background-clip: text;
  animation: attachment-shimmer 2s linear infinite;
}

.attachment-actions {
  position: relative;
  z-index: 2;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
}

.attachment-action {
  display: inline-flex;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: color 150ms ease, background-color 150ms ease, opacity 150ms ease;
}

.attachment-action:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.attachment-action:disabled {
  pointer-events: none;
  opacity: 0.5;
}

.attachment-action svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.attachment-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid color-mix(in srgb, currentColor 22%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: attachment-spin 700ms linear infinite;
}

.attachment-card--vertical {
  width: 120px;
  min-width: 120px;
  flex-direction: column;
  align-items: stretch;
}

.attachment-card--vertical .attachment-media {
  width: 100%;
}

.attachment-card--vertical .attachment-content {
  width: 100%;
  padding-inline: 4px;
}

.attachment-card--vertical .attachment-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  gap: 4px;
}

.attachment-card--vertical .attachment-media svg {
  width: 24px;
  height: 24px;
}

.attachment-media--image {
  opacity: 0.6;
}

.attachment-card[data-state="idle"] .attachment-media--image,
.attachment-card[data-state="done"] .attachment-media--image,
.attachment-card:not([data-state]) .attachment-media--image {
  opacity: 1;
}

.attachment-thumbnail {
  background-color: #8d9691;
  background-repeat: no-repeat;
  background-size: cover;
}

.attachment-thumbnail--workspace {
  background-image:
    linear-gradient(90deg, transparent 45%, rgb(24 29 27 / 0.72) 46% 50%, transparent 51%),
    linear-gradient(180deg, rgb(225 230 222 / 0.92) 0 33%, transparent 34%),
    linear-gradient(135deg, #66736d 0 46%, #b1a493 47% 64%, #4b5551 65%);
}

.attachment-thumbnail--desk {
  background-image:
    linear-gradient(90deg, rgb(228 232 222 / 0.9) 0 28%, transparent 29% 72%, rgb(36 43 40 / 0.5) 73%),
    linear-gradient(180deg, transparent 0 58%, #9b8066 59% 66%, #4f5752 67%),
    linear-gradient(135deg, #687875, #b5beb5 52%, #59645e);
}

.attachment-thumbnail--office {
  background-image:
    linear-gradient(90deg, transparent 0 18%, rgb(30 37 35 / 0.65) 19% 23%, transparent 24% 72%, rgb(30 37 35 / 0.65) 73% 77%, transparent 78%),
    linear-gradient(180deg, #c6cbc4 0 42%, #7f8a83 43% 66%, #5b5048 67%);
}

.attachment-card[data-size="sm"] {
  gap: 10px;
  padding: 6px;
  font-size: 12px;
  line-height: 16px;
}

.attachment-card[data-size="sm"] .attachment-media {
  width: 32px;
}

.attachment-card[data-size="xs"] {
  gap: 6px;
  padding: 4px;
  border-radius: 14px;
  font-size: 12px;
  line-height: 16px;
}

.attachment-card[data-size="xs"] .attachment-media {
  width: 28px;
  border-radius: 8px;
}

.attachment-card[data-size="xs"] .attachment-media svg {
  width: 14px;
  height: 14px;
}

.attachment-group {
  display: flex;
  width: 100%;
  min-width: 0;
  gap: 12px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding-block: 4px;
  scroll-padding-inline: 4px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 6px, #000 calc(100% - 22px), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 6px, #000 calc(100% - 22px), transparent 100%);
}

.attachment-group::-webkit-scrollbar {
  display: none;
}

.attachment-group:focus-visible {
  border-radius: 8px;
}

.attachment-group > .attachment-card {
  scroll-snap-align: start;
}

.attachment-group--images > .attachment-card:last-child {
  margin-right: 12px;
}

.attachment-card--grouped {
  width: 256px;
}

.attachment-trigger {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  outline: none;
}

.attachment-hint {
  padding-inline: 4px;
  color: var(--muted-foreground);
  font-size: 12px;
  line-height: 16px;
}

.attachment-hint:target {
  color: var(--foreground);
}

@keyframes attachment-spin {
  to { transform: rotate(360deg); }
}

@keyframes attachment-shimmer {
  from { background-position: 100% 0; }
  to { background-position: 0 0; }
}

@media (max-width: 760px) {
  .attachment-showcase {
    grid-template-columns: 1fr;
    max-width: 384px;
  }

  .attachment-example--wide {
    grid-column: auto;
  }
}

