import 'package:flutter/material.dart';
import '../constants/app_dimensions.dart';
import '../constants/app_typography.dart';

/// 상세 정보를 표시하는 공통 행 위젯
/// [label]과 [value]를 수직 또는 수평으로 배치
class InfoRow extends StatelessWidget {
  final String label;
  final String value;
  final bool isDark;

  /// true: 수평 배치 (레이블 | 값), false: 수직 배치 (레이블 위, 값 아래)
  final bool horizontal;

  /// 수평 배치 시 레이블 영역 너비
  final double? labelWidth;

  const InfoRow({
    super.key,
    required this.label,
    required this.value,
    required this.isDark,
    this.horizontal = false,
    this.labelWidth = 80,
  });

  @override
  Widget build(BuildContext context) {
    if (horizontal) {
      return Padding(
        padding: const EdgeInsets.symmetric(vertical: AppDimensions.paddingXs),
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            SizedBox(
              width: labelWidth,
              child: Text(label, style: AppTypography.caption(isDark)),
            ),
            const SizedBox(width: AppDimensions.paddingSm),
            Expanded(child: Text(value, style: AppTypography.body2(isDark))),
          ],
        ),
      );
    }

    return Padding(
      padding: const EdgeInsets.symmetric(vertical: AppDimensions.paddingXs),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(label, style: AppTypography.caption(isDark)),
          const SizedBox(height: 2),
          Text(value, style: AppTypography.body2(isDark)),
        ],
      ),
    );
  }
}
