/* ==========================================================================
   Attachment Components: Image Previews, Video Players, File Download Chips
   ========================================================================== */

[data-attachments] {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

[data-attachment-preview] {
  display: block;
  width: 90px;
  height: 90px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  background-color: var(--surface-alt);
  transition: transform 0.15s, box-shadow 0.15s;

  &:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }

  & img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }
}

[data-attachment-video] {
  width: 100%;
  max-width: 480px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000000;
  margin: 0.25rem 0;

  & video {
    width: 100%;
    max-height: 320px;
    display: block;
  }
}

[data-attachment-chip] {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  background-color: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s;

  &:hover {
    background-color: var(--primary-subtle);
    border-color: var(--primary);
    color: var(--primary);
  }

  & span {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ==========================================================================
   File Input & Interactive Upload Dropzone Component
   ========================================================================== */

input[type="file"] {
  font-size: 0.9rem;
  padding: 0.35rem 0.5rem;
  background-color: var(--surface-alt);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  width: 100%;
}

input[type="file"]::file-selector-button {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  margin-inline-end: 0.75rem;
  background-color: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.15s, transform 0.1s;

  &:hover {
    background-color: var(--primary-hover);
  }
}

[data-file-dropzone] {
  display: block;
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background-color: var(--surface-alt);
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;

  &:hover,
  &:focus-within,
  &[data-dragging="true"] {
    border-color: var(--primary);
    background-color: var(--primary-subtle);
  }

  & input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 2;
  }

  & [data-dropzone-content] {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    pointer-events: none;

    & svg {
      color: var(--primary);
      stroke-width: 1.75;
    }

    & strong {
      font-size: 0.95rem;
      color: var(--text);
      display: block;
    }

    & small {
      font-size: 0.8rem;
      color: var(--text-muted);
      display: block;
    }
  }

  & [data-file-list] {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.85rem;
    justify-content: center;
    position: relative;
    z-index: 3;

    &:empty {
      display: none;
    }
  }

  & [data-selected-pill] {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text);
    box-shadow: var(--shadow-sm);

    & svg {
      color: var(--primary);
      flex-shrink: 0;
    }

    & small {
      color: var(--text-muted);
      font-weight: normal;
    }
  }
}
