const mongoose = require('mongoose');

const maintenanceSchema = new mongoose.Schema({
  vehicle_id: { type: mongoose.Schema.Types.ObjectId, ref: 'Vehicle', required: true },
  service_type: { type: String, enum: ['routine','repair','inspection','tire','oil_change','brake','engine','other'], required: true },
  service_date: { type: Date, required: true },
  next_service_date: Date,
  odometer_at_service: Number,
  service_center: String,
  technician: String,
  description: String,
  parts_replaced: String,
  cost: { type: Number, default: 0 },
  status: { type: String, enum: ['scheduled','in_progress','completed','cancelled'], default: 'scheduled' },
  notes: String,
}, { timestamps: true });

module.exports = mongoose.model('Maintenance', maintenanceSchema);
