import 'package:flutter/material.dart';
import 'oto_console_contract.dart';

/// Row density for the shared artifact browser anatomy.
///
/// [full] is used by the standalone Artifacts browser tab, [compact] by the
/// selected execution detail artifact pane. Both share file identity,
/// path/location, and a reserved trailing slot for future artifact actions.
enum ArtifactRowDensity { full, compact }

/// Shared artifact record row used by both the Artifacts browser tab and the
/// execution detail artifact pane so they keep the same anatomy.
///
/// Keeps the full path with an ellipsis and does not add download or content
/// preview affordances; the trailing region is reserved for future actions.
class ArtifactRecordRow extends StatelessWidget {
  final OtoArtifactViewModel artifact;
  final OtoConsoleThemeAdapter theme;
  final ArtifactRowDensity density;

  const ArtifactRecordRow({
    super.key,
    required this.artifact,
    required this.theme,
    this.density = ArtifactRowDensity.full,
  });

  @override
  Widget build(BuildContext context) {
    final isFull = density == ArtifactRowDensity.full;
    return Container(
      padding: EdgeInsets.all(isFull ? 16 : 10),
      decoration: BoxDecoration(
        color: isFull ? theme.railBackgroundColor : theme.backgroundColor,
        borderRadius: BorderRadius.circular(isFull ? 8 : 6),
        border: Border.all(color: theme.borderColor),
      ),
      child: Row(
        children: [
          Icon(
            Icons.insert_drive_file_outlined,
            color: theme.primaryColor,
            size: isFull ? 24 : 16,
          ),
          SizedBox(width: isFull ? 16 : 12),
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  artifact.name,
                  style: TextStyle(
                    color: theme.textColor,
                    fontSize: isFull ? 15 : 13,
                    fontWeight: FontWeight.bold,
                  ),
                  overflow: TextOverflow.ellipsis,
                ),
                const SizedBox(height: 4),
                Text(
                  'Path: ${artifact.path}',
                  style: TextStyle(
                    color: theme.textSecondaryColor,
                    fontSize: isFull ? 12 : 11,
                  ),
                  overflow: TextOverflow.ellipsis,
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
