export type UserRole = 'admin' | 'assistant' | 'student';

export interface User {
  id: number;
  name: string;
  username: string;
  role: UserRole;
  email?: string;
  phone?: string;
}

export interface LoginCredentials {
  role: UserRole;
  username: string;
  password: string;
}

export interface Student {
  id: number;
  studentId: string;
  fullName: string;
  dateOfBirth: string;
  gender: 'male' | 'female' | 'other';
  phone: string;
  email?: string;
  address?: string;
  guardianName?: string;
  guardianPhone?: string;
  guardianRelationship?: 'parent' | 'sibling' | 'other';
  batchId: number;
  batchName?: string;
  skillLevel: 'beginner' | 'intermediate' | 'advanced';
  monthlyFee: number;
  joiningDate: string;
  photoUrl?: string;
  isActive: boolean;
  age?: number;
  feeStatus?: 'paid' | 'due' | 'pending';
}

export interface StudentFormData {
  fullName: string;
  dateOfBirth: string;
  gender: 'male' | 'female' | 'other';
  phone: string;
  email?: string;
  address?: string;
  guardianName: string;
  guardianPhone: string;
  guardianRelationship: 'parent' | 'sibling' | 'other';
  batchId: number;
  skillLevel: 'beginner' | 'intermediate' | 'advanced';
  monthlyFee: number;
  joiningDate: string;
  photo?: File;
}

export interface Batch {
  id: number;
  name: string;
  timing: string;
  skillLevel: 'beginner' | 'intermediate' | 'advanced';
  maxCapacity: number;
  monthlyFee: number;
  studentCount?: number;
  coachId?: number;
  isActive: boolean;
}

export interface BatchFormData {
  name: string;
  timing: string;
  skillLevel: 'beginner' | 'intermediate' | 'advanced';
  maxCapacity: number;
  monthlyFee: number;
}

export interface AttendanceRecord {
  id?: number;
  studentId: number;
  studentName?: string;
  batchId: number;
  date: string;
  status: 'present' | 'absent' | 'holiday';
}

export interface AttendanceStats {
  total: number;
  present: number;
  absent: number;
  holiday: number;
  percentage: number;
}

export interface TimingRecord {
  id: number;
  studentId: number;
  studentName?: string;
  distance: '500m' | '1lap' | '1000m' | '1500m' | '3000m';
  timeSeconds: number;
  timeDisplay: string;
  recordDate: string;
  notes?: string;
  improvement?: number;
}

export interface LapTime {
  lapNumber: number;
  time: string;
  totalTime: string;
  delta?: string;
}

export interface TimingFormData {
  studentId: number;
  distance: string;
  time: string;
  date: string;
  notes?: string;
}

export interface Receipt {
  id: number;
  receiptNumber: string;
  studentId: number;
  studentName?: string;
  monthYear: string;
  monthlyFee: number;
  lateFee: number;
  gstAmount: number;
  totalAmount: number;
  amountPaid: number;
  paymentMethod: string;
  paymentDate: string;
  notes?: string;
  status: 'paid' | 'partial' | 'due';
  createdAt?: string;
}

export interface DueFee {
  studentId: number;
  studentName: string;
  studentIdCode: string;
  amount: number;
  dueDate: string;
  daysOverdue: number;
  batchName?: string;
  phone?: string;
}

export interface PaymentFormData {
  studentId: number;
  amount: number;
  paymentMethod: 'cash' | 'upi' | 'card' | 'bank_transfer' | 'other';
  paymentDate: string;
  notes?: string;
  generateReceipt: boolean;
}

export interface EquipmentItem {
  id: number;
  name: string;
  category: string;
  currentStock: number;
  unitCost: number;
  description?: string;
  photoUrl?: string;
  isActive: boolean;
}

export interface EquipmentFormData {
  name: string;
  category: string;
  initialStock: number;
  unitCost: number;
  description?: string;
  photo?: File;
}

export interface Transaction {
  id: number;
  equipmentId: number;
  equipmentName?: string;
  type: 'buy' | 'sell';
  quantity: number;
  unitPrice: number;
  totalAmount: number;
  buyerSeller?: string;
  studentId?: number;
  transactionDate: string;
  notes?: string;
  profit?: number;
}

export interface SalesSummary {
  revenue: number;
  cost: number;
  profit: number;
  profitMargin: number;
}

export interface DashboardStats {
  totalStudents: number;
  todayAttendance: number;
  feesCollected: number;
  pendingDues: number;
  equipmentCount: number;
  totalBatches: number;
}

export interface ActivityItem {
  id: number;
  type: 'fee' | 'student' | 'attendance' | 'timing' | 'equipment';
  description: string;
  timestamp: string;
}

export interface BirthdayItem {
  studentId: number;
  studentName: string;
  date: string;
  ageTurning: number;
  isToday: boolean;
}

export interface NotificationItem {
  id: number;
  type: 'fee' | 'student' | 'attendance' | 'system';
  title: string;
  description: string;
  timestamp: string;
  isRead: boolean;
}

export interface ApiResponse<T> {
  success: boolean;
  message: string;
  data: T;
  timestamp: string;
}

export interface PaginationData {
  currentPage: number;
  totalPages: number;
  totalItems: number;
  itemsPerPage: number;
}

export interface Expense {
  id: number;
  category: 'rent' | 'salary' | 'electricity' | 'water' | 'maintenance' | 'transport' | 'food' | 'other';
  description: string;
  amount: number;
  expenseDate: string;
  createdAt: string;
}

export interface ExpenseFormData {
  category: 'rent' | 'salary' | 'electricity' | 'water' | 'maintenance' | 'transport' | 'food' | 'other';
  description: string;
  amount: number;
  expenseDate: string;
}

export type NavTab = 'dashboard' | 'students' | 'timing' | 'attendance' | 'reports' | 'more';
