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: Colors.white,
        borderRadius: BorderRadius.only(
          topLeft: Radius.circular(24),
          topRight: Radius.circular(24),
        ),
      ),
      padding: const EdgeInsets.all(24),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              Text(
                t.staff_certificates.upload_modal.title,
                style: UiTypography.headline3m.copyWith(color: UiColors.textPrimary),
              ),
              IconButton(
                onPressed: onCancel,
                icon: const Icon(UiIcons.close, size: 24),
              ),
            ],
          ),
          const SizedBox(height: 32),
          Text(
            t.staff_certificates.upload_modal.expiry_label,
            style: UiTypography.body1m,
          ),
          const SizedBox(height: 8),
          Container(
            padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
            decoration: BoxDecoration(
              border: Border.all(color: UiColors.border),
              borderRadius: BorderRadius.circular(12),
            ),
            child: Row(
              children: <Widget>[
                const Icon(UiIcons.calendar, size: 20, color: UiColors.textSecondary),
                const SizedBox(width: 12),
                Text(
                  t.staff_certificates.upload_modal.select_date,
                  style: UiTypography.body1m.copyWith(color: UiColors.textSecondary),
                ),
              ],
            ),
          ),
          const SizedBox(height: 24),
          Text(
            t.staff_certificates.upload_modal.upload_file,
            style: UiTypography.body1m,
          ),
          const SizedBox(height: 8),
          Expanded(
            child: Container(
              width: double.infinity,
              decoration: BoxDecoration(
                border: Border.all(
                  color: UiColors.border,
                  style: BorderStyle.solid,
                ),
                borderRadius: BorderRadius.circular(16),
                color: UiColors.background,
              ),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Container(
                    padding: const EdgeInsets.all(16),
                    decoration: const BoxDecoration(
                      color: Color(0xFFEFF6FF), // Light blue
                      shape: BoxShape.circle,
                    ),
                    child: const Icon(
                      UiIcons.uploadCloud,
                      size: 32,
                      color: UiColors.primary,
                    ),
                  ),
                  const SizedBox(height: 16),
                  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.copyWith(color: UiColors.textSecondary),
                  ),
                ],
              ),
            ),
          ),
          const SizedBox(height: 24),
          Row(
            children: <Widget>[
              Expanded(
                child: OutlinedButton(
                  onPressed: onCancel,
                  style: OutlinedButton.styleFrom(
                    padding: const EdgeInsets.symmetric(vertical: 16),
                    shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(12),
                    ),
                    side: const BorderSide(color: UiColors.border),
                  ),
                  child: Text(t.staff_certificates.upload_modal.cancel,
                      style: UiTypography.body1m.copyWith(color: UiColors.textPrimary)),
                ),
              ),
              const SizedBox(width: 16),
              Expanded(
                child: ElevatedButton(
                  onPressed: onSave,
                  style: ElevatedButton.styleFrom(
                    backgroundColor: UiColors.primary,
                    padding: const EdgeInsets.symmetric(vertical: 16),
                    shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(12),
                    ),
                    elevation: 0,
                  ),
                  child: Text(t.staff_certificates.upload_modal.save,
                      style: UiTypography.body1m.copyWith(color: Colors.white)),
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
