import 'package:core_localization/core_localization.dart';
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';

/// Modal for uploading or editing a certificate expiry.
class CertificateUploadModal extends StatelessWidget {
  /// The document being edited, or null for a new upload.
  // ignore: unused_field
  final dynamic
  document; // Using dynamic for now as we don't import domain here to avoid direct coupling if possible, but actually we should import domain.
  // Ideally, widgets should be dumb. Let's import domain.

  final VoidCallback onSave;
  final VoidCallback onCancel;

  const CertificateUploadModal({
    super.key,
    this.document,
    required this.onSave,
    required this.onCancel,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      height: MediaQuery.of(context).size.height * 0.75,
      decoration: const BoxDecoration(
        color: UiColors.bgPopup,
        borderRadius: BorderRadius.only(
          topLeft: Radius.circular(UiConstants.radiusBase),
          topRight: Radius.circular(UiConstants.radiusBase),
        ),
      ),
      padding: const EdgeInsets.all(UiConstants.space6),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              Text(
                t.staff_certificates.upload_modal.title,
                style: UiTypography.headline3m.textPrimary,
              ),
              IconButton(
                onPressed: onCancel,
                icon: const Icon(UiIcons.close, size: 24),
              ),
            ],
          ),
          const SizedBox(height: UiConstants.space8),
          Text(
            t.staff_certificates.upload_modal.expiry_label,
            style: UiTypography.body1m,
          ),
          const SizedBox(height: UiConstants.space2),
          Container(
            padding: const EdgeInsets.symmetric(
              horizontal: UiConstants.space4,
              vertical: UiConstants.space3,
            ),
            decoration: BoxDecoration(
              border: Border.all(color: UiColors.border),
              borderRadius: UiConstants.radiusLg,
            ),
            child: Row(
              children: <Widget>[
                const Icon(
                  UiIcons.calendar,
                  size: 20,
                  color: UiColors.textSecondary,
                ),
                const SizedBox(width: UiConstants.space3),
                Text(
                  t.staff_certificates.upload_modal.select_date,
                  style: UiTypography.body1m.textSecondary,
                ),
              ],
            ),
          ),
          const SizedBox(height: UiConstants.space6),
          Text(
            t.staff_certificates.upload_modal.upload_file,
            style: UiTypography.body1m,
          ),
          const SizedBox(height: UiConstants.space2),
          Expanded(
            child: Container(
              width: double.infinity,
              decoration: BoxDecoration(
                border: Border.all(
                  color: UiColors.border,
                  style: BorderStyle.solid,
                ),
                borderRadius: UiConstants.radiusLg,
                color: UiColors.background,
              ),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Container(
                    padding: const EdgeInsets.all(UiConstants.space4),
                    decoration: BoxDecoration(
                      color: UiColors.tagActive,
                      shape: BoxShape.circle,
                    ),
                    child: const Icon(
                      UiIcons.uploadCloud,
                      size: 32,
                      color: UiColors.primary,
                    ),
                  ),
                  const SizedBox(height: UiConstants.space4),
                  Text(
                    t.staff_certificates.upload_modal.drag_drop,
                    style: UiTypography.body1m,
                  ),
                  const SizedBox(height: 4),
                  Text(
                    t.staff_certificates.upload_modal.supported_formats,
                    style: UiTypography.body3r.textSecondary,
                  ),
                ],
              ),
            ),
          ),
          const SizedBox(height: UiConstants.space6),
          Row(
            children: <Widget>[
              Expanded(
                child: OutlinedButton(
                  onPressed: onCancel,
                  style: OutlinedButton.styleFrom(
                    padding: const EdgeInsets.symmetric(
                      vertical: UiConstants.space4,
                    ),
                    shape: RoundedRectangleBorder(
                      borderRadius: UiConstants.radiusLg,
                    ),
                    side: const BorderSide(color: UiColors.border),
                  ),
                  child: Text(
                    t.staff_certificates.upload_modal.cancel,
                    style: UiTypography.body1m.textPrimary,
                  ),
                ),
              ),
              const SizedBox(width: UiConstants.space4),
              Expanded(
                child: ElevatedButton(
                  onPressed: onSave,
                  style: ElevatedButton.styleFrom(
                    backgroundColor: UiColors.primary,
                    padding: const EdgeInsets.symmetric(
                      vertical: UiConstants.space4,
                    ),
                    shape: RoundedRectangleBorder(
                      borderRadius: UiConstants.radiusLg,
                    ),
                    elevation: 0,
                  ),
                  child: Text(
                    t.staff_certificates.upload_modal.save,
                    style: UiTypography.body1m.white,
                  ),
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
