import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { useSettings } from '@/theme';

interface HeaderProps {
  title: string;
  showLogo: boolean;
  rightAction?: React.ReactNode;
}

export function Header({ title, showLogo, rightAction }: HeaderProps) {
  const { theme } = useSettings();

  return (
    <View style={[styles.header, { backgroundColor: theme.background }]}>
      <View style={styles.headerContent}>
        {showLogo && (
          <View style={styles.logoContainer}>
            <Text style={styles.logoText}>✓</Text>
          </View>
        )}
        <Text style={[styles.title, { color: theme.text }]}>{title}</Text>
        <View style={styles.spacer}>{rightAction}</View>
      </View>
    </View>
  );
}

const styles = StyleSheet.create({
  header: {
    borderBottomLeftRadius: 24,
    borderBottomRightRadius: 24,
    shadowColor: '#000',
    shadowOffset: { width: 0, height: 2 },
    shadowOpacity: 0.05,
    shadowRadius: 8,
    elevation: 2,
  },
  headerContent: {
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'space-between',
    paddingHorizontal: 20,
    paddingTop: 2,
    paddingBottom: 6,
    height: 44,
  },
  logoContainer: {
    width: 32,
    height: 32,
    borderRadius: 10,
    backgroundColor: '#E53935',
    alignItems: 'center',
    justifyContent: 'center',
  },
  logoText: {
    color: '#FFFFFF',
    fontSize: 18,
    fontWeight: '700',
  },
  title: {
    fontSize: 20,
    fontWeight: '700',
    position: 'absolute',
    left: '50%',
    marginLeft: -30,
  },
  spacer: {
    width: 32,
    alignItems: 'flex-end',
  },
  bottomRounded: {
    height: 16,
    borderBottomLeftRadius: 16,
    borderBottomRightRadius: 16,
    marginTop: -16,
  },
});