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

enum DockTab { todo, calendar }

class BottomDock extends StatelessWidget {
  final DockTab activeTab;
  final VoidCallback? onTodoTap;
  final VoidCallback? onCalendarTap;
  final VoidCallback? onHomeTap;

  const BottomDock({
    super.key,
    required this.activeTab,
    this.onTodoTap,
    this.onCalendarTap,
    this.onHomeTap,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 61,
      padding: const EdgeInsets.only(left: 20, right: 20, top: 12, bottom: 18),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [_buildToggle(), _buildHomeBtn()],
      ),
    );
  }

  Widget _buildToggle() {
    return Container(
      padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 4),
      decoration: BoxDecoration(
        color: const Color(0xFFFDFEFF),
        borderRadius: BorderRadius.circular(24),
        border: Border.all(color: const Color(0xFFDCE6F4)),
      ),
      child: Row(
        mainAxisSize: MainAxisSize.min,
        children: [
          _buildToggleItem(
            icon: LucideIcons.listTodo,
            isActive: activeTab == DockTab.todo,
            onTap: onTodoTap,
          ),
          const SizedBox(width: 4),
          _buildToggleItem(
            icon: LucideIcons.calendar,
            isActive: activeTab == DockTab.calendar,
            onTap: onCalendarTap,
          ),
        ],
      ),
    );
  }

  Widget _buildToggleItem({
    required IconData icon,
    required bool isActive,
    VoidCallback? onTap,
  }) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        width: 44,
        height: 44,
        decoration: BoxDecoration(
          color: isActive ? const Color(0xFFD6E6FF) : Colors.transparent,
          borderRadius: BorderRadius.circular(18),
          border: Border.all(
            color: isActive ? const Color(0xFFBFD6FB) : Colors.transparent,
          ),
        ),
        child: Icon(
          icon,
          size: 20,
          color: isActive ? const Color(0xFF1D4ED8) : const Color(0xFF334155),
        ),
      ),
    );
  }

  Widget _buildHomeBtn() {
    return GestureDetector(
      onTap: onHomeTap,
      child: Container(
        width: 44,
        height: 44,
        decoration: BoxDecoration(
          color: const Color(0xFFE6EEFB),
          borderRadius: BorderRadius.circular(18),
          border: Border.all(color: const Color(0xFFC9D8EE)),
        ),
        child: const Icon(LucideIcons.home, size: 20, color: Color(0xFF1E3A8A)),
      ),
    );
  }
}
