/** @type {import('next').NextConfig} */
const nextConfig = {
  // متغیرهای NEXT_PUBLIC_* از env کانتینر/محیط خوانده می‌شوند.
  env: {
    NEXT_PUBLIC_BACKEND_URL:
      process.env.NEXT_PUBLIC_BACKEND_URL || "http://localhost:8000",
    NEXT_PUBLIC_API_BASE_URL:
      process.env.NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000",
    NEXT_PUBLIC_IDENTITY_API_URL:
      process.env.NEXT_PUBLIC_IDENTITY_API_URL || "http://localhost:8001",
    NEXT_PUBLIC_KEYCLOAK_URL:
      process.env.NEXT_PUBLIC_KEYCLOAK_URL || "http://localhost:8080",
    NEXT_PUBLIC_KEYCLOAK_REALM:
      process.env.NEXT_PUBLIC_KEYCLOAK_REALM || "superapp",
    NEXT_PUBLIC_KEYCLOAK_CLIENT_ID:
      process.env.NEXT_PUBLIC_KEYCLOAK_CLIENT_ID || "superapp-frontend",
    NEXT_PUBLIC_ACCOUNTING_API_URL:
      process.env.NEXT_PUBLIC_ACCOUNTING_API_URL || "http://localhost:8002",
    NEXT_PUBLIC_HEALTHCARE_API_URL:
      process.env.NEXT_PUBLIC_HEALTHCARE_API_URL || "http://localhost:8010",
    NEXT_PUBLIC_SPORTS_CENTER_API_URL:
      process.env.NEXT_PUBLIC_SPORTS_CENTER_API_URL || "http://localhost:8006",
  },
  async redirects() {
    return [
      { source: "/healthcare/clinics", destination: "/healthcare/admin/clinics", permanent: false },
      { source: "/healthcare/doctors", destination: "/healthcare/admin/doctors", permanent: false },
      { source: "/healthcare/patients", destination: "/healthcare/admin/patients", permanent: false },
      { source: "/healthcare/departments", destination: "/healthcare/clinic/departments", permanent: false },
      { source: "/healthcare/branches", destination: "/healthcare/hospital/clinics", permanent: false },
      { source: "/healthcare/appointments", destination: "/healthcare/reception/calendar", permanent: false },
      { source: "/healthcare/settings", destination: "/healthcare/admin/settings", permanent: false },
      { source: "/healthcare/medical-records", destination: "/healthcare/doctor/medical-records", permanent: false },
      { source: "/healthcare/doctor-panel", destination: "/healthcare/doctor", permanent: false },
      { source: "/healthcare/patient-portal", destination: "/healthcare/patient", permanent: false },
      { source: "/healthcare/clinic-management", destination: "/healthcare/clinic", permanent: false },
      { source: "/healthcare/pharmacy", destination: "/healthcare/pharmacy-portal", permanent: false },
      { source: "/healthcare/delivery", destination: "/healthcare/pharmacy-portal/delivery", permanent: false },
    ];
  },
};

export default nextConfig;
